diff --git a/build/plugins/router.ts b/build/plugins/router.ts index a32eb57..5eec070 100644 --- a/build/plugins/router.ts +++ b/build/plugins/router.ts @@ -4,6 +4,7 @@ import type { RouteKey } from '@elegant-router/types' export function setupElegantRouter() { return ElegantVueRouter({ + dtsDir: 'src/types/elegant-router.d.ts', layouts: { base: 'src/layouts/base-layout/index.vue', blank: 'src/layouts/blank-layout/index.vue', diff --git a/build/plugins/unplugin.ts b/build/plugins/unplugin.ts index 949b105..aeef0d0 100644 --- a/build/plugins/unplugin.ts +++ b/build/plugins/unplugin.ts @@ -28,7 +28,7 @@ export function setupUnplugin(viteEnv: Env.ImportMeta) { defaultClass: 'inline-block', }), AutoImport({ - dts: 'src/typings/auto-imports.d.ts', + dts: 'src/types/auto-imports.d.ts', imports: [ '@vueuse/core', 'vue-router', @@ -40,7 +40,7 @@ export function setupUnplugin(viteEnv: Env.ImportMeta) { ], }), Components({ - dts: 'src/typings/components.d.ts', + dts: 'src/types/components.d.ts', types: [{ from: 'vue-router', names: ['RouterLink', 'RouterView'] }], resolvers: [ AntDesignVueResolver({ diff --git a/packages/scripts/tsconfig.json b/packages/scripts/tsconfig.json index 67ab8a4..1ae73b1 100644 --- a/packages/scripts/tsconfig.json +++ b/packages/scripts/tsconfig.json @@ -15,6 +15,6 @@ "esModuleInterop": true, "forceConsistentCasingInFileNames": true }, - "include": ["src/**/*", "typings/**/*"], + "include": ["src/**/*", "types/**/*"], "exclude": ["node_modules", "dist"] } diff --git a/src/enum/index.ts b/src/constants/enum.ts similarity index 100% rename from src/enum/index.ts rename to src/constants/enum.ts diff --git a/src/store/modules/app/index.ts b/src/store/modules/app/index.ts index 0e7263a..7391a13 100644 --- a/src/store/modules/app/index.ts +++ b/src/store/modules/app/index.ts @@ -4,7 +4,7 @@ import { useBoolean } from '@sa/hooks' import { useRouteStore } from '../route' import { useTabStore } from '../tab' import { useThemeStore } from '../theme' -import { SetupStoreId } from '@/enum' +import { SetupStoreId } from '@/constants/enum' import { router } from '@/router' import { $t, setLocale } from '@/locales' import { setDayjsLocale } from '@/locales/dayjs' diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index c7f24df..ef8bac3 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -3,7 +3,7 @@ import { useLoading } from '@sa/hooks' import { useRouteStore } from '../route' import { useTabStore } from '../tab' import { clearAuthStorage, getToken } from './shared' -import { SetupStoreId } from '@/enum' +import { SetupStoreId } from '@/constants/enum' import { useRouterPush } from '@/hooks/common/router' import { fetchGetUserInfo, fetchLogin } from '@/service/api' import { localStg } from '@/utils/storage' diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index f5e7075..5ae8373 100644 --- a/src/store/modules/route/index.ts +++ b/src/store/modules/route/index.ts @@ -16,7 +16,7 @@ import { transformMenuToSearchMenus, updateLocaleOfGlobalMenus, } from './shared' -import { SetupStoreId } from '@/enum' +import { SetupStoreId } from '@/constants/enum' import { router } from '@/router' import { createStaticRoutes, getAuthVueRoutes } from '@/router/routes' import { ROOT_ROUTE } from '@/router/routes/builtin' diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index 2f1b23e..a8478db 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -16,7 +16,7 @@ import { updateTabsByI18nKey, } from './shared' import { router } from '@/router' -import { SetupStoreId } from '@/enum' +import { SetupStoreId } from '@/constants/enum' import { useRouterPush } from '@/hooks/common/router' import { localStg } from '@/utils/storage' import { useRouteStore } from '@/store/modules/route' diff --git a/src/store/modules/theme/index.ts b/src/store/modules/theme/index.ts index b48b114..afc9c93 100644 --- a/src/store/modules/theme/index.ts +++ b/src/store/modules/theme/index.ts @@ -8,7 +8,7 @@ import { toggleAuxiliaryColorModes, toggleCssDarkMode, } from './shared' -import { SetupStoreId } from '@/enum' +import { SetupStoreId } from '@/constants/enum' import { localStg } from '@/utils/storage' /** Theme store */ diff --git a/src/store/plugins/index.ts b/src/store/plugins/index.ts index f661a0c..5fc908e 100644 --- a/src/store/plugins/index.ts +++ b/src/store/plugins/index.ts @@ -1,6 +1,6 @@ import type { PiniaPluginContext } from 'pinia' import { jsonClone } from '@sa/utils' -import { SetupStoreId } from '@/enum' +import { SetupStoreId } from '@/constants/enum' /** * The plugin reset the state of the store which is written by setup syntax diff --git a/src/typings/api.d.ts b/src/types/api.d.ts similarity index 100% rename from src/typings/api.d.ts rename to src/types/api.d.ts diff --git a/src/typings/app.d.ts b/src/types/app.d.ts similarity index 100% rename from src/typings/app.d.ts rename to src/types/app.d.ts diff --git a/src/typings/auto-imports.d.ts b/src/types/auto-imports.d.ts similarity index 100% rename from src/typings/auto-imports.d.ts rename to src/types/auto-imports.d.ts diff --git a/src/typings/common.d.ts b/src/types/common.d.ts similarity index 100% rename from src/typings/common.d.ts rename to src/types/common.d.ts diff --git a/src/typings/components.d.ts b/src/types/components.d.ts similarity index 100% rename from src/typings/components.d.ts rename to src/types/components.d.ts diff --git a/src/typings/elegant-router.d.ts b/src/types/elegant-router.d.ts similarity index 100% rename from src/typings/elegant-router.d.ts rename to src/types/elegant-router.d.ts diff --git a/src/typings/env.d.ts b/src/types/env.d.ts similarity index 100% rename from src/typings/env.d.ts rename to src/types/env.d.ts diff --git a/src/typings/global.d.ts b/src/types/global.d.ts similarity index 100% rename from src/typings/global.d.ts rename to src/types/global.d.ts diff --git a/src/typings/naive-ui.d.ts b/src/types/naive-ui.d.ts similarity index 100% rename from src/typings/naive-ui.d.ts rename to src/types/naive-ui.d.ts diff --git a/src/typings/router.d.ts b/src/types/router.d.ts similarity index 100% rename from src/typings/router.d.ts rename to src/types/router.d.ts diff --git a/src/typings/storage.d.ts b/src/types/storage.d.ts similarity index 100% rename from src/typings/storage.d.ts rename to src/types/storage.d.ts diff --git a/src/types/typed-router.d.ts b/src/types/typed-router.d.ts new file mode 100644 index 0000000..144ddec --- /dev/null +++ b/src/types/typed-router.d.ts @@ -0,0 +1,28 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-router. ‼️ DO NOT MODIFY THIS FILE ‼️ +// It's recommended to commit this file. +// Make sure to add this file to your tsconfig.json file as an "includes" or "files" entry. + +declare module 'vue-router/auto-routes' { + import type { + RouteRecordInfo, + ParamValue, + ParamValueOneOrMore, + ParamValueZeroOrMore, + ParamValueZeroOrOne, + } from 'vue-router' + + /** + * Route name map generated by unplugin-vue-router + */ + export interface RouteNamedMap { + '/[...all]/': RouteRecordInfo<'/[...all]/', '/:all(.*)', { all: ParamValue }, { all: ParamValue }>, + '/403/': RouteRecordInfo<'/403/', '/403', Record, Record>, + '/500/': RouteRecordInfo<'/500/', '/500', Record, Record>, + '/home/': RouteRecordInfo<'/home/', '/home', Record, Record>, + '/iframe-page/[url]': RouteRecordInfo<'/iframe-page/[url]', '/iframe-page/:url', { url: ParamValue }, { url: ParamValue }>, + '/login/': RouteRecordInfo<'/login/', '/login', Record, Record>, + } +} diff --git a/src/typings/union-key.d.ts b/src/types/union-key.d.ts similarity index 100% rename from src/typings/union-key.d.ts rename to src/types/union-key.d.ts