guanchunjie 3 年之前
父节点
当前提交
a56f837940
共有 6 个文件被更改,包括 225 次插入513 次删除
  1. 2 0
      package.json
  2. 6 0
      src/components/inputModules/common/Header.vue
  3. 33 39
      src/permission.js
  4. 175 181
      src/router/index.js
  5. 0 293
      src/views/catelog.vue
  6. 9 0
      vue.config.js

+ 2 - 0
package.json

@@ -17,6 +17,7 @@
     "@tinymce/tinymce-vue": "^3.2.8",
     "@tinymce/tinymce-vue": "^3.2.8",
     "awe-dnd": "^0.3.4",
     "awe-dnd": "^0.3.4",
     "axios": "0.18.1",
     "axios": "0.18.1",
+    "book-ui": "file:../GCLS-Book-question-ui/book-ui-0.1.12.tgz",
     "cnchar": "^3.0.1",
     "cnchar": "^3.0.1",
     "cnchar-all": "^3.0.1",
     "cnchar-all": "^3.0.1",
     "cnchar-order": "^3.0.1",
     "cnchar-order": "^3.0.1",
@@ -62,6 +63,7 @@
     "eslint-plugin-vue": "6.2.2",
     "eslint-plugin-vue": "6.2.2",
     "hanzi-writer": "^3.1.0",
     "hanzi-writer": "^3.1.0",
     "html-webpack-plugin": "3.2.0",
     "html-webpack-plugin": "3.2.0",
+    "image-webpack-loader": "^8.0.1",
     "mockjs": "^1.0.1-beta3",
     "mockjs": "^1.0.1-beta3",
     "postcss": "^8.2.10",
     "postcss": "^8.2.10",
     "postcss-loader": "^5.2.0",
     "postcss-loader": "^5.2.0",

+ 6 - 0
src/components/inputModules/common/Header.vue

@@ -116,6 +116,7 @@
 import { mapGetters } from "vuex";
 import { mapGetters } from "vuex";
 import { getToken, removeToken, getConfig } from "@/utils/auth";
 import { getToken, removeToken, getConfig } from "@/utils/auth";
 import Cookies from "js-cookie";
 import Cookies from "js-cookie";
+import { getConfigInfor } from "@/utils/index";
 import {
 import {
   getLearnWebContent,
   getLearnWebContent,
   getStaticContent,
   getStaticContent,
@@ -276,12 +277,17 @@ export default {
         this.is_exist = res.is_exist;
         this.is_exist = res.is_exist;
       });
       });
     },
     },
+    async _getConfig() {
+      this.configInfor = await getConfigInfor();
+    },
   },
   },
   created() {
   created() {
     let _this = this;
     let _this = this;
     let config = getConfig();
     let config = getConfig();
     if (config) {
     if (config) {
       _this.configInfor = JSON.parse(config);
       _this.configInfor = JSON.parse(config);
+    } else {
+      _this._getConfig();
     }
     }
     _this.getChildSysList();
     _this.getChildSysList();
   },
   },

+ 33 - 39
src/permission.js

@@ -10,48 +10,42 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
 
 const whiteList = ['/login', '/BookBrowsing'] // no redirect whitelist
 const whiteList = ['/login', '/BookBrowsing'] // no redirect whitelist
 
 
-router.beforeEach(async(to, from, next) => {
-    // start progress bar
-    NProgress.start()
-        // set page title
-    document.title = getPageTitle(to.meta.title)
-        //next();
-    NProgress.done()
-    const hasToken = getToken()
-    if (hasToken) {
-        let config = getConfig();
-        if (config) {
-            if (to.path === '/login') {
-                // if is logged in, redirect to the home page
-                next({ path: '/EnterSys' })
-                NProgress.done()
-            } else {
-                try {
-                    next()
-                } catch (error) {
-                    Message.error(error || 'Has Error')
-                    next(`/login?redirect=${to.path}`)
-                    NProgress.done()
-                }
-            }
-        } else {
-            next(`/login?redirect=${to.path}`)
-            NProgress.done()
-        }
+router.beforeEach(async (to, from, next) => {
+  // start progress bar
+  NProgress.start()
+  // set page title
+  document.title = getPageTitle(to.meta.title)
+  //next();
+  NProgress.done()
+  const hasToken = getToken()
+  if (hasToken) {
+    if (to.path === '/login') {
+      // if is logged in, redirect to the home page
+      next({ path: '/EnterSys' })
+      NProgress.done()
     } else {
     } else {
-        /* has no token*/
-        if (whiteList.indexOf(to.path) !== -1) {
-            // in the free login whitelist, go directly
-            next()
-        } else {
-            // other pages that do not have permission to access are redirected to the login page.
-            next(`/login?redirect=${to.path}`)
-            NProgress.done()
-        }
+      try {
+        next()
+      } catch (error) {
+        Message.error(error || 'Has Error')
+        next(`/login?redirect=${to.path}`)
+        NProgress.done()
+      }
     }
     }
+  } else {
+    /* has no token*/
+    if (whiteList.indexOf(to.path) !== -1) {
+      // in the free login whitelist, go directly
+      next()
+    } else {
+      // other pages that do not have permission to access are redirected to the login page.
+      next(`/login?redirect=${to.path}`)
+      NProgress.done()
+    }
+  }
 })
 })
 
 
 router.afterEach(() => {
 router.afterEach(() => {
-    // finish progress bar
-    NProgress.done()
+  // finish progress bar
+  NProgress.done()
 })
 })

+ 175 - 181
src/router/index.js

@@ -30,201 +30,195 @@ Vue.use(Router)
  * all roles can be accessed
  * all roles can be accessed
  */
  */
 export const constantRoutes = [{
 export const constantRoutes = [{
-        path: '/404',
-        component: () =>
-            import ('@/views/404'),
-        hidden: true
-    },
-    {
-        path: '/login',
-        component: () =>
-            import ('@/views/login'),
-        hidden: true
-    },
-    {
-        path: '/EnterSys',
-        beforeEnter: (to, from, next) => {
-            let loadingInstance = Loading.service({
-                text: '跳转中...'
-            });
-            let config = getConfig();
-            if (config) {
-                let configObj = JSON.parse(config);
-                let path = handleSysType(configObj.sys_type, 'home');
-                if (path) {
-                    loadingInstance.close();
-                    if (configObj.sys_type == 'GCLS') {
-                        next(path);
-                    } else {
-                        window.location.href = path
-                    }
-                } else {
-                    loadingInstance.close();
-                    Message({
-                        message: '此路径不存在',
-                        type: 'error',
-                        showClose: true,
-                        duration: 0
-                    })
-                }
-            }
+  path: '/404',
+  component: () =>
+    import('@/views/404'),
+  hidden: true
+},
+{
+  path: '/login',
+  component: () =>
+    import('@/views/login'),
+  hidden: true
+},
+{
+  path: '/EnterSys',
+  beforeEnter: (to, from, next) => {
+    let loadingInstance = Loading.service({
+      text: '跳转中...'
+    });
+    let config = getConfig();
+    if (config) {
+      let configObj = JSON.parse(config);
+      let path = handleSysType(configObj.sys_type, 'home');
+      if (path) {
+        loadingInstance.close();
+        if (configObj.sys_type == 'GCLS') {
+          next(path);
+        } else {
+          window.location.href = path
         }
         }
-    },
-    // {
-    //   path: '/',
-    //   redirect: '/EnterSys',
-    //   hidden: true
-    // },
-    {
-        path: '/input',
-        component: () =>
-            import ('@/views/input'),
-        hidden: true
-    },
-    {
-        path: '/cate',
-        component: () =>
-            import ('@/views/catelog'),
-        hidden: true
-    },
-    {
-        path: '/input2',
-        component: () =>
-            import ('@/views/input2'),
-        hidden: true
-    },
-    {
-        path: '/input3',
-        component: () =>
-            import ('@/views/input3'),
-        hidden: true
-    },
-    {
-        path: '/',
-        component: () =>
-            import ('@/views/courseList'),
+      } else {
+        loadingInstance.close();
+        Message({
+          message: '此路径不存在',
+          type: 'error',
+          showClose: true,
+          duration: 0
+        })
+      }
+    }
+  }
+},
+// {
+//   path: '/',
+//   redirect: '/EnterSys',
+//   hidden: true
+// },
+{
+  path: '/input',
+  component: () =>
+    import('@/views/input'),
+  hidden: true
+},
+{
+  path: '/input2',
+  component: () =>
+    import('@/views/input2'),
+  hidden: true
+},
+{
+  path: '/input3',
+  component: () =>
+    import('@/views/input3'),
+  hidden: true
+},
+{
+  path: '/',
+  component: () =>
+    import('@/views/courseList'),
 
 
-    },
-    {
-        path: '/preview',
-        component: () =>
-            import ('@/views/preview')
-    },
-    {
-        path: '/login',
-        component: () =>
-            import ('@/views/login')
-    },
-    {
-        path: '/courseView',
-        component: () =>
-            import ('@/views/courseView')
-    },
-    {
-        path: '/bookView',
-        component: () =>
-            import ('@/views/bookView')
-    },
-    {
-        path: '/GoodsDetail',
-        beforeEnter: (to, from, next) => {
-            let loadingInstance = Loading.service({
-                text: '跳转中...'
-            });
-            let config = getConfig();
-            if (config) {
-                let configObj = JSON.parse(config);
-                let path = handleSysType(configObj.sys_type, 'goods');
-                if (path) {
-                    loadingInstance.close();
-                    if (configObj.sys_type == 'GCLS') {
-                        next(path);
-                    } else {
-                        window.location.href = path
-                    }
-                } else {
-                    loadingInstance.close();
-                    Message({
-                        message: '此路径不存在',
-                        type: 'error',
-                        showClose: true,
-                        duration: 0
-                    })
-                }
-            }
+},
+{
+  path: '/preview',
+  component: () =>
+    import('@/views/preview')
+},
+{
+  path: '/login',
+  component: () =>
+    import('@/views/login')
+},
+{
+  path: '/courseView',
+  component: () =>
+    import('@/views/courseView')
+},
+{
+  path: '/bookView',
+  component: () =>
+    import('@/views/bookView')
+},
+{
+  path: '/GoodsDetail',
+  beforeEnter: (to, from, next) => {
+    let loadingInstance = Loading.service({
+      text: '跳转中...'
+    });
+    let config = getConfig();
+    if (config) {
+      let configObj = JSON.parse(config);
+      let path = handleSysType(configObj.sys_type, 'goods');
+      if (path) {
+        loadingInstance.close();
+        if (configObj.sys_type == 'GCLS') {
+          next(path);
+        } else {
+          window.location.href = path
         }
         }
-    },
-    {
-        path: '/curGoodsDetail',
-        component: () =>
-            import ('@/views/TextbookDetail')
-    },
-    {
-        path: '/discountCodeList',
-        component: () =>
-            import ('@/views/discountCodeList')
-    },
-    {
-        path: '/adultInput',
-        component: () =>
-            import ('@/views/adultInput')
-    },
-    {
-        path: '/adultInput2',
-        component: () =>
-            import ('@/views/adultInput2')
-    },
-    {
-        path: "/BookBrowsing",
-        name: "BookBrowsing",
-        component: () =>
-            import ('@/views/BookView2')
-    },
-    // 404 page must be placed at the end !!!
-    { path: '*', redirect: '/', hidden: true }
+      } else {
+        loadingInstance.close();
+        Message({
+          message: '此路径不存在',
+          type: 'error',
+          showClose: true,
+          duration: 0
+        })
+      }
+    }
+  }
+},
+{
+  path: '/curGoodsDetail',
+  component: () =>
+    import('@/views/TextbookDetail')
+},
+{
+  path: '/discountCodeList',
+  component: () =>
+    import('@/views/discountCodeList')
+},
+{
+  path: '/adultInput',
+  component: () =>
+    import('@/views/adultInput')
+},
+{
+  path: '/adultInput2',
+  component: () =>
+    import('@/views/adultInput2')
+},
+{
+  path: "/BookBrowsing",
+  name: "BookBrowsing",
+  component: () =>
+    import('@/views/BookView2')
+},
+// 404 page must be placed at the end !!!
+{ path: '*', redirect: '/', hidden: true }
 ]
 ]
 
 
 const createRouter = () =>
 const createRouter = () =>
-    new Router({
-        // mode: 'history', // require service support
-        scrollBehavior: () => ({ y: 0 }),
-        routes: constantRoutes
-    })
+  new Router({
+    // mode: 'history', // require service support
+    scrollBehavior: () => ({ y: 0 }),
+    routes: constantRoutes
+  })
 
 
 const router = createRouter()
 const router = createRouter()
 
 
 // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
 // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
 export function resetRouter() {
 export function resetRouter() {
-    const newRouter = createRouter()
-    router.matcher = newRouter.matcher // reset router
+  const newRouter = createRouter()
+  router.matcher = newRouter.matcher // reset router
 }
 }
 export function handleSysType(sys_type, path_type) {
 export function handleSysType(sys_type, path_type) {
-    let path = '';
-    let csArr = window.location.href.split('?');
-    let cs = csArr[1];
-    switch (sys_type) {
-        case 'GCLS':
-            console.log('全球汉语教学平台')
-            if (path_type == 'home') {
-                path = '/';
-            } else if (path_type == 'goods') {
+  let path = '';
+  let csArr = window.location.href.split('?');
+  let cs = csArr[1];
+  switch (sys_type) {
+    case 'GCLS':
+      console.log('全球汉语教学平台')
+      if (path_type == 'home') {
+        path = '/';
+      } else if (path_type == 'goods') {
 
 
-                path = '/curGoodsDetail?' + cs
-            }
-            break;
-        case 'AILP':
-            console.log('课后三点半')
-            if (path_type == 'home') {
-                path = '/GCLS-Book-AILP/#/EnterSys';
-            } else if (path_type == 'goods') {
-                path = '/GCLS-Book-AILP/#/GoodsDetail?' + cs;
-            }
-            break;
-        default:
-            path = '';
-            break;
-    }
-    return path;
+        path = '/curGoodsDetail?' + cs
+      }
+      break;
+    case 'AILP':
+      console.log('课后三点半')
+      if (path_type == 'home') {
+        path = '/GCLS-Book-AILP/#/EnterSys';
+      } else if (path_type == 'goods') {
+        path = '/GCLS-Book-AILP/#/GoodsDetail?' + cs;
+      }
+      break;
+    default:
+      path = '';
+      break;
+  }
+  return path;
 }
 }
 
 
 export default router
 export default router

+ 0 - 293
src/views/catelog.vue

@@ -1,293 +0,0 @@
-<!--  -->
-<template>
-  <div class="">
-    <ul id="treeDemo" class="ztree"></ul>
-  </div>
-</template>
-
-<script>
-import "jquery";
-import "@ztree/ztree_v3/js/jquery.ztree.core.min.js";
-import "@ztree/ztree_v3/js/jquery.ztree.excheck.min.js";
-import "@ztree/ztree_v3/js/jquery.ztree.exedit.min.js";
-//import "@ztree/ztree_v3/css/zTreeStyle/zTreeStyle.css";
-import "@ztree/ztree_v3/css/metroStyle/metroStyle.css";
-export default {
-  components: {},
-  data() {
-    return {
-      setting: {
-        check: {
-          enable: true,
-        },
-        data: {
-          simpleData: {
-            enable: true,
-          },
-        },
-        edit: {
-          enable: true,
-        },
-      },
-      zNodes: [
-        { id: 1, pId: 0, name: "父节点1", open: true },
-        { id: 11, pId: 1, name: "父节点11" },
-        { id: 111, pId: 11, name: "叶子节点111" },
-        { id: 112, pId: 11, name: "叶子节点112" },
-        { id: 113, pId: 11, name: "叶子节点113" },
-        { id: 114, pId: 11, name: "叶子节点114" },
-        { id: 12, pId: 1, name: "父节点12" },
-        { id: 121, pId: 12, name: "叶子节点121" },
-        { id: 122, pId: 12, name: "叶子节点122" },
-        { id: 123, pId: 12, name: "叶子节点123" },
-        { id: 124, pId: 12, name: "叶子节点124" },
-        { id: 13, pId: 1, name: "父节点13", isParent: true },
-        { id: 2, pId: 0, name: "父节点2" },
-        { id: 21, pId: 2, name: "父节点21", open: true },
-        { id: 211, pId: 21, name: "叶子节点211" },
-        { id: 212, pId: 21, name: "叶子节点212" },
-        { id: 213, pId: 21, name: "叶子节点213" },
-        { id: 214, pId: 21, name: "叶子节点214" },
-        { id: 22, pId: 2, name: "父节点22" },
-        { id: 221, pId: 22, name: "叶子节点221" },
-        { id: 222, pId: 22, name: "叶子节点222" },
-        { id: 223, pId: 22, name: "叶子节点223" },
-        { id: 224, pId: 22, name: "叶子节点224" },
-        { id: 23, pId: 2, name: "父节点23" },
-        { id: 231, pId: 23, name: "叶子节点231" },
-        { id: 232, pId: 23, name: "叶子节点232" },
-        { id: 233, pId: 23, name: "叶子节点233" },
-        { id: 234, pId: 23, name: "叶子节点234" },
-        { id: 3, pId: 0, name: "父节点3", isParent: true },
-      ],
-    };
-  },
-  computed: {},
-  watch: {},
-  //方法集合
-  methods: {},
-  //生命周期 - 创建完成(可以访问当前this实例)
-  created() {},
-  //生命周期 - 挂载完成(可以访问DOM元素)
-  mounted() {
-    let _this = this;
-    _this.$nextTick(function () {
-      $.fn.zTree.init($("#treeDemo"), _this.setting, _this.zNodes);
-    });
-  },
-  beforeCreate() {}, //生命周期 - 创建之前
-  beforeMount() {}, //生命周期 - 挂载之前
-  beforeUpdate() {}, //生命周期 - 更新之前
-  updated() {}, //生命周期 - 更新之后
-  beforeDestroy() {}, //生命周期 - 销毁之前
-  destroyed() {}, //生命周期 - 销毁完成
-  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
-};
-</script>
-<style lang='scss' scoped>
-//@import url(); 引入公共css类
-</style>
-<style scoped>
-html,
-body,
-div,
-span,
-applet,
-object,
-iframe,
-h1,
-h2,
-h3,
-h4,
-h5,
-h6,
-p,
-blockquote,
-pre,
-a,
-abbr,
-acronym,
-address,
-big,
-cite,
-code,
-del,
-dfn,
-em,
-font,
-img,
-ins,
-kbd,
-q,
-s,
-samp,
-small,
-strike,
-strong,
-sub,
-sup,
-tt,
-var,
-dl,
-dt,
-dd,
-ol,
-ul,
-li,
-fieldset,
-form,
-label,
-legend,
-table,
-caption,
-tbody,
-tfoot,
-thead,
-tr,
-th,
-td {
-  margin: 0;
-  padding: 0;
-  border: 0;
-  outline: 0;
-  font-weight: inherit;
-  font-style: inherit;
-  font-size: 100%;
-  font-family: inherit;
-  vertical-align: baseline;
-}
-body {
-  color: #2f332a;
-  font: 15px/21px Arial, Helvetica, simsun, sans-serif;
-  background: #f0f6e4 \9;
-}
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
-  color: #2f332a;
-  font-weight: bold;
-  font-family: Helvetica, Arial, sans-serif;
-  padding-bottom: 5px;
-}
-h1 {
-  font-size: 24px;
-  line-height: 34px;
-  text-align: center;
-}
-h2 {
-  font-size: 14px;
-  line-height: 24px;
-  padding-top: 5px;
-}
-h6 {
-  font-weight: normal;
-  font-size: 12px;
-  letter-spacing: 1px;
-  line-height: 24px;
-  text-align: center;
-}
-a {
-  color: #3c6e31;
-  text-decoration: underline;
-}
-a:hover {
-  background-color: #3c6e31;
-  color: white;
-}
-input.radio {
-  margin: 0 2px 0 8px;
-}
-input.radio.first {
-  margin-left: 0;
-}
-input.empty {
-  color: lightgray;
-}
-code {
-  color: #2f332a;
-}
-.highlight_red {
-  color: #a60000;
-}
-.highlight_green {
-  color: #a7f43d;
-}
-li {
-  list-style: circle;
-  font-size: 12px;
-}
-li.title {
-  list-style: none;
-}
-ul.list {
-  margin-left: 17px;
-}
-
-div.content_wrap {
-  width: 600px;
-  height: 380px;
-}
-div.content_wrap div.left {
-  float: left;
-  width: 250px;
-}
-div.content_wrap div.right {
-  float: right;
-  width: 340px;
-}
-div.zTreeDemoBackground {
-  width: 250px;
-  height: 362px;
-  text-align: left;
-}
-
-ul.ztree {
-  margin-top: 10px;
-  border: 1px solid #617775;
-  background: #f0f6e4;
-  width: 220px;
-  height: 360px;
-  overflow-y: scroll;
-  overflow-x: auto;
-}
-ul.log {
-  border: 1px solid #617775;
-  background: #f0f6e4;
-  width: 300px;
-  height: 170px;
-  overflow: hidden;
-}
-ul.log.small {
-  height: 45px;
-}
-ul.log li {
-  color: #666666;
-  list-style: none;
-  padding-left: 10px;
-}
-ul.log li.dark {
-  background-color: #e3e3e3;
-}
-
-/* ruler */
-div.ruler {
-  height: 20px;
-  width: 220px;
-  background-color: #f0f6e4;
-  border: 1px solid #333;
-  margin-bottom: 5px;
-  cursor: pointer;
-}
-div.ruler div.cursor {
-  height: 20px;
-  width: 30px;
-  background-color: #3c6e31;
-  color: white;
-  text-align: right;
-  padding-right: 5px;
-  cursor: pointer;
-}
-</style>

+ 9 - 0
vue.config.js

@@ -129,6 +129,15 @@ module.exports = {
           }
           }
         }
         }
       })
       })
+      config.module
+        .rule('images')
+        .use('image-webpack-loader')
+        .loader('image-webpack-loader')
+        .options({
+          bypassOnDebug: true
+        })
+        .end()
+
       // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
       // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
       config.optimization.runtimeChunk('single')
       config.optimization.runtimeChunk('single')
     })
     })