使用字典配置替换枚举.
This commit is contained in:
@@ -182,7 +182,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { MenuQueryRequest, MenuQueryResponse } from '@/api/system/menu';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { getMenuList, deleteMenu, updateMenuStatus, initCache } from '@/api/system/menu';
|
||||
import { menuStatusKey, menuVisibleKey, menuTypeKey, MenuType } from '../types/const';
|
||||
@@ -281,7 +281,10 @@
|
||||
setFetchLoading(false);
|
||||
}
|
||||
};
|
||||
loadMenuData();
|
||||
|
||||
onMounted(() => {
|
||||
loadMenuData();
|
||||
});
|
||||
|
||||
// 重置菜单
|
||||
const resetForm = () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="layout-container">
|
||||
<div class="layout-container" v-if="render">
|
||||
<!-- 表格 -->
|
||||
<menu-table ref="table"
|
||||
@openAdd="(e) => modal.openAdd(e)"
|
||||
@@ -20,16 +20,22 @@
|
||||
<script lang="ts" setup>
|
||||
import MenuTable from '@/views/system/menu/components/menu-table.vue';
|
||||
import MenuFormModal from '@/views/system/menu/components/menu-form-modal.vue';
|
||||
|
||||
import { onUnmounted, ref } from 'vue';
|
||||
import { onBeforeMount, onUnmounted, ref } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
|
||||
const table = ref();
|
||||
const modal = ref();
|
||||
// FIXME
|
||||
const render = ref(false);
|
||||
|
||||
// FIXME
|
||||
// 加载字典项
|
||||
useDictStore().loadKeys(dictKeys);
|
||||
onBeforeMount(async () => {
|
||||
const dictStore = useDictStore();
|
||||
await dictStore.loadKeys(dictKeys);
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 卸载时清除 menu cache
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -36,4 +36,5 @@ export const menuVisibleKey = 'systemMenuVisible';
|
||||
// 是否缓存 字典项
|
||||
export const menuCacheKey = 'systemMenuCache';
|
||||
|
||||
// 加载的字典值
|
||||
export const dictKeys = [menuTypeKey, menuStatusKey, menuVisibleKey, menuCacheKey];
|
||||
|
||||
Reference in New Issue
Block a user