Ver código fonte

chore: 根据场景输出html名称

chenlei 2 anos atrás
pai
commit
afb3a21426
5 arquivos alterados com 33 adições e 8 exclusões
  1. 6 0
      README.md
  2. 1 1
      config.js
  3. 3 2
      package.json
  4. 17 5
      public/index.html
  5. 6 0
      vue.config.js

+ 6 - 0
README.md

@@ -10,6 +10,12 @@ pnpm install
 
 尽量使用 `.tsx` 后缀,因为 `.vue` 为自定义后缀,webpack 暂不能友好支持 `.vue` 后缀,需要明确使用 `demo.vue`,导致无法区分场景
 
+### 关于分支
+
+`release` 稳定版本,线上代码稳定一段时间后同步 `release-buffer`
+
+`release-buffer` 缓冲区,发布一些工具类,创建分支的话拉取此分支
+
 ### 🚀 关于代码格式化
 
 在 ide 扩展中下载 `prettier`

+ 1 - 1
config.js

@@ -26,7 +26,7 @@ module.exports = {
   /**
    * 静态资源部署位置
    */
-  publicPath: process.env.MUSEUM ? `/${process.env.MUSEUM}/` : `/`,
+  publicPath: process.env.SCENE ? `/${process.env.SCENE}/` : `/`,
   /**
    * 静态资源放置的子目录
    */

+ 3 - 2
package.json

@@ -3,8 +3,9 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "serve:hn": "cross-env SCENE=hn vue-cli-service serve",
-    "build:hn": "cross-env SCENE=hn vue-cli-service build",
+    "serve": "vue-cli-service serve",
+    "serve:hn": "cross-env TITLE=河南博物馆 SCENE=hn vue-cli-service serve",
+    "build:hn": "cross-env TITLE=河南博物馆 SCENE=hn vue-cli-service build",
     "lint": "vue-cli-service lint",
     "prepare": "husky install"
   },

+ 17 - 5
public/index.html

@@ -1,15 +1,27 @@
 <!DOCTYPE html>
 <html lang="">
   <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width,initial-scale=1.0">
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <meta charset="utf-8" />
+    <meta
+      name="viewport"
+      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui"
+    />
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+    <link
+      rel="icon"
+      href="<%= BASE_URL %>favicon<%= !!process.env.SCENE ? '.' + process.env.SCENE : '' %>.ico"
+    />
     <title><%= htmlWebpackPlugin.options.title %></title>
+    <meta name="description" content="四维时代" />
+    <meta property="og:title" content="四维时代" />
+    <meta property="og:description" content="四维时代" />
   </head>
   <body>
     <noscript>
-      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+      <strong
+        >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without
+        JavaScript enabled. Please enable it to continue.</strong
+      >
     </noscript>
     <div id="app"></div>
     <!-- built files will be auto injected -->

+ 6 - 0
vue.config.js

@@ -18,6 +18,7 @@ const ENV = getEnv();
 module.exports = defineConfig({
   transpileDependencies: true,
   lintOnSave: false,
+  indexPath: `${SCENE}.html`,
   publicPath: IS_PRODUCTION ? config.publicPath : '/',
   outputDir: IS_PRODUCTION && !!SCENE ? `build/${SCENE}` : 'build',
   // 根据场景隔离
@@ -68,6 +69,11 @@ module.exports = defineConfig({
     if (IS_PRODUCTION) {
       webpackConfig.plugin('loadshReplace').use(new LodashModuleReplacementPlugin());
     }
+
+    webpackConfig.plugin('html').tap((args) => {
+      args[0].title = process.env.TITLE;
+      return args;
+    });
   },
 });