使用字典配置替换枚举.

This commit is contained in:
lijiahangmax
2023-10-27 02:27:18 +08:00
parent 74688ca535
commit d32f21dc91
7 changed files with 60 additions and 33 deletions

View File

@@ -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 = () => {

View File

@@ -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(() => {

View File

@@ -36,4 +36,5 @@ export const menuVisibleKey = 'systemMenuVisible';
// 是否缓存 字典项
export const menuCacheKey = 'systemMenuCache';
// 加载的字典值
export const dictKeys = [menuTypeKey, menuStatusKey, menuVisibleKey, menuCacheKey];