no message

This commit is contained in:
kuaifan 2023-02-24 00:30:07 +08:00
parent 3a74fc6d4e
commit 914b19ea58
5 changed files with 35 additions and 35 deletions

View File

@ -8,6 +8,7 @@ APP_URL=http://localhost
APP_ID=
APP_IPPR=
APP_PORT=2222
APP_DEV_PORT=
LOG_CHANNEL=stack
LOG_LEVEL=debug

View File

@ -52,19 +52,19 @@ class IndexController extends InvokeController
*/
public function main()
{
$hash = 'no';
$path = public_path('js/hash');
$murl = url('manifest.txt');
if (file_exists($path)) {
$hash = trim(file_get_contents(public_path('js/hash')));
if (strlen($hash) > 16) {
$hash = 'long';
}
$scripts = [];
if (config('app.debug')) {
$port = env("APP_DEV_PORT");
$scripts[] = "<script type=\"module\" src=\"http://localhost:{$port}/resources/assets/js/app.js\"></script>";
} else {
$manifest = Base::json2array(file_get_contents(public_path('manifest.json')));
$scripts[] = "<link rel=\"stylesheet\" href=\"" . asset_main($manifest['resources/assets/js/app.js']['css'][0]) . "\"/>";
$scripts[] = "<script type=\"module\" src=\"" . asset_main($manifest['resources/assets/js/app.js']['file']) . "\"></script>";
}
return response()->view('main', [
'version' => Base::getVersion(),
'hash' => $hash
])->header('Link', "<{$murl}>; rel=\"prefetch\"");
'script' => implode("\n", $scripts),
])->header('Link', "<" . url('manifest.txt') . ">; rel=\"prefetch\"");
}
/**

3
cmd
View File

@ -99,6 +99,9 @@ run_compile() {
if [ ! -d "./node_modules" ]; then
npm install
fi
if [ "$type" = "dev" ]; then
env_set APP_DEV_PORT $(rand 20001 30000)
fi
run_exec php "php bin/run --mode=$type"
supervisorctl_restart php
#

View File

@ -37,19 +37,7 @@
</div>
</div>
@php
if (config('app.debug')) {
echo ' <script type="module" src="http://127.0.0.1:22222/resources/assets/js/app.js"></script> ';
}else{
$manifest = json_decode(file_get_contents(public_path('manifest.json')), true);
$css = $manifest['resources/assets/js/app.js']['css'][0];
$css2 = $manifest['resources/assets/js/pages/manage/calendar.vue']['css'][0];
$js = $manifest['resources/assets/js/app.js']['file'];
echo ' <link rel="stylesheet" href="/' . $css . '" /> ';
echo ' <link rel="stylesheet" href="/' . $css2 . '" /> ';
echo ' <script type="module" src="/'.$js.'"></script> ';
}
@endphp
{!! $script !!}
</body>
</html>

32
vite.config.js vendored
View File

@ -1,5 +1,5 @@
import {resolve} from "path";
import {defineConfig} from 'vite'
import {defineConfig, loadEnv} from 'vite'
import {createVuePlugin} from 'vite-plugin-vue2';
import vitePluginRequire from 'vite-plugin-require'
import vitePluginFileCopy from 'vite-plugin-file-copy';
@ -8,24 +8,26 @@ const argv = process.argv;
const isElectron = argv.includes('--electron');
const publicPath = isElectron ? 'electron/public' : 'public';
const serverHost = '0.0.0.0'
const serverPort = 22222
export default defineConfig(({command, mode}) => {
const env = loadEnv(mode, process.cwd(), '')
const host = "0.0.0.0"
const port = parseInt(env['APP_DEV_PORT'])
return {
base: '/',
publicDir: publicPath,
server: {
host: serverHost,
port: serverPort,
host,
port,
strictPort: false,
},
resolve: {
alias: {
'~element-ui': resolve(__dirname, './node_modules/element-ui'),
'~quill': resolve(__dirname, './node_modules/quill'),
'~quill-mention-hi': resolve(__dirname, './node_modules/quill-mention-hi'),
'../images': resolve(__dirname, command === 'serve' ? '/images' : './resources/assets/statics/public/images'),
'../css': resolve(__dirname, command === 'serve' ? '/css' : './resources/assets/statics/public/css')
'~element-ui': resolve(__dirname, 'node_modules/element-ui'),
'~quill': resolve(__dirname, 'node_modules/quill'),
'~quill-mention-hi': resolve(__dirname, 'node_modules/quill-mention-hi'),
'../images': resolve(__dirname, command === 'serve' ? '/images' : 'resources/assets/statics/public/images'),
'../css': resolve(__dirname, command === 'serve' ? '/css' : 'resources/assets/statics/public/css')
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
@ -36,15 +38,21 @@ export default defineConfig(({command, mode}) => {
manifest: true,
outDir: publicPath,
assetsDir: "js/build",
emptyOutDir: false,
copyPublicDir: false,
rollupOptions: {
input: 'resources/assets/js/app.js',
},
brotliSize: false,
chunkSizeWarningLimit: 3000,
},
plugins: [
createVuePlugin(),
vitePluginRequire(),
vitePluginFileCopy([{src: 'resources/assets/statics/public', dest: publicPath}]),
vitePluginFileCopy([{
src: resolve(__dirname, 'resources/assets/statics/public'),
dest: resolve(__dirname, publicPath)
}]),
]
};
});