diff --git a/.env b/.env index 8c37d17..5992ff0 100644 --- a/.env +++ b/.env @@ -23,4 +23,4 @@ VITE_COPYRIGHT_INFO = Copyright © 2024 chansee97 VITE_AUTO_REFRESH_TOKEN = N # 默认多语言 enUS | zhCN -VITE_DEFAULT_LANG = enUS +VITE_DEFAULT_LANG = zhCN diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2dfa6e7..c4ba90e 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,7 +3,6 @@ "mikestead.dotenv", "usernamehw.errorlens", "dbaeumer.vscode-eslint", - "eamodio.gitlens", "mhutchie.git-graph", "donjayamanne.githistory", "lokalise.i18n-ally", diff --git a/src/api/demo.ts b/src/api/demo.ts index 3aded9a..7e8f54c 100644 --- a/src/api/demo.ts +++ b/src/api/demo.ts @@ -27,5 +27,5 @@ export function fetchRoleList() { */ export function fetchDictList(code?: string) { const params = { code } - return request.Get>('/dict/list', { params }) + return request.Get>('/dict/list', { params }) } diff --git a/src/api/index.ts b/src/api/index.ts index 4770c31..99a42ff 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,8 +1,4 @@ export * from './login' export * from './demo' export * from './test' -export * from './system/user' -export * from './system/menu' -export * from './system/role' -export * from './system/dict' -export * from './system/dept' +export * from './system' diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts index b72763f..cfde048 100644 --- a/src/api/system/dept.ts +++ b/src/api/system/dept.ts @@ -1,6 +1,6 @@ import { request } from '../../utils/alova' -export type SearchQuery = Partial> +export type DeptSearchQuery = Partial> /** * 创建部门 @@ -14,7 +14,7 @@ export function createDept(data: Partial) { * 分页查询部门 * GET /dept */ -export function getDeptList(params?: SearchQuery) { +export function getDeptList(params?: DeptSearchQuery) { return request.Get>('/dept', { params }) } diff --git a/src/api/system/index.ts b/src/api/system/index.ts new file mode 100644 index 0000000..d595aef --- /dev/null +++ b/src/api/system/index.ts @@ -0,0 +1,5 @@ +export * from './user' +export * from './menu' +export * from './role' +export * from './dict' +export * from './dept' diff --git a/src/api/system/menu.ts b/src/api/system/menu.ts index 7a40b95..ed3007d 100644 --- a/src/api/system/menu.ts +++ b/src/api/system/menu.ts @@ -1,6 +1,6 @@ import { request } from '../../utils/alova' -export type SearchQuery = Partial> +export type MenuSearchQuery = Partial> /** * 创建菜单 * POST /menu @@ -13,7 +13,7 @@ export function createMenu(data: Partial) { * 分页查询菜单 * GET /menu */ -export function getMenuList(params?: SearchQuery) { +export function getMenuList(params?: MenuSearchQuery) { return request.Get>('/menu', { params }) } diff --git a/src/components/common/Pagination.vue b/src/components/common/Pagination.vue deleted file mode 100644 index dc09836..0000000 --- a/src/components/common/Pagination.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - diff --git a/src/hooks/useDict.ts b/src/hooks/useDict.ts new file mode 100644 index 0000000..b80290a --- /dev/null +++ b/src/hooks/useDict.ts @@ -0,0 +1,72 @@ +import { useDictStore } from '@/store/dict' + +/** + * 字典数据转换工具类型 + */ +export interface DictUtils { + /** 原始字典数据 */ + data: Entity.DictData[] + /** 枚举映射 { value: label } */ + enum: Record + /** 值映射 { value: dictData } */ + valueMap: Record> + /** 标签映射 { label: dictData } */ + labelMap: Record> + /** 选项数组 [{ label, value }] */ + options: Array<{ label: string, value: string }> +} + +/** + * 使用字典数据的 Hook + * @param dictType 字典类型 + * @returns 字典工具对象和加载状态 + */ +export function useDict(dictType: string) { + const dictStore = useDictStore() + + const dictData = ref([]) + + // 获取字典数据 + async function fetchDict() { + try { + dictData.value = await dictStore.getDict(dictType) + } + catch (err) { + console.error(`获取字典数据失败 [${dictType}]:`, err) + } + } + + // 立即获取数据 + fetchDict() + + const enumMap = computed(() => { + return Object.fromEntries( + dictData.value.map(({ value, name }) => [value, name]), + ) + }) + const valueMap = computed(() => { + return Object.fromEntries( + dictData.value.map(({ value, ...data }) => [value, data]), + ) + }) + const labelMap = computed(() => { + return Object.fromEntries( + dictData.value.map(({ name, ...data }) => [name, data]), + ) + }) + + const options = computed(() => { + return dictData.value.map(({ name, value }) => ({ + label: name, + value, + })) + }) + + return { + rawData: dictData, + enumMap, + valueMap, + labelMap, + options, + } +} diff --git a/src/hooks/useTableDrag.ts b/src/hooks/useTableDrag.ts deleted file mode 100644 index d31ea15..0000000 --- a/src/hooks/useTableDrag.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { NDataTable } from 'naive-ui' -import { useDraggable } from 'vue-draggable-plus' - -export function useTableDrag(params: { - tableRef: Ref | undefined> - data: Ref - onRowDrag: (rows: T[]) => void -}) { - const tableEl = computed(() => params.tableRef?.value?.$el as HTMLElement) - const tableBodyRef = ref(undefined) - - const { start } = useDraggable(tableBodyRef, params.data, { - immediate: false, - animation: 150, - handle: '.drag-handle', - onEnd: (event) => { - const { oldIndex, newIndex } = event - const start = Math.min(oldIndex!, newIndex!) - const end = Math.max(oldIndex!, newIndex!) - start + 1 - const changedRows = [...params.data.value].splice(start, end) - params.onRowDrag(unref([...changedRows])) - }, - }) - - onMounted(async () => { - while (!tableBodyRef.value) { - tableBodyRef.value = tableEl.value?.querySelector('tbody') || undefined - await new Promise(resolve => setTimeout(resolve, 100)) - } - }) - - watchOnce(() => tableBodyRef.value, (el) => { - el && start() - }) -} diff --git a/src/layouts/components/tab/TabBar.vue b/src/layouts/components/tab/TabBar.vue index 72d3a9d..5dbf092 100644 --- a/src/layouts/components/tab/TabBar.vue +++ b/src/layouts/components/tab/TabBar.vue @@ -1,7 +1,7 @@ + + diff --git a/src/views/build-in/user-center/index.vue b/src/views/build-in/user-center/index.vue index 7089487..ddcc07f 100644 --- a/src/views/build-in/user-center/index.vue +++ b/src/views/build-in/user-center/index.vue @@ -1,15 +1,13 @@ diff --git a/src/views/demo/list/common-list/components/TableModal.vue b/src/views/demo/list/common-list/components/TableModal.vue deleted file mode 100644 index 96d6130..0000000 --- a/src/views/demo/list/common-list/components/TableModal.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - - - diff --git a/src/views/demo/list/common-list/index.vue b/src/views/demo/list/common-list/index.vue deleted file mode 100644 index 40fe188..0000000 --- a/src/views/demo/list/common-list/index.vue +++ /dev/null @@ -1,209 +0,0 @@ - - - diff --git a/src/views/demo/list/draggable-list/index.vue b/src/views/demo/list/draggable-list/index.vue index c66a982..7dce810 100644 --- a/src/views/demo/list/draggable-list/index.vue +++ b/src/views/demo/list/draggable-list/index.vue @@ -1,170 +1,103 @@ diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 889cd62..cf7207e 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -1,7 +1,7 @@