Ver Fonte

:fire: 移除代码或文件。 删除无用引入 validateNull 采用avue 内置

pigxcloud há 6 anos atrás
pai
commit
febb4409bc

+ 1 - 1
src/config/env.js

@@ -3,7 +3,7 @@
 const env = process.env
 const baseUrl = ''
 // 图表库为avue和pig2套地址
-const iconfontVersion = ['567566_qo5lxgtishg', '667895_t6gqnmup16']
+const iconfontVersion = ['567566_qo5lxgtishg', '667895_hzxmega6h6i']
 const iconfontUrl = '//at.alicdn.com/t/font_$key.css'
 const codeUrl = `${window.location.origin}/code`
 const actUrl = `${window.location.origin}/act/modeler.html?modelId=`

+ 1 - 2
src/page/index/index.vue

@@ -41,7 +41,6 @@ import tags from './tags'
 import top from './top/'
 import sidebar from './sidebar/'
 import admin from '@/util/admin'
-import { validatenull } from '@/util/validate'
 import { getStore } from '@/util/store.js'
 import SockJS from 'sockjs-client'
 import Stomp from 'stompjs'
@@ -100,7 +99,7 @@ export default {
           debug: true
         })
 
-        if (validatenull(token)) {
+        if (this.validatenull(token)) {
           return
         }
 

+ 1 - 2
src/page/index/top/top-lock.vue

@@ -33,7 +33,6 @@
 </template>
 
 <script>
-import { validatenull } from '@/util/validate'
 import { mapGetters } from 'vuex'
 export default {
   name: 'TopLock',
@@ -61,7 +60,7 @@ export default {
       })
     },
     handleLock() {
-      if (validatenull(this.lockPasswd)) {
+      if (this.validatenull(this.lockPasswd)) {
         this.box = true
         return
       }

+ 1 - 2
src/page/index/top/top-setting.vue

@@ -28,7 +28,6 @@
 
 <script>
 import { mapState, mapGetters } from 'vuex'
-import { validatenull } from '@/util/validate'
 import { option, list } from '@/const/setting/'
 export default {
   data() {
@@ -72,7 +71,7 @@ export default {
     },
     init() {
       this.list.forEach(ele => {
-        this.form[ele.key] = validatenull(this[ele.key]) ? 'true' : this[ele.key] + ''
+        this.form[ele.key] = this.validatenull(this[ele.key]) ? 'true' : this[ele.key] + ''
         this.set(ele.key)
       })
     },

+ 100 - 101
src/page/login/index.vue

@@ -48,119 +48,118 @@
   </div>
 </template>
 <script>
-import request from '@/router/axios'
-import userLogin from './userlogin'
-import codeLogin from './codelogin'
-import thirdLogin from './thirdlogin'
-import { mapGetters } from 'vuex'
-import { getStore, setStore } from '@/util/store'
-import { dateFormat } from '@/util/date'
-import { validatenull } from '@/util/validate'
-import topColor from '@/page/index/top/top-color'
+  import request from '@/router/axios'
+  import userLogin from './userlogin'
+  import codeLogin from './codelogin'
+  import thirdLogin from './thirdlogin'
+  import {mapGetters} from 'vuex'
+  import {getStore, setStore} from '@/util/store'
+  import {dateFormat} from '@/util/date'
+  import topColor from '@/page/index/top/top-color'
 
-export default {
-  name: 'Login',
-  components: {
-    userLogin,
-    codeLogin,
-    thirdLogin,
-    topColor
-  },
-  data() {
-    return {
-      tenantList: [],
-      time: '',
-      active: '',
-      activeName: 'user',
-      socialForm: {}
-    }
-  },
-  watch: {
-    $route: {
-      handler() {
-        const params = this.$route.query
-        if (validatenull(params.state) && validatenull(params.code)) return
+  export default {
+    name: 'Login',
+    components: {
+      userLogin,
+      codeLogin,
+      thirdLogin,
+      topColor
+    },
+    data() {
+      return {
+        tenantList: [],
+        time: '',
+        active: '',
+        activeName: 'user',
+        socialForm: {}
+      }
+    },
+    watch: {
+      $route: {
+        handler() {
+          const params = this.$route.query
+          if (this.validatenull(params.state) && this.validatenull(params.code)) return
 
-        this.socialForm.state = params.state
-        this.socialForm.code = params.code
+          this.socialForm.state = params.state
+          this.socialForm.code = params.code
 
-        const loading = this.$loading({
-          lock: true,
-          text: `登录中,请稍后。。。`,
-          spinner: 'el-icon-loading'
-        })
-        this.$store.dispatch('LoginBySocial', this.socialForm).then(
-          () => {
+          const loading = this.$loading({
+            lock: true,
+            text: `登录中,请稍后。。。`,
+            spinner: 'el-icon-loading'
+          })
+          this.$store.dispatch('LoginBySocial', this.socialForm).then(
+            () => {
+              loading.close()
+              this.$router.push({path: this.tagWel.value})
+            }).catch(() => {
             loading.close()
-            this.$router.push({ path: this.tagWel.value })
-          }).catch(() => {
-          loading.close()
-        })
-      },
-      immediate: true
-    }
-  },
-  created() {
-    this.watermark()
-    this.getTenantList()
-    this.active = getStore({ name: 'tenantId' })
-    this.getTime()
-    setInterval(() => {
+          })
+        },
+        immediate: true
+      }
+    },
+    created() {
+      this.watermark()
+      this.getTenantList()
+      this.active = getStore({name: 'tenantId'})
       this.getTime()
-    }, 1000)
-  },
-  mounted() {
-  },
-  computed: {
-    ...mapGetters(['website', 'tagWel'])
-  },
-  props: [],
-  methods: {
-    handleCommand(command) {
-      setStore({ name: 'tenantId', content: command })
+      setInterval(() => {
+        this.getTime()
+      }, 1000)
     },
-    getTime() {
-      this.time = dateFormat(new Date())
+    mounted() {
     },
-    getTenantList() {
-      request({
-        url: '/admin/tenant/list',
-        method: 'get'
-      }).then(response => {
-        this.tenantList = response.data.data
-      })
+    computed: {
+      ...mapGetters(['website', 'tagWel'])
     },
-    watermark() {
-      const text = ''
-      const canvas = document.createElement('canvas')
-      canvas.width = '500'
-      canvas.height = '200'
-      const ctx = canvas.getContext('2d')
-      ctx.clearRect(0, 0, 200, 200) // 绘制之前画布清除
-      ctx.font = '30px 黑体'
-      ctx.rotate(-20 * Math.PI / 180) // 为了实现水印倾斜效果,旋转画布坐标系
-      ctx.fillStyle = 'rgba(100,100,100,0.15)' // 画笔颜色
-      ctx.fillText(text, -20, 200) // 书写的内容及位置
-      ctx.rotate('20*Math.PI/180') // 坐标系还原,如果后续没有其他操作,这一步可以省略
-      // 将canvas的内容转换为base64编码
-      const data = canvas.toDataURL('image/png', 1) // 1表示质量(无损压缩)
+    props: [],
+    methods: {
+      handleCommand(command) {
+        setStore({name: 'tenantId', content: command})
+      },
+      getTime() {
+        this.time = dateFormat(new Date())
+      },
+      getTenantList() {
+        request({
+          url: '/admin/tenant/list',
+          method: 'get'
+        }).then(response => {
+          this.tenantList = response.data.data
+        })
+      },
+      watermark() {
+        const text = ''
+        const canvas = document.createElement('canvas')
+        canvas.width = '500'
+        canvas.height = '200'
+        const ctx = canvas.getContext('2d')
+        ctx.clearRect(0, 0, 200, 200) // 绘制之前画布清除
+        ctx.font = '30px 黑体'
+        ctx.rotate(-20 * Math.PI / 180) // 为了实现水印倾斜效果,旋转画布坐标系
+        ctx.fillStyle = 'rgba(100,100,100,0.15)' // 画笔颜色
+        ctx.fillText(text, -20, 200) // 书写的内容及位置
+        ctx.rotate('20*Math.PI/180') // 坐标系还原,如果后续没有其他操作,这一步可以省略
+        // 将canvas的内容转换为base64编码
+        const data = canvas.toDataURL('image/png', 1) // 1表示质量(无损压缩)
 
-      window.onload = () => {
-        const background = 'url(' + data + ') repeat'
-        var watermark = document.createElement('div')
-        watermark.style.width = '100%'
-        watermark.style.height = '100%'
-        watermark.style.position = 'fixed'
-        watermark.style.left = '0'
-        watermark.style.top = '0'
-        watermark.style.pointerEvents = 'none'
-        watermark.style.background = background
-        watermark.style.zIndex = '9999'
-        document.body.append(watermark)
+        window.onload = () => {
+          const background = 'url(' + data + ') repeat'
+          var watermark = document.createElement('div')
+          watermark.style.width = '100%'
+          watermark.style.height = '100%'
+          watermark.style.position = 'fixed'
+          watermark.style.left = '0'
+          watermark.style.top = '0'
+          watermark.style.pointerEvents = 'none'
+          watermark.style.background = background
+          watermark.style.zIndex = '9999'
+          document.body.append(watermark)
+        }
       }
     }
   }
-}
 </script>
 
 <style lang="scss">

+ 10 - 5
src/router/avue-router.js

@@ -5,7 +5,9 @@ const RouterPlugin = function() {
 RouterPlugin.install = function(router, store) {
   this.$router = router
   this.$store = store
-
+  function isURL(s) {
+    return /^http[s]?:\/\/.*/.test(s)
+  }
   function objToform(obj) {
     const result = []
     Object.keys(obj).forEach(ele => {
@@ -74,14 +76,17 @@ RouterPlugin.install = function(router, store) {
         const oMenu = aMenu[i]
         if (this.routerList.includes(oMenu[propsDefault.path])) return
         const path = (() => {
-          if (first) {
+          if (!oMenu[propsDefault.path]) {
+            return
+          } else if (first) {
             return oMenu[propsDefault.path].replace('/index', '')
           } else {
             return oMenu[propsDefault.path]
           }
         })()
 
-        const component = oMenu.component
+        //特殊处理组件
+        const component = 'views' + oMenu.path
 
         const name = oMenu[propsDefault.label]
 
@@ -113,13 +118,13 @@ RouterPlugin.install = function(router, store) {
           icon: icon,
           meta: meta,
           redirect: (() => {
-            if (!isChild && first) return `${path}/index`
+            if (!isChild && first && !isURL(path)) return `${path}/index`
             else return ''
           })(),
           // 处理是否为一级路由
           children: !isChild ? (() => {
             if (first) {
-              oMenu[propsDefault.path] = `${path}/index`
+              if (!isURL(path)) oMenu[propsDefault.path] = `${path}/index`
               return [{
                 component(resolve) { require([`../${component}.vue`], resolve) },
                 icon: icon,

+ 12 - 11
src/store/modules/user.js

@@ -1,29 +1,30 @@
 import { getStore, setStore } from '@/util/store'
-import { isURL } from '@/util/validate'
+import { isURL, validatenull } from '@/util/validate'
 import { getUserInfo, loginByMobile, loginBySocial, loginByUsername, logout, refreshToken } from '@/api/login'
 import { deepClone, encryption } from '@/util/util'
 import webiste from '@/const/website'
 import { GetMenu } from '@/api/admin/menu'
 
 function addPath(ele, first) {
-  const propsConfig = webiste.menu.props
+  const menu = webiste.menu
+  const propsConfig = menu.props
   const propsDefault = {
-    label: propsConfig.label || 'label',
+    label: propsConfig.label || 'name',
     path: propsConfig.path || 'path',
     icon: propsConfig.icon || 'icon',
     children: propsConfig.children || 'children'
   }
+  const icon = ele[propsDefault.icon]
+  ele[propsDefault.icon] = validatenull(icon) ? menu.iconDefault : icon
   const isChild = ele[propsDefault.children] && ele[propsDefault.children].length !== 0
-  if (!isChild && first) {
+  if (!isChild) ele[propsDefault.children] = []
+  if (!isChild && first && !isURL(ele[propsDefault.path])) {
     ele[propsDefault.path] = ele[propsDefault.path] + '/index'
-    return
+  } else {
+    ele[propsDefault.children].forEach(child => {
+      addPath(child)
+    })
   }
-  ele[propsDefault.children].forEach(child => {
-    if (!isURL(child[propsDefault.path])) {
-      child[propsDefault.path] = `${ele[propsDefault.path]}/${child[propsDefault.path] ? child[propsDefault.path] : 'index'}`
-    }
-    addPath(child)
-  })
 }
 
 const user = {

+ 27 - 26
src/views/admin/menu/index.vue

@@ -77,8 +77,8 @@
               </el-form-item>
               <el-form-item
                 label="节点ID"
-                prop="menuId"
-                v-if="form.menuId">
+                v-if="form.menuId"
+                prop="menuId">
                 <el-input
                   v-model="form.menuId"
                   :disabled="formEdit || formStatus === 'update'"
@@ -111,12 +111,12 @@
               </el-form-item>
               <el-form-item
                 v-if="form.type === '0'"
-                label="前端组件"
+                label="地址"
                 prop="component">
                 <el-input
-                  v-model="form.component"
+                  v-model="form.path"
                   :disabled="formEdit"
-                  placeholder="http://xx | views/xx/xx"/>
+                  placeholder="/xx/xxx || http://"/>
               </el-form-item>
               <el-form-item
                 v-if="form.type === '0'"
@@ -130,7 +130,7 @@
               </el-form-item>
               <el-form-item
                 v-if="form.type === '0'"
-                label="菜单排序"
+                label="排序"
                 prop="sort">
                 <el-input
                   v-model="form.sort"
@@ -141,7 +141,7 @@
               <el-form-item
                 v-if="form.type === '0'"
                 label="路由缓冲"
-                prop="keepAlive">
+                prop="type">
                 <el-switch
                   v-model="form.keepAlive"
                   :disabled="formEdit"
@@ -175,7 +175,6 @@
 <script>
   import {addObj, delObj, fetchMenuTree, getObj, putObj} from '@/api/admin/menu'
   import {mapGetters} from 'vuex'
-  import {validatenull} from '@/util/validate'
   import iconList from '@/const/iconList'
 
   export default {
@@ -222,31 +221,33 @@
           menuId: undefined,
           parentId: undefined,
           icon: undefined,
-          sort: 0,
+          sort: undefined,
           component: undefined,
           type: undefined,
-          path: undefined,
+          path: undefined
         },
         currentId: -1,
         menuManager_btn_add: false,
         menuManager_btn_edit: false,
         menuManager_btn_del: false,
         rules: {
-          name: [{required: true, message: '请输入标题', trigger: 'blur'}],
-          type: [{required: true, message: '请输入类型', trigger: 'blur'}],
-          component: [{validator: this.checkComponent, trigger: 'blur'}]
+          menuId: [{required: true, message: '节点ID不合法', trigger: 'blur'}],
+          name: [{required: true, message: '标题不合法', trigger: 'blur'}],
+          type: [{required: true, message: '类型不合法', trigger: 'blur'}],
+          path: [{validator: this.checkPath, trigger: 'blur'}]
         }
       }
     },
+
+    computed: {
+      ...mapGetters(['elements', 'permissions'])
+    },
     created() {
       this.getList()
       this.menuManager_btn_add = this.permissions['sys_menu_add']
       this.menuManager_btn_edit = this.permissions['sys_menu_edit']
       this.menuManager_btn_del = this.permissions['sys_menu_del']
     },
-    computed: {
-      ...mapGetters(['elements', 'permissions'])
-    },
     methods: {
       getList() {
         fetchMenuTree(this.listQuery).then(response => {
@@ -303,6 +304,15 @@
         this.currentId = data.id
         this.showElement = true
       },
+      checkPath(rule, value, callback) {
+        if (this.form.type === '1') {
+          callback()
+        } else if (this.validatenull(value)) {
+          callback(new Error('请输入前端组件'))
+        } else {
+          callback()
+        }
+      },
       handlerEdit() {
         if (this.form.menuId) {
           this.formEdit = false
@@ -314,15 +324,6 @@
         this.formEdit = false
         this.formStatus = 'create'
       },
-      checkComponent(rule, value, callback) {
-        if (this.form.type === '1') {
-          callback()
-        } else if (validatenull(value)) {
-          callback(new Error('请输入前端组件'))
-        } else if (value.startsWith('/') || value.endsWith("/")) {
-          callback(new Error('组件不能以/开头或结尾'))
-        }
-      },
       handleDelete() {
         this.$confirm('此操作将永久删除, 是否继续?', '提示', {
           confirmButtonText: '确定',
@@ -385,7 +386,7 @@
           menuId: undefined,
           parentId: this.currentId,
           icon: undefined,
-          sort: 0,
+          sort: undefined,
           component: undefined,
           type: undefined,
           path: undefined