فهرست منبع

配置环境打包

yangzj 2 سال پیش
والد
کامیت
342ffa6189
6فایلهای تغییر یافته به همراه41 افزوده شده و 6 حذف شده
  1. 2 0
      .env.dev
  2. 2 0
      .env.prod
  3. 5 1
      package.json
  4. 11 1
      src/router/index.js
  5. 17 1
      src/views/Home/HomeIndex.vue
  6. 4 3
      vue.config.js

+ 2 - 0
.env.dev

@@ -1,2 +1,4 @@
+# 开发环境配置
+ENV = 'development'
 # 请求基础api
 VUE_APP_BASE_API = '/api'

+ 2 - 0
.env.prod

@@ -1,2 +1,4 @@
+# 开发环境配置
+ENV = 'production'
 # 请求基础api
 VUE_APP_BASE_API = '/api'

+ 5 - 1
package.json

@@ -5,7 +5,11 @@
   "scripts": {
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
-    "lint": "vue-cli-service lint"
+    "lint": "vue-cli-service lint",
+    "serve:dev": "vue-cli-service serve --mode dev",
+    "serve:prod": "vue-cli-service serve --mode prod",
+    "build:dev": "vue-cli-service build --mode dev",
+    "build:prod": "vue-cli-service build --mode prod"
   },
   "dependencies": {
     "axios": "^0.27.2",

+ 11 - 1
src/router/index.js

@@ -22,7 +22,10 @@ const routes = [
   {
     path: '/login',
     name: 'Login',
-    component: () => import('@/views/Login/LoginIndex.vue')
+    component: () => import('@/views/Login/LoginIndex.vue'),
+    meta: {
+      title: '登录'
+    }
   }
 ]
 
@@ -30,5 +33,12 @@ const router = new VueRouter({
   mode: 'history',
   routes
 })
+router.beforeEach((to, from, next) => {
+  /* 路由发生变化修改页面title */
+  if (to.meta.title) {
+    document.title = to.meta.title
+  }
+  next()
+})
 
 export default router

+ 17 - 1
src/views/Home/HomeIndex.vue

@@ -3,7 +3,7 @@
  * @Author: 空白格
  * @Date: 2022-08-10 11:26:40
  * @LastEditors: 空白格
- * @LastEditTime: 2022-08-10 17:38:49
+ * @LastEditTime: 2022-08-10 18:01:06
  * @FilePath: \veterans_client_web\src\views\Home\HomeIndex.vue
  * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
 -->
@@ -205,6 +205,22 @@ export default {
       getNoticeList().then((res) => {
         this.noticeList = res.data;
       });
+    },
+    /**
+     * tab点击事件
+     * @date 2022-08-10
+     * @param {any} tab
+     * @returns {any}
+     */
+    handleClick(tab) {
+      switch(tab.name) {
+        case 'first':
+          this.getNews();
+          break;
+        case 'second':
+          this.getNotice();
+          break
+      }
     }
   },
 };

+ 4 - 3
vue.config.js

@@ -1,5 +1,6 @@
 const { defineConfig } = require('@vue/cli-service')
-let port = 9010
+const port = 9010
+const name = '贵州退役军人教育培训'
 module.exports = defineConfig({
   transpileDependencies: true,
   lintOnSave: false,
@@ -8,11 +9,11 @@ module.exports = defineConfig({
     port,
     proxy: {
       // 开发模式请求基础api反代理
-      '/api': {
+      [process.env.VUE_APP_BASE_API]: {
         target: `https://wx.hw.hongweisoft.com/veterans`,
         changeOrigin: true,
         pathRewrite: {
-          '^/api': ''
+          ['^' + process.env.VUE_APP_BASE_API]: ''
         }
       }
     }