fix: 优化组件功能和样式

This commit is contained in:
AN 2025-05-10 23:12:57 +08:00
parent fd0783a50f
commit 862ac25057
2 changed files with 19 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<script setup lang="tsx">
import { onMounted, ref, useAttrs } from 'vue';
import { onMounted, ref, useAttrs, watch } from 'vue';
import type { TreeOption, TreeSelectInst, TreeSelectProps } from 'naive-ui';
import { useBoolean } from '@sa/hooks';
import { fetchGetMenuTreeSelect } from '@/service/api/system';
@ -40,6 +40,7 @@ async function getMenuList() {
children: data
}
] as Api.System.MenuList;
//
loading.value = false;
}
@ -49,6 +50,21 @@ onMounted(() => {
}
});
// watch expandAll ,optionsexpandedKeys
watch(
[expandAll, options],
([newVal]) => {
if (newVal) {
//
expandedKeys.value = getAllMenuIds(options.value);
} else {
//
expandedKeys.value = [0];
}
},
{ immediate: true }
);
function renderPrefix({ option }: { option: TreeOption }) {
const renderLocalIcon = String(option.icon).startsWith('icon-');
let icon = renderLocalIcon ? undefined : String(option.icon ?? 'material-symbols:buttons-alt-outline-rounded');
@ -62,7 +78,7 @@ function renderPrefix({ option }: { option: TreeOption }) {
function getAllMenuIds(menu: Api.System.MenuList) {
const menuIds: CommonType.IdType[] = [];
menu.forEach(item => {
menuIds.push(item.menuId);
menuIds.push(item.id!);
if (item.children) {
menuIds.push(...getAllMenuIds(item.children));
}
@ -123,7 +139,6 @@ defineExpose({
:loading="loading"
virtual-scroll
check-strategy="all"
:default-expand-all="expandAll"
:render-prefix="renderPrefix"
v-bind="attrs"
/>

View File

@ -116,7 +116,7 @@ const { columns, columnChecks, data, getData, loading, searchParams, resetSearch
<ButtonIcon
text
type="error"
icon="material-symbols:person-remove-outline-rounded"
icon="material-symbols:delete-outline"
class="text-20px"
tooltipContent="强制下线"
popconfirmContent="确认强制下线吗?"