dusenyao преди 3 години
родител
ревизия
c0363fc060
променени са 11 файла, в които са добавени 78 реда и са изтрити 21 реда
  1. 0 6
      src/main.js
  2. 9 5
      src/permission.js
  3. 12 0
      src/settings.js
  4. 10 5
      src/store/modules/app.js
  5. 1 2
      src/store/mutation-types.js
  6. 18 0
      src/utils/auth.js
  7. 16 0
      src/utils/index.js
  8. 2 0
      src/views/live/student/index.vue
  9. 1 0
      src/views/live/student/live.js
  10. 5 0
      src/views/login/index.vue
  11. 4 3
      vue.config.js

+ 0 - 6
src/main.js

@@ -2,8 +2,6 @@ import Vue from 'vue';
 import App from './App.vue';
 import router from './router';
 import store from './store';
-import { GetLogo } from '@/api/app';
-import { app } from '@/store/mutation-types';
 
 import ElementUI from 'element-ui';
 import 'element-ui/lib/theme-chalk/index.css';
@@ -19,10 +17,6 @@ import 'normalize.css/normalize.css';
 import i18n from '@/utils/i18n';
 import '@/permission'; // 权限控制
 
-GetLogo().then(({ title }) => {
-  store.commit(`app/${app.SET_TITLE}`, title);
-});
-
 Vue.use(ElementUI);
 Vue.use(GCLSBookQuestionUI);
 Vue.use(VueDND);

+ 9 - 5
src/permission.js

@@ -1,9 +1,8 @@
 import router from './router';
-import { getSessionID } from '@/utils/auth';
+import { getSessionID, getConfig } from '@/utils/auth';
 
 import NProgress from 'nprogress';
 import 'nprogress/nprogress.css';
-
 NProgress.configure({ showSpinner: false });
 
 const whiteList = ['/login', '/EnterSys']; // 重定向白名单
@@ -12,8 +11,9 @@ const whiteList = ['/login', '/EnterSys']; // 重定向白名单
 router.beforeEach(async (to, from, next) => {
   NProgress.start();
 
-  const session_id = getSessionID();
-  if (session_id) {
+  const { isHas } = getConfig();
+
+  if (getSessionID() && isHas) {
     if (to.path === '/login') {
       next({ path: '/' });
       NProgress.done();
@@ -25,7 +25,11 @@ router.beforeEach(async (to, from, next) => {
     next();
   } else {
     // 其他无权访问的页面将重定向到登录页面
-    next('/login');
+    if (process.env.NODE_ENV === 'production') {
+      window.location.href = '/';
+    } else {
+      next('/login');
+    }
     NProgress.done();
   }
 });

+ 12 - 0
src/settings.js

@@ -0,0 +1,12 @@
+const Cookies = require('js-cookie');
+
+let title = '';
+let config = Cookies.get('GCLS_Config');
+if (config) {
+  let configObj = JSON.parse(config);
+  title = configObj.title;
+}
+
+module.exports = {
+  title: title
+};

+ 10 - 5
src/store/modules/app.js

@@ -1,4 +1,5 @@
 import { app } from '@/store/mutation-types';
+import { getConfig } from '@/utils/auth';
 
 let liveStorage = 'liveDevice';
 
@@ -10,11 +11,19 @@ const getDefaultSate = () => {
   };
   device = device ? JSON.parse(device) : defaultDevice;
 
+  const { token, isHas } = getConfig();
+
+  if (isHas) document.title = token.title;
+
   return {
     liveDevice: device,
     showProgress: false,
     percentage: 0,
-    title: ''
+    config: {
+      title: isHas ? token.title : '',
+      logo_image_url_home: isHas ? token.logo_image_url_home : '',
+      sys_type: isHas ? token.sys_type : ''
+    }
   };
 };
 
@@ -30,10 +39,6 @@ const mutations = {
   },
   [app.SET_PERCENTAGE]: (state, percentage) => {
     state.percentage = percentage;
-  },
-  [app.SET_TITLE]: (state, title) => {
-    state.title = title;
-    document.title = title;
   }
 };
 

+ 1 - 2
src/store/mutation-types.js

@@ -7,8 +7,7 @@ const user = {
 const app = {
   SET_DEVICE: 'SET_DEVICE',
   SHOW_PROGRESS: 'SHOW_PROGRESS',
-  SET_PERCENTAGE: 'SET_PERCENTAGE',
-  SET_TITLE: 'SET_TITLE'
+  SET_PERCENTAGE: 'SET_PERCENTAGE'
 };
 
 export { user, app };

+ 18 - 0
src/utils/auth.js

@@ -1,6 +1,7 @@
 import Cookies from 'js-cookie';
 
 const TokenKey = 'GCLS_Token';
+const ConfigKey = 'GCLS_Config';
 
 export function getSessionID() {
   let token = Cookies.get(TokenKey);
@@ -25,3 +26,20 @@ export function setToken(token) {
 export function removeToken() {
   return Cookies.remove(TokenKey);
 }
+
+// 系统信息
+export function getConfig() {
+  const token = Cookies.get(ConfigKey);
+  if (token) {
+    return { token: JSON.parse(token), isHas: true };
+  }
+  return { token: {}, isHas: false };
+}
+
+export function setConfig(val) {
+  return Cookies.set(ConfigKey, val);
+}
+
+export function removeConfig() {
+  return Cookies.remove(ConfigKey);
+}

+ 16 - 0
src/utils/index.js

@@ -1,3 +1,6 @@
+import { GetLogo } from '@/api/app';
+import { setConfig } from './auth';
+
 /**
  * 格式化 Date
  * @param {Date} date
@@ -39,3 +42,16 @@ export function parseTime(time, cFormat) {
   });
   return time_str;
 }
+
+export function getConfigInformation() {
+  return new Promise((resolve, reject) => {
+    GetLogo()
+      .then(res => {
+        setConfig(res);
+        resolve(res);
+      })
+      .catch(err => {
+        reject(err);
+      });
+  });
+}

+ 2 - 0
src/views/live/student/index.vue

@@ -382,6 +382,7 @@ export default {
           }
 
           this.callLoading = false;
+          this.invite = false;
           this.dealStudentConnection(this.room_user_id, 0, this.roomInfo.video_mode);
           console.log('下麦成功', str);
           common.updateMcResult('', 0);
@@ -390,6 +391,7 @@ export default {
         fail: data => {
           this.connect = false;
           this.callLoading = false;
+          this.invite = false;
           console.log('下麦失败', data);
         }
       });

+ 1 - 0
src/views/live/student/live.js

@@ -333,6 +333,7 @@ export function initListener(vue) {
     // 连接中途下麦
     if (data.type === 'handsDown-load' && data.uid === vue.room_user_id) {
       vue.callLoading = false;
+      vue.invite = false;
     }
 
     // 连麦信息

+ 5 - 0
src/views/login/index.vue

@@ -63,6 +63,7 @@
 
 <script>
 import { updateWordPack } from '@/utils/i18n';
+import { getConfigInformation } from '@/utils/index';
 
 export default {
   data() {
@@ -103,6 +104,7 @@ export default {
     }
   },
   created() {
+    this.getConfig();
     updateWordPack({
       word_key_list: [
         'login',
@@ -116,6 +118,9 @@ export default {
     });
   },
   methods: {
+    async getConfig() {
+      await getConfigInformation();
+    },
     handleLogin(user_type) {
       this.$refs.loginForm.validate(valid => {
         if (valid) {

+ 4 - 3
vue.config.js

@@ -1,11 +1,12 @@
-import path from 'path';
-import StyleLintPlugin from 'stylelint-webpack-plugin';
+const path = require('path');
+const StyleLintPlugin = require('stylelint-webpack-plugin');
+const defaultSettings = require('./src/settings.js');
 
 function resolve(dir) {
   return path.join(__dirname, './', dir);
 }
 
-const name = '全球汉语教学平台';
+const name = defaultSettings.title;
 
 const NODE_ENV = process.env.NODE_ENV;