2 Commits 8c32ccac55 ... ef003974b2

Tác giả SHA1 Thông báo Ngày
  chenlei ef003974b2 feat: -- 1 ngày trước cách đây
  chenlei 640a772b3f style: -- 1 tuần trước cách đây

+ 2 - 1
scripts/generate-offline-config.js

@@ -6,9 +6,10 @@ const _filename = fileURLToPath(import.meta.url);
 const _dirname = dirname(_filename);
 
 const scene = process.env.VITE_APP_SCENE;
+const scenePath = scene ? '/' + scene : '';
 
 const configContent = `{
-  "files": "build${scene ? '/' + scene : ''}/js/*.js",
+  "files": ["build${scenePath}/js/*.js", "build${scenePath}/data/*.json"],
   "from": "https://super.4dage.com",
   "to": "."
 }`;

+ 1 - 1
scripts/offline-replace-config.json

@@ -1,5 +1,5 @@
 {
-  "files": "build/js/*.js",
+  "files": ["build/js/*.js", "build/data/*.json"],
   "from": "https://super.4dage.com",
   "to": "."
 }

+ 6 - 2
src/index/views/home/index.scss

@@ -1,6 +1,10 @@
 .home {
-  width: 100%;
-  height: 100%;
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  overflow: hidden;
 
   &_logo {
     display: flex;

+ 26 - 18
vite.config.ts

@@ -13,9 +13,34 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
 const IS_PRODUCTION = process.env.NODE_ENV === 'production';
 // 当前场景
 const SCENE = process.env.VITE_APP_SCENE;
+// 是否离线包
+const OFFLINE = Boolean(Number(process.env.VITE_APP_OFFLINE));
+const extensions = ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'];
 
 if (SCENE != null) {
   console.log('当前场景:', SCENE);
+
+  extensions.unshift(
+    `.${SCENE}.mjs`,
+    `.${SCENE}.js`,
+    `.${SCENE}.ts`,
+    `.${SCENE}.jsx`,
+    `.${SCENE}.tsx`,
+    `.${SCENE}.json`,
+    `.${SCENE}.vue`
+  );
+
+  if (OFFLINE) {
+    extensions.unshift(
+      `.${SCENE}.offline.mjs`,
+      `.${SCENE}.offline.js`,
+      `.${SCENE}.offline.ts`,
+      `.${SCENE}.offline.jsx`,
+      `.${SCENE}.offline.tsx`,
+      `.${SCENE}.offline.json`,
+      `.${SCENE}.offline.vue`
+    );
+  }
 }
 
 // https://vite.dev/config/
@@ -52,24 +77,7 @@ export default defineConfig(() => {
         '@': fileURLToPath(new URL('./src/index', import.meta.url)),
         '@hotspot': fileURLToPath(new URL('./src/hotspot', import.meta.url)),
       },
-      extensions: SCENE
-        ? [
-            `.${SCENE}.mjs`,
-            `.${SCENE}.js`,
-            `.${SCENE}.ts`,
-            `.${SCENE}.jsx`,
-            `.${SCENE}.tsx`,
-            `.${SCENE}.json`,
-            `.${SCENE}.vue`,
-            '.mjs',
-            '.js',
-            '.ts',
-            '.jsx',
-            '.tsx',
-            '.json',
-            '.vue',
-          ]
-        : ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
+      extensions,
     },
     server: {
       port: Number(process.env.PORT) || 80,