Prechádzať zdrojové kódy

:sparkles: Introducing new features. 前端增加 keepAlive 控制

冷冷 5 rokov pred
rodič
commit
d440941b9b

+ 30 - 3
src/const/crud/admin/menu.js

@@ -18,7 +18,7 @@ import iconList from '@/const/iconList'
 
 export const tableOption = {
   tip: false,
-  lazy:true,
+  lazy: true,
   dialogWidth: "60%",
   tree: true,
   border: true,
@@ -41,9 +41,9 @@ export const tableOption = {
     {
       label: "类型",
       prop: "type",
-      type: "radio",
+      type: "select",
       slot: true,
-      border:true,
+      border: true,
       valueFormat: "string",
       dicData: [
         {
@@ -131,6 +131,33 @@ export const tableOption = {
         }
       ]
     },
+    {
+      hide: true,
+      addDisplay: true,
+      editDisplay: true,
+      label: "路由缓冲",
+      prop: "keepAlive",
+      type: "radio",
+      border: true,
+      valueFormat: "string",
+      dicData: [
+        {
+          label: "关闭",
+          value: "0"
+        },
+        {
+          label: "打开",
+          value: "1"
+        },
+      ],
+      rules: [
+        {
+          required: true,
+          message: "请选择上级菜单",
+          trigger: "click",
+        }
+      ]
+    },
     {
       label: "排序",
       prop: "sort",

+ 1 - 1
src/router/avue-router.js

@@ -95,7 +95,7 @@ RouterPlugin.install = function(router, store) {
         const children = oMenu[propsDefault.children]
 
         const meta = {
-          keepAlive: Number(oMenu['keepAlive']) === 0
+          keepAlive: Number(oMenu['keepAlive']) === 1
         }
         const isChild = children.length !== 0
         const oRouter = {

+ 8 - 1
src/views/admin/menu/index.vue

@@ -124,7 +124,7 @@
             item.editDisplay = this.form.type !== "1"
           }
 
-          // 是按钮类型输入code
+          // 是按钮类型输入permission
           if (item.prop === "permission") {
             item.addDisplay = this.form.type === "1"
             item.editDisplay = this.form.type === "1"
@@ -140,6 +140,13 @@
           if (item.prop === "parentId") {
             item.rules[0].required = this.form.type === "1"
           }
+
+          // 菜单开启 keepAlive 选择
+          if (item.prop === "keepAlive") {
+            item.addDisplay = this.form.type === "0"
+            item.editDisplay = this.form.type === "0"
+            item.rules[0].required = this.form.type === "0"
+          }
         });
       }
     }