feat:【代码优化】use-dict-select.ts 的 API 导入问题,不在 import *

This commit is contained in:
YunaiV
2025-10-27 08:44:07 +08:00
parent 9651ec49a6
commit b7d32e315b
2 changed files with 10 additions and 6 deletions

View File

@@ -1,8 +1,10 @@
import type { SystemDictTypeApi } from '#/api/system/dict/type';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { buildUUID, cloneDeep } from '@vben/utils'; import { buildUUID, cloneDeep } from '@vben/utils';
import * as DictDataApi from '#/api/system/dict/type'; import { getSimpleDictTypeList } from '#/api/system/dict/type';
import { import {
localeProps, localeProps,
makeRequiredRule, makeRequiredRule,
@@ -18,12 +20,12 @@ export function useDictSelectRule() {
const rules = cloneDeep(selectRule); const rules = cloneDeep(selectRule);
const dictOptions = ref<{ label: string; value: string }[]>([]); // 字典类型下拉数据 const dictOptions = ref<{ label: string; value: string }[]>([]); // 字典类型下拉数据
onMounted(async () => { onMounted(async () => {
const data = await DictDataApi.getSimpleDictTypeList(); const data = await getSimpleDictTypeList();
if (!data || data.length === 0) { if (!data || data.length === 0) {
return; return;
} }
dictOptions.value = dictOptions.value =
data?.map((item: DictDataApi.SystemDictTypeApi.DictType) => ({ data?.map((item: SystemDictTypeApi.DictType) => ({
label: item.name, label: item.name,
value: item.type, value: item.type,
})) ?? []; })) ?? [];

View File

@@ -1,8 +1,10 @@
import type { SystemDictTypeApi } from '#/api/system/dict/type';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { buildUUID, cloneDeep } from '@vben/utils'; import { buildUUID, cloneDeep } from '@vben/utils';
import * as DictDataApi from '#/api/system/dict/type'; import { getSimpleDictTypeList } from '#/api/system/dict/type';
import { import {
localeProps, localeProps,
makeRequiredRule, makeRequiredRule,
@@ -18,12 +20,12 @@ export const useDictSelectRule = () => {
const rules = cloneDeep(selectRule); const rules = cloneDeep(selectRule);
const dictOptions = ref<{ label: string; value: string }[]>([]); // 字典类型下拉数据 const dictOptions = ref<{ label: string; value: string }[]>([]); // 字典类型下拉数据
onMounted(async () => { onMounted(async () => {
const data = await DictDataApi.getSimpleDictTypeList(); const data = await getSimpleDictTypeList();
if (!data || data.length === 0) { if (!data || data.length === 0) {
return; return;
} }
dictOptions.value = dictOptions.value =
data?.map((item: DictDataApi.SystemDictTypeApi.DictType) => ({ data?.map((item: SystemDictTypeApi.DictType) => ({
label: item.name, label: item.name,
value: item.type, value: item.type,
})) ?? []; })) ?? [];