瀏覽代碼

环境变量文件 .evn.production 中添加一个 VUE_APP_DEVOPS 变量, 标识是否为 devops 系统

reghao 3 月之前
父節點
當前提交
aa5908ae00
共有 6 個文件被更改,包括 11 次插入8 次删除
  1. 1 0
      .env.development
  2. 2 1
      .env.production
  3. 2 2
      src/assets/js/mixin.js
  4. 2 3
      src/components/layout/LoginBar.vue
  5. 2 0
      src/views/Login.vue
  6. 2 2
      src/views/admin/Dashboard.vue

+ 1 - 0
.env.development

@@ -1 +1,2 @@
 VUE_APP_SERVER_URL=//reghao.cn
+VUE_APP_DEVOPS=0

+ 2 - 1
.env.production

@@ -1 +1,2 @@
-VUE_APP_SERVER_URL=//reghao.cn
+VUE_APP_SERVER_URL=//reghao.cn
+VUE_APP_DEVOPS=0

+ 2 - 2
src/assets/js/mixin.js

@@ -10,7 +10,6 @@ import store from '@/store'
 export const userMixin = {
   data() {
     return {
-      devops: false,
       pubkey: '',
       pubkeyR: '',
       captchaCode: '',
@@ -169,7 +168,8 @@ export const userMixin = {
         return
       }
 
-      if (!this.devops) {
+      const devops = process.env.VUE_APP_DEVOPS
+      if (!devops) {
         if (this.userLogin.captchaCode === '' || this.userLogin.captchaCode === null) {
           this.$message.warning('图形验证码不能为空')
           return

+ 2 - 3
src/components/layout/LoginBar.vue

@@ -42,16 +42,15 @@
 </template>
 
 <script>
-import { userMixin } from 'assets/js/mixin'
-
 export default {
   name: 'LoginBar',
-  mixins: [userMixin],
   data() {
     return {
+      devops: false
     }
   },
   created() {
+    this.devops = parseInt(process.env.VUE_APP_DEVOPS) === 1
   },
   methods: {
   }

+ 2 - 0
src/views/Login.vue

@@ -150,6 +150,7 @@ export default {
   mixins: [userMixin],
   data() {
     return {
+      devops: false,
       activeName: 'login1'
     }
   },
@@ -159,6 +160,7 @@ export default {
     }
   },
   created() {
+    this.devops = parseInt(process.env.VUE_APP_DEVOPS) === 1
     document.title = '用户登入'
     this.fetchPubkey(1)
   },

+ 2 - 2
src/views/admin/Dashboard.vue

@@ -107,19 +107,19 @@
 </template>
 
 <script>
-import { userMixin } from 'assets/js/mixin'
 import { getDashboard } from '@/api/devops'
 
 export default {
   name: 'Dashboard',
-  mixins: [userMixin],
   data() {
     return {
+      devops: false,
       machineStatList: [],
       sysInfo: null
     }
   },
   created() {
+    this.devops = parseInt(process.env.VUE_APP_DEVOPS) === 1
     document.title = 'Dashboard'
     this.getData()
   },