From 340d18a1f07ed7356c589f1892900dae5ccd3591 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 7 Mar 2024 20:13:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 1 - index.html | 14 ++++++------- src/main.ts | 54 ++++++++++++++++++++++++++++++++++++++++++------- src/styles.less | 5 +++++ vite.config.ts | 18 +++++++++++------ 5 files changed, 71 insertions(+), 21 deletions(-) diff --git a/.prettierignore b/.prettierignore index 14f8109..4a9dabf 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,3 @@ -vite.config.ts public/project/data.js story.md public/project/floors/*.js diff --git a/index.html b/index.html index 7f2c736..00a65c5 100644 --- a/index.html +++ b/index.html @@ -160,13 +160,13 @@
- - - - - - - + + + + + + + diff --git a/src/main.ts b/src/main.ts index 7bfc967..b388f93 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,13 +1,53 @@ import { createApp } from 'vue'; -import './game/index'; -import './core/index'; -import App from './App.vue'; import './styles.less'; -import 'ant-design-vue/dist/antd.dark.css'; +import 'ant-design-vue/dist/antd.dark.less'; export * from './game/system'; -createApp(App).mount('#root'); +const list = [ + 'libs/thirdparty/lz-string.min.js', + 'libs/thirdparty/priority-queue.min.js', + 'libs/thirdparty/localforage.min.js', + 'libs/thirdparty/zip.min.js', + 'project/data.js', + 'main.js' +]; -main.init('play'); -main.listen(); +load(); + +async function load() { + await loadJsList(list); + await import('./game/index'); + await import('./core/index'); + const { default: App } = await import('./App.vue'); + + createApp(App).mount('#root'); + + main.init('play'); + main.listen(); +} + +function loadJsList(list: string[]) { + return Promise.all( + list.map(v => { + return loadJs(v); + }) + ); +} + +function loadJs(src: string) { + const script = document.createElement('script'); + script.src = src; + script.crossOrigin = 'anonymous'; + document.body.appendChild(script); + + return new Promise(res => { + script.addEventListener( + 'load', + () => { + res(); + }, + { once: true } + ); + }); +} diff --git a/src/styles.less b/src/styles.less index 5af63f7..c64f93f 100644 --- a/src/styles.less +++ b/src/styles.less @@ -1,5 +1,10 @@ // 部分全局css特效 +html, +body { + background-color: black; +} + #root { position: fixed; display: block; diff --git a/vite.config.ts b/vite.config.ts index 3f697b1..27c8e3c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,9 +2,9 @@ import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import legacy from '@vitejs/plugin-legacy'; import components from 'unplugin-vue-components/vite'; -import vuejsx from '@vitejs/plugin-vue-jsx' +import vuejsx from '@vitejs/plugin-vue-jsx'; import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; -import dts from 'vite-plugin-dts' +import dts from 'vite-plugin-dts'; import { resolve } from 'path'; // @ts-ignore import postcssPreset from 'postcss-preset-env'; @@ -16,7 +16,13 @@ export default defineConfig({ plugins: [ vue(), vuejsx(), - components({ resolvers: [AntDesignVueResolver()] }) + components({ + resolvers: [ + AntDesignVueResolver({ + importStyle: false + }) + ] + }) ], base: `./`, resolve: { @@ -67,18 +73,18 @@ export default defineConfig({ changeOrigin: true, rewrite(path) { return './' + path.replace(/^\/all/, ''); - }, + } }, '^/forceTem/.*': { target: FSHOST, changeOrigin: true, rewrite(path) { return './' + path.replace(/^\/forceTem/, ''); - }, + } } }, watch: { ignored: ['**/public/**'] - }, + } } });