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_ID=
APP_IPPR= APP_IPPR=
APP_PORT=2222 APP_PORT=2222
APP_DEV_PORT=
LOG_CHANNEL=stack LOG_CHANNEL=stack
LOG_LEVEL=debug LOG_LEVEL=debug

View File

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

3
cmd
View File

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

View File

@ -37,19 +37,7 @@
</div> </div>
</div> </div>
@php {!! $script !!}
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
</body> </body>
</html> </html>

32
vite.config.js vendored
View File

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