Kaynağa Gözat

新增 beiyu 环境配置文件

dusenyao 1 yıl önce
ebeveyn
işleme
1036904492

+ 6 - 0
.env.beiyu

@@ -0,0 +1,6 @@
+NODE_ENV = 'beiyu'
+
+# base api
+VUE_APP_BASE_API = 'https://chinesedu.blcup.com/'
+
+VUE_APP_FILE = 'https://chinesedu-file.blcup.com/'

+ 3 - 3
.eslintrc.js

@@ -33,8 +33,8 @@ module.exports = {
   ],
 
   rules: {
-    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
-    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
+    'no-console': process.env.NODE_ENV === 'development' ? 'off' : 'warn',
+    'no-debugger': process.env.NODE_ENV === 'development' ? 'off' : 'warn',
     'vue/multi-word-component-names': 0,
     'vue/max-attributes-per-line': [
       2,
@@ -212,7 +212,7 @@ module.exports = {
     'wrap-iife': [2, 'any'],
     'yield-star-spacing': [2, 'both'],
     'object-curly-spacing': [2, 'always'],
-    'no-alert': process.env.NODE_ENV === 'production' ? 1 : 0,
+    'no-alert': process.env.NODE_ENV === 'development' ? 0 : 1,
     'no-array-constructor': 2,
     'no-bitwise': 1,
     'no-div-regex': 1,

+ 1 - 0
package.json

@@ -9,6 +9,7 @@
     "electron": "nodemon --watch main.js --exec \"electron .\"",
     "dev": "vue-cli-service serve",
     "build": "vue-cli-service build",
+    "build:beiyu": "vue-cli-service build --mode beiyu",
     "lint": "vue-cli-service lint",
     "postinstall": "patch-package",
     "builder": "electron-builder",

+ 1 - 1
src/router/guard/index.js

@@ -23,7 +23,7 @@ export function setupRouterGuard(router) {
       next();
     } else {
       // 其他无权访问的页面将重定向到登录页面
-      if (process.env.NODE_ENV === 'production') {
+      if (process.env.NODE_ENV === 'development') {
         next('/login');
       } else {
         next('/login');

+ 1 - 3
src/store/modules/app.js

@@ -1,5 +1,5 @@
 import { app } from '@/store/mutation-types';
-import { getConfig, getBaseUrl, getFileUrl } from '@/utils/auth';
+import { getConfig } from '@/utils/auth';
 import { conversionSize } from '@/utils/common';
 
 const getDefaultSate = () => {
@@ -7,8 +7,6 @@ const getDefaultSate = () => {
   return {
     showProgress: false,
     uploadController: null,
-    APP_BASE_API: getBaseUrl(),
-    APP_FILE_API: getFileUrl(),
     uploadInfo: {
       loaded: 0,
       progress: 0,

+ 0 - 22
src/utils/auth.js

@@ -35,25 +35,3 @@ export function setConfig(value) {
 export function removeConfig() {
   localStorage.removeItem(ConfigKey);
 }
-
-// 基础请求路径
-const BaseUrl = 'APP_BASE_API';
-export function getBaseUrl() {
-  const defaultUrl = process.env.NODE_ENV === 'development' ? '/api' : 'https://gcls.helxsoft.cn/';
-  return localStorage.getItem(BaseUrl) ?? defaultUrl;
-}
-
-export function setBaseUrl(value) {
-  console.log(value);
-  localStorage.setItem(BaseUrl, value);
-}
-
-const FileUrl = 'APP_FILE_API';
-export function getFileUrl() {
-  const defaultUrl = process.env.NODE_ENV === 'development' ? '/file' : 'https://file-kf.helxsoft.cn/';
-  return localStorage.getItem(FileUrl) ?? defaultUrl;
-}
-
-export function setFileUrl(value) {
-  localStorage.setItem(FileUrl, value);
-}

+ 2 - 7
src/utils/http.js

@@ -2,19 +2,14 @@ import axios from 'axios';
 import store from '@/store';
 import router from '@/router';
 
-import { getToken, getBaseUrl } from '@/utils/auth';
+import { getToken } from '@/utils/auth';
 import { Message } from 'element-ui';
 
 const service = axios.create({
-  baseURL: getBaseUrl(),
+  baseURL: process.env.VUE_APP_BASE_API,
   timeout: 30000,
 });
 
-// 重置请求地址
-export function resetBaseUrl() {
-  service.defaults.baseURL = getBaseUrl();
-}
-
 // 请求拦截器
 service.interceptors.request.use(
   (config) => {

+ 1 - 13
src/views/login/index.vue

@@ -17,9 +17,6 @@
             @click="updateVerificationCode"
           />
         </el-form-item>
-        <el-form-item v-if="!isDev" label="服务器地址">
-          <el-input v-model="base_url" placeholder="请输入服务器地址" @change="changeBaseUrl" />
-        </el-form-item>
         <el-form-item>
           <el-button class="submit" type="primary" @click="signIn">登录</el-button>
         </el-form-item>
@@ -32,7 +29,6 @@
           </div>
         </el-form-item>
       </el-form>
-      <div class="not-tips">没有账号</div>
     </main>
   </div>
 </template>
@@ -40,15 +36,12 @@
 <script>
 import md5 from 'md5';
 import { GetVerificationCodeImage, GetLogo } from '@/api/app';
-import { setConfig, getBaseUrl, setBaseUrl } from '@/utils/auth';
-import { resetBaseUrl } from '@/utils/http';
+import { setConfig } from '@/utils/auth';
 
 export default {
   name: 'LoginPage',
   data() {
     return {
-      base_url: getBaseUrl(),
-      isDev: process.env.NODE_ENV === 'development',
       isAgree: true, // 是否同意用户协议
       form: {
         user_type: 'TEACHER',
@@ -90,11 +83,6 @@ export default {
       });
     },
 
-    changeBaseUrl() {
-      setBaseUrl(this.base_url);
-      resetBaseUrl();
-    },
-
     getLogo() {
       GetLogo().then((res) => {
         setConfig(res);

+ 30 - 19
vue.config.js

@@ -12,6 +12,35 @@ const NODE_ENV = process.env.NODE_ENV;
 
 const port = process.env.port || 9564;
 
+const baseApiUrlList = {
+  '': '',
+  '/api': 'https://gcls.helxsoft.cn/',
+};
+
+const fileApiUrlList = {
+  '': '',
+  '/file': 'https://file-kf.helxsoft.cn/',
+};
+
+const proxy = {};
+
+if (NODE_ENV === 'development') {
+  proxy[process.env.VUE_APP_BASE_API] = {
+    target: baseApiUrlList[process.env.VUE_APP_BASE_API],
+    changeOrigin: true,
+    pathRewrite: {
+      [`^${process.env.VUE_APP_BASE_API}`]: '',
+    },
+  };
+  proxy[process.env.VUE_APP_FILE] = {
+    target: fileApiUrlList[process.env.VUE_APP_FILE],
+    changeOrigin: true,
+    pathRewrite: {
+      [`^${process.env.VUE_APP_FILE}`]: '',
+    },
+  };
+}
+
 module.exports = defineConfig({
   publicPath: NODE_ENV === 'development' ? '/' : './',
   outputDir: 'dist',
@@ -30,25 +59,7 @@ module.exports = defineConfig({
         errors: true,
       },
     },
-    proxy: {
-      [process.env.VUE_APP_BASE_API]: {
-        // target: 'https://gcls.utschool.cn/',
-        target: 'https://gcls.helxsoft.cn/',
-        // target: 'https://youthchinesedu.blcup.com/',
-        changeOrigin: true,
-        pathRewrite: {
-          [`^${process.env.VUE_APP_BASE_API}`]: '',
-        },
-      },
-      [process.env.VUE_APP_FILE]: {
-        // target: 'https://file-cs.helxsoft.cn',
-        target: 'https://file-kf.helxsoft.cn/',
-        changeOrigin: true,
-        pathRewrite: {
-          [`^${process.env.VUE_APP_FILE}`]: '',
-        },
-      },
-    },
+    proxy,
   },
   css: {
     loaderOptions: {