xiaochan 1 年之前
父节点
当前提交
b810ee6ebd
共有 2 个文件被更改,包括 23 次插入17 次删除
  1. 4 9
      src/router/index.ts
  2. 19 8
      src/views/settings/menu-settings/dialog.vue

+ 4 - 9
src/router/index.ts

@@ -19,13 +19,10 @@ import {userInfoStore} from "@/utils/store-public";
 import {stringIsBlank} from "@/utils/blank-utils";
 import XEUtils from "xe-utils";
 
-const whiteNameRouting = []
 
 function dashboardRouter(data: Array<RouteRecordRaw>) {
     data.forEach((item) => {
         XEUtils.set(item, "meta.needToken", false)
-        XEUtils.set(item, "meta.needToken", false)
-        whiteNameRouting.push(item.path)
         if (item.children && item.children.length > 0) {
             dashboardRouter(item.children)
         }
@@ -136,6 +133,7 @@ router.beforeEach(async (to, _from, next) => {
         NProgress.start();
 
         function tmpNext(...arg) {
+            console.log(123)
             to.meta.title && changeTitle(to.meta.title)
             if (to.meta.needToken && stringIsBlank(userInfoStore.value.token)) {
                 next('/login')
@@ -144,12 +142,9 @@ router.beforeEach(async (to, _from, next) => {
             next(...arg);
         }
 
-        for (let i = 0; i < whiteNameRouting.length; i++) {
-            const tmp: string = whiteNameRouting[i]
-            if (tmp.startsWith(to.path)) {
-                tmpNext()
-                return
-            }
+        if (XEUtils.has(to, 'meta.needToken') && !to.meta.needToken) {
+            tmpNext()
+            return
         }
 
         if (!asyncFinished) {

+ 19 - 8
src/views/settings/menu-settings/dialog.vue

@@ -20,6 +20,7 @@ import XEUtils from "xe-utils";
 import icon from '@/icons/iconfont.css'
 import {eachAndReturnList} from "@/utils/cyRefList";
 import {useCompRef} from "@/utils/useCompRef";
+import {QuestionFilled} from "@element-plus/icons-vue";
 
 const props = defineProps<{
   cascaderData: any[],
@@ -115,7 +116,6 @@ function handlePath() {
   } else {
     if (isStartsWith) {
       currentData.value.path = currentData.value.path.substring(1)
-      console.log(currentData.value.path.substring(1))
     }
   }
 }
@@ -172,15 +172,18 @@ defineExpose({
         </el-col>
 
         <el-col :span="24">
-          <el-form-item label="路径" prop="path">
+          <el-form-item prop="path">
             <template #label>
               路径
+              <el-tooltip content="如果是在根目录则不需要已 / 开头" placement="top">
+                <el-icon>
+                  <QuestionFilled/>
+                </el-icon>
+              </el-tooltip>
             </template>
-            <template #default>
-              <el-input v-model="currentData.path"
-                        @blur="handlePath"
-              />
-            </template>
+            <el-input v-model="currentData.path"
+                      @blur="handlePath"
+            />
           </el-form-item>
         </el-col>
 
@@ -197,7 +200,15 @@ defineExpose({
         </el-col>
 
         <el-col :span="12">
-          <el-form-item label="路由名称" prop="name">
+          <el-form-item prop="name">
+            <template #label>
+              名称
+              <el-tooltip content="这个名称必须是唯一" placement="top">
+                <el-icon>
+                  <QuestionFilled/>
+                </el-icon>
+              </el-tooltip>
+            </template>
             <el-input v-model="currentData.name"
                       clearable maxlength="50"/>
           </el-form-item>