mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-11-22 00:16:47 +08:00
Compare commits
3 Commits
6eaec8705d
...
3d0daae43c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d0daae43c | ||
|
|
5be864a80b | ||
|
|
b041fdd864 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -33,3 +33,5 @@ package-lock.json
|
|||||||
yarn.lock
|
yarn.lock
|
||||||
|
|
||||||
.VSCodeCounter
|
.VSCodeCounter
|
||||||
|
|
||||||
|
.temp
|
||||||
@@ -2,7 +2,7 @@ import type { PluginOption } from 'vite';
|
|||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||||
import progress from 'vite-plugin-progress';
|
import progress from 'vite-plugin-progress';
|
||||||
import { setupElegantRouter } from './router';
|
import elegantRouter from 'elegant-router/vite';
|
||||||
import { setupUnocss } from './unocss';
|
import { setupUnocss } from './unocss';
|
||||||
import { setupUnplugin } from './unplugin';
|
import { setupUnplugin } from './unplugin';
|
||||||
import { setupHtmlPlugin } from './html';
|
import { setupHtmlPlugin } from './html';
|
||||||
@@ -13,7 +13,7 @@ export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) {
|
|||||||
vue(),
|
vue(),
|
||||||
vueJsx(),
|
vueJsx(),
|
||||||
setupDevtoolsPlugin(viteEnv),
|
setupDevtoolsPlugin(viteEnv),
|
||||||
setupElegantRouter(),
|
elegantRouter(),
|
||||||
setupUnocss(viteEnv),
|
setupUnocss(viteEnv),
|
||||||
...setupUnplugin(viteEnv),
|
...setupUnplugin(viteEnv),
|
||||||
progress(),
|
progress(),
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
import type { RouteMeta } from 'vue-router';
|
|
||||||
import ElegantVueRouter from '@elegant-router/vue/vite';
|
|
||||||
import type { RouteKey } from '@elegant-router/types';
|
|
||||||
|
|
||||||
export function setupElegantRouter() {
|
|
||||||
return ElegantVueRouter({
|
|
||||||
layouts: {
|
|
||||||
base: 'src/layouts/base-layout/index.vue',
|
|
||||||
blank: 'src/layouts/blank-layout/index.vue'
|
|
||||||
},
|
|
||||||
routePathTransformer(routeName, routePath) {
|
|
||||||
const key = routeName as RouteKey;
|
|
||||||
|
|
||||||
if (key === 'login') {
|
|
||||||
const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];
|
|
||||||
|
|
||||||
const moduleReg = modules.join('|');
|
|
||||||
|
|
||||||
return `/login/:module(${moduleReg})?`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return routePath;
|
|
||||||
},
|
|
||||||
onRouteMetaGen(routeName) {
|
|
||||||
const key = routeName as RouteKey;
|
|
||||||
|
|
||||||
const constantRoutes: RouteKey[] = ['login', '403', '404', '500'];
|
|
||||||
|
|
||||||
const meta: Partial<RouteMeta> = {
|
|
||||||
title: key,
|
|
||||||
i18nKey: `route.${key}` as App.I18n.I18nKey
|
|
||||||
};
|
|
||||||
|
|
||||||
if (constantRoutes.includes(key)) {
|
|
||||||
meta.constant = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
37
er.config.ts
Normal file
37
er.config.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import type { RouteMeta } from 'vue-router';
|
||||||
|
import { defineConfig } from 'elegant-router';
|
||||||
|
import type { RouteKey } from '@elegant-router/types';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
pageDir: ['src/views'],
|
||||||
|
layouts: {
|
||||||
|
base: 'src/layouts/base-layout/index.vue',
|
||||||
|
blank: 'src/layouts/blank-layout/index.vue'
|
||||||
|
},
|
||||||
|
getRoutePath: node => {
|
||||||
|
if (node.name === 'Login') {
|
||||||
|
const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];
|
||||||
|
|
||||||
|
const moduleReg = modules.join('|');
|
||||||
|
|
||||||
|
return `/login/:module(${moduleReg})?`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return node.path;
|
||||||
|
},
|
||||||
|
getRouteMeta: node => {
|
||||||
|
const constantRoutes: RouteKey[] = ['Login', '403', '404', '500'];
|
||||||
|
|
||||||
|
const name = node.name as RouteKey;
|
||||||
|
|
||||||
|
const meta: Partial<RouteMeta> = {
|
||||||
|
title: name
|
||||||
|
};
|
||||||
|
|
||||||
|
if (constantRoutes.includes(name)) {
|
||||||
|
meta.constant = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
});
|
||||||
41
package.json
41
package.json
@@ -54,53 +54,54 @@
|
|||||||
"@sa/hooks": "workspace:*",
|
"@sa/hooks": "workspace:*",
|
||||||
"@sa/materials": "workspace:*",
|
"@sa/materials": "workspace:*",
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"@vueuse/core": "13.8.0",
|
"@vueuse/core": "13.9.0",
|
||||||
"clipboard": "2.0.11",
|
"clipboard": "2.0.11",
|
||||||
"dayjs": "1.11.14",
|
"dayjs": "1.11.18",
|
||||||
"defu": "6.1.4",
|
"defu": "6.1.4",
|
||||||
"echarts": "6.0.0",
|
"echarts": "6.0.0",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"naive-ui": "2.42.0",
|
"naive-ui": "2.43.1",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"pinia": "3.0.3",
|
"pinia": "3.0.3",
|
||||||
"tailwind-merge": "3.3.1",
|
"tailwind-merge": "3.3.1",
|
||||||
"vue": "3.5.20",
|
"vue": "3.5.21",
|
||||||
"vue-draggable-plus": "0.6.0",
|
"vue-draggable-plus": "0.6.0",
|
||||||
"vue-i18n": "11.1.11",
|
"vue-i18n": "11.1.12",
|
||||||
"vue-router": "4.5.1"
|
"vue-router": "4.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@elegant-router/vue": "0.3.8",
|
"@elegant-router/vue": "0.3.8",
|
||||||
"@iconify/json": "2.2.378",
|
"@iconify/json": "2.2.385",
|
||||||
"@sa/scripts": "workspace:*",
|
"@sa/scripts": "workspace:*",
|
||||||
"@sa/uno-preset": "workspace:*",
|
"@sa/uno-preset": "workspace:*",
|
||||||
"@soybeanjs/eslint-config": "1.7.1",
|
"@soybeanjs/eslint-config": "1.7.1",
|
||||||
"@types/node": "24.3.0",
|
"@types/node": "24.5.1",
|
||||||
"@types/nprogress": "0.2.3",
|
"@types/nprogress": "0.2.3",
|
||||||
"@unocss/eslint-config": "66.4.2",
|
"@unocss/eslint-config": "66.5.1",
|
||||||
"@unocss/preset-icons": "66.4.2",
|
"@unocss/preset-icons": "66.5.1",
|
||||||
"@unocss/preset-uno": "66.4.2",
|
"@unocss/preset-uno": "66.5.1",
|
||||||
"@unocss/transformer-directives": "66.4.2",
|
"@unocss/transformer-directives": "66.5.1",
|
||||||
"@unocss/transformer-variant-group": "66.4.2",
|
"@unocss/transformer-variant-group": "66.5.1",
|
||||||
"@unocss/vite": "66.4.2",
|
"@unocss/vite": "66.5.1",
|
||||||
"@vitejs/plugin-vue": "6.0.1",
|
"@vitejs/plugin-vue": "6.0.1",
|
||||||
"@vitejs/plugin-vue-jsx": "5.1.0",
|
"@vitejs/plugin-vue-jsx": "5.1.1",
|
||||||
"consola": "3.4.2",
|
"consola": "3.4.2",
|
||||||
"eslint": "9.34.0",
|
"elegant-router": "1.0.4",
|
||||||
|
"eslint": "9.35.0",
|
||||||
"eslint-plugin-vue": "10.4.0",
|
"eslint-plugin-vue": "10.4.0",
|
||||||
"kolorist": "1.8.0",
|
"kolorist": "1.8.0",
|
||||||
"sass": "1.91.0",
|
"sass": "1.92.1",
|
||||||
"simple-git-hooks": "2.13.1",
|
"simple-git-hooks": "2.13.1",
|
||||||
"tsx": "4.20.5",
|
"tsx": "4.20.5",
|
||||||
"typescript": "5.9.2",
|
"typescript": "5.9.2",
|
||||||
"unplugin-icons": "22.2.0",
|
"unplugin-icons": "22.3.0",
|
||||||
"unplugin-vue-components": "29.0.0",
|
"unplugin-vue-components": "29.0.0",
|
||||||
"vite": "7.1.3",
|
"vite": "7.1.5",
|
||||||
"vite-plugin-progress": "0.0.7",
|
"vite-plugin-progress": "0.0.7",
|
||||||
"vite-plugin-svg-icons": "2.0.1",
|
"vite-plugin-svg-icons": "2.0.1",
|
||||||
"vite-plugin-vue-devtools": "8.0.1",
|
"vite-plugin-vue-devtools": "8.0.2",
|
||||||
"vue-eslint-parser": "10.2.0",
|
"vue-eslint-parser": "10.2.0",
|
||||||
"vue-tsc": "3.0.6"
|
"vue-tsc": "3.0.7"
|
||||||
},
|
},
|
||||||
"simple-git-hooks": {
|
"simple-git-hooks": {
|
||||||
"commit-msg": "pnpm sa git-commit-verify",
|
"commit-msg": "pnpm sa git-commit-verify",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"axios": "1.11.0",
|
"axios": "1.12.2",
|
||||||
"axios-retry": "4.5.0",
|
"axios-retry": "4.5.0",
|
||||||
"qs": "6.14.0"
|
"qs": "6.14.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { AxiosResponse, CreateAxiosDefaults, InternalAxiosRequestConfig } f
|
|||||||
import axiosRetry from 'axios-retry';
|
import axiosRetry from 'axios-retry';
|
||||||
import { nanoid } from '@sa/utils';
|
import { nanoid } from '@sa/utils';
|
||||||
import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options';
|
import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options';
|
||||||
|
import { transformResponse } from './shared';
|
||||||
import { BACKEND_ERROR_CODE, REQUEST_ID_KEY } from './constant';
|
import { BACKEND_ERROR_CODE, REQUEST_ID_KEY } from './constant';
|
||||||
import type {
|
import type {
|
||||||
CustomAxiosRequestConfig,
|
CustomAxiosRequestConfig,
|
||||||
@@ -53,6 +54,8 @@ function createCommonRequest<
|
|||||||
async response => {
|
async response => {
|
||||||
const responseType: ResponseType = (response.config?.responseType as ResponseType) || 'json';
|
const responseType: ResponseType = (response.config?.responseType as ResponseType) || 'json';
|
||||||
|
|
||||||
|
await transformResponse(response);
|
||||||
|
|
||||||
if (responseType !== 'json' || opts.isBackendSuccess(response)) {
|
if (responseType !== 'json' || opts.isBackendSuccess(response)) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { AxiosHeaderValue, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
import type { AxiosHeaderValue, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||||
|
import type { ResponseType } from './type';
|
||||||
|
|
||||||
export function getContentType(config: InternalAxiosRequestConfig) {
|
export function getContentType(config: InternalAxiosRequestConfig) {
|
||||||
const contentType: AxiosHeaderValue = config.headers?.['Content-Type'] || 'application/json';
|
const contentType: AxiosHeaderValue = config.headers?.['Content-Type'] || 'application/json';
|
||||||
@@ -26,3 +27,53 @@ export function isResponseJson(response: AxiosResponse) {
|
|||||||
|
|
||||||
return responseType === 'json' || responseType === undefined;
|
return responseType === 'json' || responseType === undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function transformResponse(response: AxiosResponse) {
|
||||||
|
const responseType: ResponseType = (response.config?.responseType as ResponseType) || 'json';
|
||||||
|
if (responseType === 'json') return;
|
||||||
|
|
||||||
|
const isJson = response.headers['content-type']?.includes('application/json');
|
||||||
|
if (!isJson) return;
|
||||||
|
|
||||||
|
if (responseType === 'blob') {
|
||||||
|
await transformBlobToJson(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseType === 'arrayBuffer') {
|
||||||
|
await transformArrayBufferToJson(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function transformBlobToJson(response: AxiosResponse) {
|
||||||
|
try {
|
||||||
|
let data = response.data;
|
||||||
|
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.prototype.toString.call(data) === '[object Blob]') {
|
||||||
|
const json = await data.text();
|
||||||
|
data = JSON.parse(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.data = data;
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function transformArrayBufferToJson(response: AxiosResponse) {
|
||||||
|
try {
|
||||||
|
let data = response.data;
|
||||||
|
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.prototype.toString.call(data) === '[object ArrayBuffer]') {
|
||||||
|
const json = new TextDecoder().decode(data);
|
||||||
|
data = JSON.parse(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.data = data;
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,15 +13,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@soybeanjs/changelog": "0.3.24",
|
"@soybeanjs/changelog": "0.3.25",
|
||||||
"bumpp": "10.2.3",
|
"bumpp": "10.2.3",
|
||||||
"c12": "3.2.0",
|
"c12": "3.3.0",
|
||||||
"cac": "6.7.14",
|
"cac": "6.7.14",
|
||||||
"consola": "3.4.2",
|
"consola": "3.4.2",
|
||||||
"enquirer": "2.4.1",
|
"enquirer": "2.4.1",
|
||||||
"execa": "9.6.0",
|
"execa": "9.6.0",
|
||||||
"kolorist": "1.8.0",
|
"kolorist": "1.8.0",
|
||||||
"npm-check-updates": "18.0.3",
|
"npm-check-updates": "18.1.1",
|
||||||
"picomatch": "4.0.3",
|
"picomatch": "4.0.3",
|
||||||
"rimraf": "6.0.1"
|
"rimraf": "6.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
1734
pnpm-lock.yaml
generated
1734
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
31
src/router/_generated/imports.ts
Normal file
31
src/router/_generated/imports.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
/* oxlint-disable */
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// Generated by elegant-router
|
||||||
|
// Read more: https://github.com/soybeanjs/elegant-router
|
||||||
|
|
||||||
|
import type { RouteFileKey, RouteLayoutKey, RawRouteComponent } from "@elegant-router/types";
|
||||||
|
|
||||||
|
export const layouts: Record<RouteLayoutKey, RawRouteComponent> = {
|
||||||
|
base: () => import("@/layouts/base-layout/index.vue"),
|
||||||
|
blank: () => import("@/layouts/blank-layout/index.vue"),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const views: Record<RouteFileKey, RawRouteComponent> = {
|
||||||
|
403: () => import("@/views/(builtin)/403/index.vue"),
|
||||||
|
404: () => import("@/views/(builtin)/404/index.vue"),
|
||||||
|
500: () => import("@/views/(builtin)/500/index.vue"),
|
||||||
|
Home: () => import("@/views/home/index.vue"),
|
||||||
|
IframeUrl: () => import("@/views/(builtin)/iframe/[url].vue"),
|
||||||
|
Login: () => import("@/views/(builtin)/login/index.vue"),
|
||||||
|
ManageApi: () => import("@/views/manage/api/index.vue"),
|
||||||
|
ManageDictionary: () => import("@/views/manage/dictionary/index.vue"),
|
||||||
|
ManageMenu: () => import("@/views/manage/menu/index.vue"),
|
||||||
|
ManageOrganization: () => import("@/views/manage/organization/index.vue"),
|
||||||
|
ManagePermission: () => import("@/views/manage/permission/index.vue"),
|
||||||
|
ManageRole: () => import("@/views/manage/role/index.vue"),
|
||||||
|
ManageRoute: () => import("@/views/manage/route/index.vue"),
|
||||||
|
ManageUser: () => import("@/views/manage/user/index.vue"),
|
||||||
|
Wip: () => import("@/views/(builtin)/wip/index.vue"),
|
||||||
|
};
|
||||||
166
src/router/_generated/routes.ts
Normal file
166
src/router/_generated/routes.ts
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// Generated by elegant-router
|
||||||
|
// Read more: https://github.com/soybeanjs/elegant-router
|
||||||
|
|
||||||
|
import type { AutoRouterRoute } from '@elegant-router/types';
|
||||||
|
|
||||||
|
export const routes: AutoRouterRoute[] = [
|
||||||
|
{
|
||||||
|
name: 'Root',
|
||||||
|
path: '/',
|
||||||
|
redirect: '/home',
|
||||||
|
meta: {
|
||||||
|
title: "Root"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'NotFound',
|
||||||
|
path: '/:pathMatch(.*)*',
|
||||||
|
layout: 'base',
|
||||||
|
component: '404',
|
||||||
|
meta: {
|
||||||
|
title: "NotFound"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '403',
|
||||||
|
path: '/403',
|
||||||
|
layout: 'base',
|
||||||
|
component: '403',
|
||||||
|
meta: {
|
||||||
|
title: "403",
|
||||||
|
constant: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '404',
|
||||||
|
path: '/404',
|
||||||
|
layout: 'base',
|
||||||
|
component: '404',
|
||||||
|
meta: {
|
||||||
|
title: "404",
|
||||||
|
constant: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '500',
|
||||||
|
path: '/500',
|
||||||
|
layout: 'base',
|
||||||
|
component: '500',
|
||||||
|
meta: {
|
||||||
|
title: "500",
|
||||||
|
constant: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Home',
|
||||||
|
path: '/home',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'Home',
|
||||||
|
meta: {
|
||||||
|
title: "Home"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'IframeUrl',
|
||||||
|
path: '/iframe/:url',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'IframeUrl',
|
||||||
|
meta: {
|
||||||
|
title: "IframeUrl"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Login',
|
||||||
|
path: '/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'Login',
|
||||||
|
meta: {
|
||||||
|
title: "Login",
|
||||||
|
constant: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageApi',
|
||||||
|
path: '/manage/api',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageApi',
|
||||||
|
meta: {
|
||||||
|
title: "ManageApi"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageDictionary',
|
||||||
|
path: '/manage/dictionary',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageDictionary',
|
||||||
|
meta: {
|
||||||
|
title: "ManageDictionary"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageMenu',
|
||||||
|
path: '/manage/menu',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageMenu',
|
||||||
|
meta: {
|
||||||
|
title: "ManageMenu"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageOrganization',
|
||||||
|
path: '/manage/organization',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageOrganization',
|
||||||
|
meta: {
|
||||||
|
title: "ManageOrganization"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManagePermission',
|
||||||
|
path: '/manage/permission',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManagePermission',
|
||||||
|
meta: {
|
||||||
|
title: "ManagePermission"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageRole',
|
||||||
|
path: '/manage/role',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageRole',
|
||||||
|
meta: {
|
||||||
|
title: "ManageRole"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageRoute',
|
||||||
|
path: '/manage/route',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageRoute',
|
||||||
|
meta: {
|
||||||
|
title: "ManageRoute"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ManageUser',
|
||||||
|
path: '/manage/user',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'ManageUser',
|
||||||
|
meta: {
|
||||||
|
title: "ManageUser"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Wip',
|
||||||
|
path: '/wip',
|
||||||
|
layout: 'base',
|
||||||
|
component: 'Wip',
|
||||||
|
meta: {
|
||||||
|
title: "Wip"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
32
src/router/_generated/shared.ts
Normal file
32
src/router/_generated/shared.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
/* oxlint-disable */
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// Generated by elegant-router
|
||||||
|
// Read more: https://github.com/soybeanjs/elegant-router
|
||||||
|
|
||||||
|
import type { RouteKey, RoutePathMap } from '@elegant-router/types';
|
||||||
|
|
||||||
|
const routePathMap: RoutePathMap = {
|
||||||
|
"Root": "/",
|
||||||
|
"NotFound": "/:pathMatch(.*)*",
|
||||||
|
"403": "/403",
|
||||||
|
"404": "/404",
|
||||||
|
"500": "/500",
|
||||||
|
"Home": "/home",
|
||||||
|
"IframeUrl": "/iframe/:url",
|
||||||
|
"Login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?",
|
||||||
|
"ManageApi": "/manage/api",
|
||||||
|
"ManageDictionary": "/manage/dictionary",
|
||||||
|
"ManageMenu": "/manage/menu",
|
||||||
|
"ManageOrganization": "/manage/organization",
|
||||||
|
"ManagePermission": "/manage/permission",
|
||||||
|
"ManageRole": "/manage/role",
|
||||||
|
"ManageRoute": "/manage/route",
|
||||||
|
"ManageUser": "/manage/user",
|
||||||
|
"Wip": "/wip",
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getRoutePath(key: RouteKey) {
|
||||||
|
return routePathMap[key];
|
||||||
|
}
|
||||||
70
src/router/_generated/transformer.ts
Normal file
70
src/router/_generated/transformer.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
/* oxlint-disable */
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// Generated by elegant-router
|
||||||
|
// Read more: https://github.com/soybeanjs/elegant-router
|
||||||
|
|
||||||
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
import type {
|
||||||
|
AutoRouterRedirect,
|
||||||
|
AutoRouterRoute,
|
||||||
|
AutoRouterSingleView,
|
||||||
|
RawRouteComponent,
|
||||||
|
RouteFileKey,
|
||||||
|
RouteLayoutKey
|
||||||
|
} from '@elegant-router/types';
|
||||||
|
|
||||||
|
export function transformToVueRoutes(
|
||||||
|
routes: AutoRouterRoute[],
|
||||||
|
layouts: Record<RouteLayoutKey, RawRouteComponent>,
|
||||||
|
views: Record<RouteFileKey, RawRouteComponent>
|
||||||
|
) {
|
||||||
|
const { redirects, groupedRoutes } = getFormattedRoutes(routes);
|
||||||
|
|
||||||
|
const vueRoutes: RouteRecordRaw[] = [...redirects];
|
||||||
|
|
||||||
|
groupedRoutes.forEach((items, layout) => {
|
||||||
|
const layoutRoute: RouteRecordRaw = {
|
||||||
|
path: `/${layout}-layout`,
|
||||||
|
component: layouts[layout],
|
||||||
|
children: items.map(item => {
|
||||||
|
const { layout: _, component, ...rest } = item;
|
||||||
|
|
||||||
|
return {
|
||||||
|
component: views[component],
|
||||||
|
...rest
|
||||||
|
};
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
vueRoutes.push(layoutRoute);
|
||||||
|
});
|
||||||
|
|
||||||
|
return vueRoutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFormattedRoutes(routes: AutoRouterRoute[]) {
|
||||||
|
const groupedRoutes = new Map<RouteLayoutKey, AutoRouterSingleView[]>();
|
||||||
|
const redirects: AutoRouterRedirect[] = [];
|
||||||
|
|
||||||
|
routes.forEach(route => {
|
||||||
|
if (isAutoRouterRedirect(route)) {
|
||||||
|
redirects.push(route);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const items = groupedRoutes.get(route.layout) || [];
|
||||||
|
items.push(route);
|
||||||
|
groupedRoutes.set(route.layout, items);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
redirects,
|
||||||
|
groupedRoutes
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAutoRouterRedirect(route: AutoRouterRoute): route is AutoRouterRedirect {
|
||||||
|
return 'redirect' in route;
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* prettier-ignore */
|
|
||||||
// Generated by elegant-router
|
|
||||||
// Read more: https://github.com/soybeanjs/elegant-router
|
|
||||||
|
|
||||||
import type { RouteComponent } from "vue-router";
|
|
||||||
import type { LastLevelRouteKey, RouteLayout } from "@elegant-router/types";
|
|
||||||
|
|
||||||
import BaseLayout from "@/layouts/base-layout/index.vue";
|
|
||||||
import BlankLayout from "@/layouts/blank-layout/index.vue";
|
|
||||||
|
|
||||||
export const layouts: Record<RouteLayout, RouteComponent | (() => Promise<RouteComponent>)> = {
|
|
||||||
base: BaseLayout,
|
|
||||||
blank: BlankLayout,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<RouteComponent>)> = {
|
|
||||||
403: () => import("@/views/_builtin/403/index.vue"),
|
|
||||||
404: () => import("@/views/_builtin/404/index.vue"),
|
|
||||||
500: () => import("@/views/_builtin/500/index.vue"),
|
|
||||||
"iframe-page": () => import("@/views/_builtin/iframe-page/[url].vue"),
|
|
||||||
login: () => import("@/views/_builtin/login/index.vue"),
|
|
||||||
home: () => import("@/views/home/index.vue"),
|
|
||||||
};
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* prettier-ignore */
|
|
||||||
// Generated by elegant-router
|
|
||||||
// Read more: https://github.com/soybeanjs/elegant-router
|
|
||||||
|
|
||||||
import type { GeneratedRoute } from '@elegant-router/types';
|
|
||||||
|
|
||||||
export const generatedRoutes: GeneratedRoute[] = [
|
|
||||||
{
|
|
||||||
name: '403',
|
|
||||||
path: '/403',
|
|
||||||
component: 'layout.blank$view.403',
|
|
||||||
meta: {
|
|
||||||
title: '403',
|
|
||||||
i18nKey: 'route.403',
|
|
||||||
constant: true,
|
|
||||||
hideInMenu: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '404',
|
|
||||||
path: '/404',
|
|
||||||
component: 'layout.blank$view.404',
|
|
||||||
meta: {
|
|
||||||
title: '404',
|
|
||||||
i18nKey: 'route.404',
|
|
||||||
constant: true,
|
|
||||||
hideInMenu: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '500',
|
|
||||||
path: '/500',
|
|
||||||
component: 'layout.blank$view.500',
|
|
||||||
meta: {
|
|
||||||
title: '500',
|
|
||||||
i18nKey: 'route.500',
|
|
||||||
constant: true,
|
|
||||||
hideInMenu: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'home',
|
|
||||||
path: '/home',
|
|
||||||
component: 'layout.base$view.home',
|
|
||||||
meta: {
|
|
||||||
title: 'home',
|
|
||||||
i18nKey: 'route.home',
|
|
||||||
icon: 'mdi:monitor-dashboard',
|
|
||||||
order: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'iframe-page',
|
|
||||||
path: '/iframe-page/:url',
|
|
||||||
component: 'layout.base$view.iframe-page',
|
|
||||||
props: true,
|
|
||||||
meta: {
|
|
||||||
title: 'iframe-page',
|
|
||||||
i18nKey: 'route.iframe-page',
|
|
||||||
constant: true,
|
|
||||||
hideInMenu: true,
|
|
||||||
keepAlive: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'login',
|
|
||||||
path: '/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?',
|
|
||||||
component: 'layout.blank$view.login',
|
|
||||||
props: true,
|
|
||||||
meta: {
|
|
||||||
title: 'login',
|
|
||||||
i18nKey: 'route.login',
|
|
||||||
constant: true,
|
|
||||||
hideInMenu: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* prettier-ignore */
|
|
||||||
// Generated by elegant-router
|
|
||||||
// Read more: https://github.com/soybeanjs/elegant-router
|
|
||||||
|
|
||||||
import type { RouteRecordRaw, RouteComponent } from 'vue-router';
|
|
||||||
import type { ElegantConstRoute } from '@elegant-router/vue';
|
|
||||||
import type { RouteMap, RouteKey, RoutePath } from '@elegant-router/types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* transform elegant const routes to vue routes
|
|
||||||
* @param routes elegant const routes
|
|
||||||
* @param layouts layout components
|
|
||||||
* @param views view components
|
|
||||||
*/
|
|
||||||
export function transformElegantRoutesToVueRoutes(
|
|
||||||
routes: ElegantConstRoute[],
|
|
||||||
layouts: Record<string, RouteComponent | (() => Promise<RouteComponent>)>,
|
|
||||||
views: Record<string, RouteComponent | (() => Promise<RouteComponent>)>
|
|
||||||
) {
|
|
||||||
return routes.flatMap(route => transformElegantRouteToVueRoute(route, layouts, views));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* transform elegant route to vue route
|
|
||||||
* @param route elegant const route
|
|
||||||
* @param layouts layout components
|
|
||||||
* @param views view components
|
|
||||||
*/
|
|
||||||
function transformElegantRouteToVueRoute(
|
|
||||||
route: ElegantConstRoute,
|
|
||||||
layouts: Record<string, RouteComponent | (() => Promise<RouteComponent>)>,
|
|
||||||
views: Record<string, RouteComponent | (() => Promise<RouteComponent>)>
|
|
||||||
) {
|
|
||||||
const LAYOUT_PREFIX = 'layout.';
|
|
||||||
const VIEW_PREFIX = 'view.';
|
|
||||||
const ROUTE_DEGREE_SPLITTER = '_';
|
|
||||||
const FIRST_LEVEL_ROUTE_COMPONENT_SPLIT = '$';
|
|
||||||
|
|
||||||
function isLayout(component: string) {
|
|
||||||
return component.startsWith(LAYOUT_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLayoutName(component: string) {
|
|
||||||
const layout = component.replace(LAYOUT_PREFIX, '');
|
|
||||||
|
|
||||||
if(!layouts[layout]) {
|
|
||||||
throw new Error(`Layout component "${layout}" not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isView(component: string) {
|
|
||||||
return component.startsWith(VIEW_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getViewName(component: string) {
|
|
||||||
const view = component.replace(VIEW_PREFIX, '');
|
|
||||||
|
|
||||||
if(!views[view]) {
|
|
||||||
throw new Error(`View component "${view}" not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isFirstLevelRoute(item: ElegantConstRoute) {
|
|
||||||
return !item.name.includes(ROUTE_DEGREE_SPLITTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isSingleLevelRoute(item: ElegantConstRoute) {
|
|
||||||
return isFirstLevelRoute(item) && !item.children?.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSingleLevelRouteComponent(component: string) {
|
|
||||||
const [layout, view] = component.split(FIRST_LEVEL_ROUTE_COMPONENT_SPLIT);
|
|
||||||
|
|
||||||
return {
|
|
||||||
layout: getLayoutName(layout),
|
|
||||||
view: getViewName(view)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const vueRoutes: RouteRecordRaw[] = [];
|
|
||||||
|
|
||||||
// add props: true to route
|
|
||||||
if (route.path.includes(':') && !route.props) {
|
|
||||||
route.props = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { name, path, component, children, ...rest } = route;
|
|
||||||
|
|
||||||
const vueRoute = { name, path, ...rest } as RouteRecordRaw;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (component) {
|
|
||||||
if (isSingleLevelRoute(route)) {
|
|
||||||
const { layout, view } = getSingleLevelRouteComponent(component);
|
|
||||||
|
|
||||||
const singleLevelRoute: RouteRecordRaw = {
|
|
||||||
path,
|
|
||||||
component: layouts[layout],
|
|
||||||
meta: {
|
|
||||||
title: route.meta?.title || ''
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
name,
|
|
||||||
path: '',
|
|
||||||
component: views[view],
|
|
||||||
...rest
|
|
||||||
} as RouteRecordRaw
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
return [singleLevelRoute];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLayout(component)) {
|
|
||||||
const layoutName = getLayoutName(component);
|
|
||||||
|
|
||||||
vueRoute.component = layouts[layoutName];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isView(component)) {
|
|
||||||
const viewName = getViewName(component);
|
|
||||||
|
|
||||||
vueRoute.component = views[viewName];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error(`Error transforming route "${route.name}": ${error.toString()}`);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// add redirect to child
|
|
||||||
if (children?.length && !vueRoute.redirect) {
|
|
||||||
vueRoute.redirect = {
|
|
||||||
name: children[0].name
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (children?.length) {
|
|
||||||
const childRoutes = children.flatMap(child => transformElegantRouteToVueRoute(child, layouts, views));
|
|
||||||
|
|
||||||
if(isFirstLevelRoute(route)) {
|
|
||||||
vueRoute.children = childRoutes;
|
|
||||||
} else {
|
|
||||||
vueRoutes.push(...childRoutes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vueRoutes.unshift(vueRoute);
|
|
||||||
|
|
||||||
return vueRoutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* map of route name and route path
|
|
||||||
*/
|
|
||||||
const routeMap: RouteMap = {
|
|
||||||
"root": "/",
|
|
||||||
"not-found": "/:pathMatch(.*)*",
|
|
||||||
"403": "/403",
|
|
||||||
"404": "/404",
|
|
||||||
"500": "/500",
|
|
||||||
"home": "/home",
|
|
||||||
"iframe-page": "/iframe-page/:url",
|
|
||||||
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?"
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get route path by route name
|
|
||||||
* @param name route name
|
|
||||||
*/
|
|
||||||
export function getRoutePath<T extends RouteKey>(name: T) {
|
|
||||||
return routeMap[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get route name by route path
|
|
||||||
* @param path route path
|
|
||||||
*/
|
|
||||||
export function getRouteName(path: RoutePath) {
|
|
||||||
const routeEntries = Object.entries(routeMap) as [RouteKey, RoutePath][];
|
|
||||||
|
|
||||||
const routeName: RouteKey | null = routeEntries.find(([, routePath]) => routePath === path)?.[0] || null;
|
|
||||||
|
|
||||||
return routeName;
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
import {
|
import { createMemoryHistory, createRouter, createWebHashHistory, createWebHistory } from 'vue-router';
|
||||||
type RouterHistory,
|
import type { RouterHistory } from 'vue-router';
|
||||||
createMemoryHistory,
|
|
||||||
createRouter,
|
|
||||||
createWebHashHistory,
|
|
||||||
createWebHistory
|
|
||||||
} from 'vue-router';
|
|
||||||
import { createBuiltinVueRoutes } from './routes/builtin';
|
|
||||||
import { createRouterGuard } from './guard';
|
import { createRouterGuard } from './guard';
|
||||||
|
|
||||||
const { VITE_ROUTER_HISTORY_MODE = 'history', VITE_BASE_URL } = import.meta.env;
|
const { VITE_ROUTER_HISTORY_MODE = 'history', VITE_BASE_URL } = import.meta.env;
|
||||||
@@ -19,7 +13,7 @@ const historyCreatorMap: Record<Env.RouterHistoryMode, (base?: string) => Router
|
|||||||
|
|
||||||
export const router = createRouter({
|
export const router = createRouter({
|
||||||
history: historyCreatorMap[VITE_ROUTER_HISTORY_MODE](VITE_BASE_URL),
|
history: historyCreatorMap[VITE_ROUTER_HISTORY_MODE](VITE_BASE_URL),
|
||||||
routes: createBuiltinVueRoutes()
|
routes: []
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Setup Vue Router */
|
/** Setup Vue Router */
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import type { CustomRoute } from '@elegant-router/types';
|
|
||||||
import { layouts, views } from '../elegant/imports';
|
|
||||||
import { getRoutePath, transformElegantRoutesToVueRoutes } from '../elegant/transform';
|
|
||||||
|
|
||||||
export const ROOT_ROUTE: CustomRoute = {
|
|
||||||
name: 'root',
|
|
||||||
path: '/',
|
|
||||||
redirect: getRoutePath(import.meta.env.VITE_ROUTE_HOME) || '/home',
|
|
||||||
meta: {
|
|
||||||
title: 'root',
|
|
||||||
constant: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const NOT_FOUND_ROUTE: CustomRoute = {
|
|
||||||
name: 'not-found',
|
|
||||||
path: '/:pathMatch(.*)*',
|
|
||||||
component: 'layout.blank$view.404',
|
|
||||||
meta: {
|
|
||||||
title: 'not-found',
|
|
||||||
constant: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** builtin routes, it must be constant and setup in vue-router */
|
|
||||||
const builtinRoutes: CustomRoute[] = [ROOT_ROUTE, NOT_FOUND_ROUTE];
|
|
||||||
|
|
||||||
/** create builtin vue routes */
|
|
||||||
export function createBuiltinVueRoutes() {
|
|
||||||
return transformElegantRoutesToVueRoutes(builtinRoutes, layouts, views);
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,14 @@
|
|||||||
import type { CustomRoute, ElegantConstRoute, ElegantRoute } from '@elegant-router/types';
|
import type { AutoRouterRoute } from '@elegant-router/types';
|
||||||
import { generatedRoutes } from '../elegant/routes';
|
import { routes } from '../_generated/routes';
|
||||||
import { layouts, views } from '../elegant/imports';
|
import { layouts, views } from '../_generated/imports';
|
||||||
import { transformElegantRoutesToVueRoutes } from '../elegant/transform';
|
import { transformToVueRoutes } from '../_generated/transformer';
|
||||||
|
|
||||||
/**
|
|
||||||
* custom routes
|
|
||||||
*
|
|
||||||
* @link https://github.com/soybeanjs/elegant-router?tab=readme-ov-file#custom-route
|
|
||||||
*/
|
|
||||||
const customRoutes: CustomRoute[] = [];
|
|
||||||
|
|
||||||
/** create routes when the auth route mode is static */
|
/** create routes when the auth route mode is static */
|
||||||
export function createStaticRoutes() {
|
export function createStaticRoutes() {
|
||||||
const constantRoutes: ElegantRoute[] = [];
|
const constantRoutes: AutoRouterRoute[] = [];
|
||||||
|
const authRoutes: AutoRouterRoute[] = [];
|
||||||
|
|
||||||
const authRoutes: ElegantRoute[] = [];
|
routes.forEach(item => {
|
||||||
|
|
||||||
[...customRoutes, ...generatedRoutes].forEach(item => {
|
|
||||||
if (item.meta?.constant) {
|
if (item.meta?.constant) {
|
||||||
constantRoutes.push(item);
|
constantRoutes.push(item);
|
||||||
} else {
|
} else {
|
||||||
@@ -33,8 +25,8 @@ export function createStaticRoutes() {
|
|||||||
/**
|
/**
|
||||||
* Get auth vue routes
|
* Get auth vue routes
|
||||||
*
|
*
|
||||||
* @param routes Elegant routes
|
* @param authRoutes Elegant routes
|
||||||
*/
|
*/
|
||||||
export function getAuthVueRoutes(routes: ElegantConstRoute[]) {
|
export function getAuthVueRoutes(authRoutes: AutoRouterRoute[]) {
|
||||||
return transformElegantRoutesToVueRoutes(routes, layouts, views);
|
return transformToVueRoutes(authRoutes, layouts, views);
|
||||||
}
|
}
|
||||||
|
|||||||
240
src/typings/elegant-router.d.ts
vendored
240
src/typings/elegant-router.d.ts
vendored
@@ -1,240 +1,104 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/* prettier-ignore */
|
/* prettier-ignore */
|
||||||
|
/* oxlint-disable */
|
||||||
|
// biome-ignore lint: disable
|
||||||
// Generated by elegant-router
|
// Generated by elegant-router
|
||||||
// Read more: https://github.com/soybeanjs/elegant-router
|
// Read more: https://github.com/soybeanjs/elegant-router
|
||||||
|
|
||||||
declare module "@elegant-router/types" {
|
declare module "@elegant-router/types" {
|
||||||
type ElegantConstRoute = import('@elegant-router/vue').ElegantConstRoute;
|
type RouteRecordSingleView = import("vue-router").RouteRecordSingleView;
|
||||||
|
type RouteRecordRedirect = import("vue-router").RouteRecordRedirect;
|
||||||
|
type RouteComponent = import("vue-router").RouteComponent;
|
||||||
|
|
||||||
|
type Lazy<T> = () => Promise<T>;
|
||||||
|
|
||||||
|
export type RawRouteComponent = RouteComponent | Lazy<RouteComponent>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* route layout
|
* route layout key
|
||||||
*/
|
*/
|
||||||
export type RouteLayout = "base" | "blank";
|
export type RouteLayoutKey = "base" | "blank";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* route map
|
* route path map
|
||||||
*/
|
*/
|
||||||
export type RouteMap = {
|
export type RoutePathMap = {
|
||||||
"root": "/";
|
"Root": "/";
|
||||||
"not-found": "/:pathMatch(.*)*";
|
"NotFound": "/:pathMatch(.*)*";
|
||||||
"403": "/403";
|
"403": "/403";
|
||||||
"404": "/404";
|
"404": "/404";
|
||||||
"500": "/500";
|
"500": "/500";
|
||||||
"home": "/home";
|
"Home": "/home";
|
||||||
"iframe-page": "/iframe-page/:url";
|
"IframeUrl": "/iframe/:url";
|
||||||
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
|
"Login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
|
||||||
|
"ManageApi": "/manage/api";
|
||||||
|
"ManageDictionary": "/manage/dictionary";
|
||||||
|
"ManageMenu": "/manage/menu";
|
||||||
|
"ManageOrganization": "/manage/organization";
|
||||||
|
"ManagePermission": "/manage/permission";
|
||||||
|
"ManageRole": "/manage/role";
|
||||||
|
"ManageRoute": "/manage/route";
|
||||||
|
"ManageUser": "/manage/user";
|
||||||
|
"Wip": "/wip";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* route key
|
* route key
|
||||||
*/
|
*/
|
||||||
export type RouteKey = keyof RouteMap;
|
export type RouteKey = keyof RoutePathMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* route path
|
* route path
|
||||||
*/
|
*/
|
||||||
export type RoutePath = RouteMap[RouteKey];
|
export type RoutePath = RoutePathMap[RouteKey];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* custom route key
|
* root route key
|
||||||
*/
|
*/
|
||||||
export type CustomRouteKey = Extract<
|
export type RootRouteKey = 'Root';
|
||||||
RouteKey,
|
|
||||||
| "root"
|
|
||||||
| "not-found"
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the generated route key
|
* not found route key
|
||||||
*/
|
*/
|
||||||
export type GeneratedRouteKey = Exclude<RouteKey, CustomRouteKey>;
|
export type NotFoundRouteKey = 'NotFound';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the first level route key, which contain the layout of the route
|
* builtin route key
|
||||||
*/
|
*/
|
||||||
export type FirstLevelRouteKey = Extract<
|
export type BuiltinRouteKey = RootRouteKey | NotFoundRouteKey;
|
||||||
RouteKey,
|
|
||||||
| "403"
|
|
||||||
| "404"
|
|
||||||
| "500"
|
|
||||||
| "home"
|
|
||||||
| "iframe-page"
|
|
||||||
| "login"
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the custom first level route key
|
* reuse route key
|
||||||
*/
|
*/
|
||||||
export type CustomFirstLevelRouteKey = Extract<
|
export type ReuseRouteKey = never;
|
||||||
CustomRouteKey,
|
|
||||||
| "root"
|
|
||||||
| "not-found"
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the last level route key, which has the page file
|
* the route file key, which has it's own file
|
||||||
*/
|
*/
|
||||||
export type LastLevelRouteKey = Extract<
|
export type RouteFileKey = Exclude<RouteKey, BuiltinRouteKey | ReuseRouteKey>;
|
||||||
RouteKey,
|
|
||||||
| "403"
|
|
||||||
| "404"
|
|
||||||
| "500"
|
|
||||||
| "iframe-page"
|
|
||||||
| "login"
|
|
||||||
| "home"
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the custom last level route key
|
* mapped name and path
|
||||||
*/
|
*/
|
||||||
export type CustomLastLevelRouteKey = Extract<
|
type MappedNamePath = {
|
||||||
CustomRouteKey,
|
[K in RouteKey]: { name: K; path: RoutePathMap[K] };
|
||||||
| "root"
|
}[RouteKey];
|
||||||
| "not-found"
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the single level route key
|
* auto router single view
|
||||||
*/
|
*/
|
||||||
export type SingleLevelRouteKey = FirstLevelRouteKey & LastLevelRouteKey;
|
export type AutoRouterSingleView = Omit<RouteRecordSingleView, 'component' | 'name' | 'path'> & {
|
||||||
|
component: RouteFileKey;
|
||||||
|
layout: RouteLayoutKey;
|
||||||
|
} & MappedNamePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the custom single level route key
|
* auto router redirect
|
||||||
*/
|
*/
|
||||||
export type CustomSingleLevelRouteKey = CustomFirstLevelRouteKey & CustomLastLevelRouteKey;
|
export type AutoRouterRedirect = Omit<RouteRecordRedirect, 'children' | 'name' | 'path'> & MappedNamePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the first level route key, but not the single level
|
* auto router route
|
||||||
*/
|
|
||||||
export type FirstLevelRouteNotSingleKey = Exclude<FirstLevelRouteKey, SingleLevelRouteKey>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom first level route key, but not the single level
|
|
||||||
*/
|
*/
|
||||||
export type CustomFirstLevelRouteNotSingleKey = Exclude<CustomFirstLevelRouteKey, CustomSingleLevelRouteKey>;
|
export type AutoRouterRoute = AutoRouterSingleView | AutoRouterRedirect;
|
||||||
|
|
||||||
/**
|
|
||||||
* the center level route key
|
|
||||||
*/
|
|
||||||
export type CenterLevelRouteKey = Exclude<GeneratedRouteKey, FirstLevelRouteKey | LastLevelRouteKey>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom center level route key
|
|
||||||
*/
|
|
||||||
export type CustomCenterLevelRouteKey = Exclude<CustomRouteKey, CustomFirstLevelRouteKey | CustomLastLevelRouteKey>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the center level route key
|
|
||||||
*/
|
|
||||||
type GetChildRouteKey<K extends RouteKey, T extends RouteKey = RouteKey> = T extends `${K}_${infer R}`
|
|
||||||
? R extends `${string}_${string}`
|
|
||||||
? never
|
|
||||||
: T
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the single level route
|
|
||||||
*/
|
|
||||||
type SingleLevelRoute<K extends SingleLevelRouteKey = SingleLevelRouteKey> = K extends string
|
|
||||||
? Omit<ElegantConstRoute, 'children'> & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
component: `layout.${RouteLayout}$view.${K}`;
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the last level route
|
|
||||||
*/
|
|
||||||
type LastLevelRoute<K extends GeneratedRouteKey> = K extends LastLevelRouteKey
|
|
||||||
? Omit<ElegantConstRoute, 'children'> & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
component: `view.${K}`;
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the center level route
|
|
||||||
*/
|
|
||||||
type CenterLevelRoute<K extends GeneratedRouteKey> = K extends CenterLevelRouteKey
|
|
||||||
? Omit<ElegantConstRoute, 'component'> & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
children: (CenterLevelRoute<GetChildRouteKey<K>> | LastLevelRoute<GetChildRouteKey<K>>)[];
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the multi level route
|
|
||||||
*/
|
|
||||||
type MultiLevelRoute<K extends FirstLevelRouteNotSingleKey = FirstLevelRouteNotSingleKey> = K extends string
|
|
||||||
? ElegantConstRoute & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
component: `layout.${RouteLayout}`;
|
|
||||||
children: (CenterLevelRoute<GetChildRouteKey<K>> | LastLevelRoute<GetChildRouteKey<K>>)[];
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom first level route
|
|
||||||
*/
|
|
||||||
type CustomSingleLevelRoute<K extends CustomFirstLevelRouteKey = CustomFirstLevelRouteKey> = K extends string
|
|
||||||
? Omit<ElegantConstRoute, 'children'> & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
component?: `layout.${RouteLayout}$view.${LastLevelRouteKey}`;
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom last level route
|
|
||||||
*/
|
|
||||||
type CustomLastLevelRoute<K extends CustomRouteKey> = K extends CustomLastLevelRouteKey
|
|
||||||
? Omit<ElegantConstRoute, 'children'> & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
component?: `view.${LastLevelRouteKey}`;
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom center level route
|
|
||||||
*/
|
|
||||||
type CustomCenterLevelRoute<K extends CustomRouteKey> = K extends CustomCenterLevelRouteKey
|
|
||||||
? Omit<ElegantConstRoute, 'component'> & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
children: (CustomCenterLevelRoute<GetChildRouteKey<K>> | CustomLastLevelRoute<GetChildRouteKey<K>>)[];
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom multi level route
|
|
||||||
*/
|
|
||||||
type CustomMultiLevelRoute<K extends CustomFirstLevelRouteNotSingleKey = CustomFirstLevelRouteNotSingleKey> =
|
|
||||||
K extends string
|
|
||||||
? ElegantConstRoute & {
|
|
||||||
name: K;
|
|
||||||
path: RouteMap[K];
|
|
||||||
component: `layout.${RouteLayout}`;
|
|
||||||
children: (CustomCenterLevelRoute<GetChildRouteKey<K>> | CustomLastLevelRoute<GetChildRouteKey<K>>)[];
|
|
||||||
}
|
|
||||||
: never;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the custom route
|
|
||||||
*/
|
|
||||||
type CustomRoute = CustomSingleLevelRoute | CustomMultiLevelRoute;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the generated route
|
|
||||||
*/
|
|
||||||
type GeneratedRoute = SingleLevelRoute | MultiLevelRoute;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the elegant route
|
|
||||||
*/
|
|
||||||
type ElegantRoute = GeneratedRoute | CustomRoute;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/typings/router.d.ts
vendored
4
src/typings/router.d.ts
vendored
@@ -1,7 +1,7 @@
|
|||||||
import 'vue-router';
|
export {};
|
||||||
|
|
||||||
declare module 'vue-router' {
|
declare module 'vue-router' {
|
||||||
interface RouteMeta {
|
export interface RouteMeta {
|
||||||
/**
|
/**
|
||||||
* Title of the route
|
* Title of the route
|
||||||
*
|
*
|
||||||
|
|||||||
44
src/typings/typed-router.d.ts
vendored
Normal file
44
src/typings/typed-router.d.ts
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
/* prettier-ignore */
|
||||||
|
/* oxlint-disable */
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// Generated by elegant-router
|
||||||
|
// Read more: https://github.com/soybeanjs/elegant-router
|
||||||
|
|
||||||
|
export {}
|
||||||
|
|
||||||
|
declare module "vue-router" {
|
||||||
|
type RouteNamedMap = import("vue-router/auto-routes").RouteNamedMap;
|
||||||
|
|
||||||
|
export interface TypesConfig {
|
||||||
|
RouteNamedMap: RouteNamedMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "vue-router/auto-routes" {
|
||||||
|
import type { RouteParamsRawGeneric, RouteParamsGeneric, RouteMeta, RouteRecordInfo, ParamValue, ParamValueZeroOrOne } from "vue-router";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* route named map
|
||||||
|
*/
|
||||||
|
export interface RouteNamedMap {
|
||||||
|
"Root": RouteRecordInfo<"Root", "/", Record<never, never>, Record<never, never>>;
|
||||||
|
"NotFound": RouteRecordInfo<"NotFound", "/:pathMatch(.*)*", Record<never, never>, Record<never, never>>;
|
||||||
|
"403": RouteRecordInfo<"403", "/403", Record<never, never>, Record<never, never>>;
|
||||||
|
"404": RouteRecordInfo<"404", "/404", Record<never, never>, Record<never, never>>;
|
||||||
|
"500": RouteRecordInfo<"500", "/500", Record<never, never>, Record<never, never>>;
|
||||||
|
"Home": RouteRecordInfo<"Home", "/home", Record<never, never>, Record<never, never>>;
|
||||||
|
"IframeUrl": RouteRecordInfo<"IframeUrl", "/iframe/:url", { url: ParamValue<true> }, { url: ParamValue<false> }>;
|
||||||
|
"Login": RouteRecordInfo<"Login", "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?", { module?: ParamValueZeroOrOne<true> }, { module?: ParamValueZeroOrOne<false> }>;
|
||||||
|
"ManageApi": RouteRecordInfo<"ManageApi", "/manage/api", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManageDictionary": RouteRecordInfo<"ManageDictionary", "/manage/dictionary", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManageMenu": RouteRecordInfo<"ManageMenu", "/manage/menu", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManageOrganization": RouteRecordInfo<"ManageOrganization", "/manage/organization", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManagePermission": RouteRecordInfo<"ManagePermission", "/manage/permission", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManageRole": RouteRecordInfo<"ManageRole", "/manage/role", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManageRoute": RouteRecordInfo<"ManageRoute", "/manage/route", Record<never, never>, Record<never, never>>;
|
||||||
|
"ManageUser": RouteRecordInfo<"ManageUser", "/manage/user", Record<never, never>, Record<never, never>>;
|
||||||
|
"Wip": RouteRecordInfo<"Wip", "/wip", Record<never, never>, Record<never, never>>
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/views/(builtin)/wip/index.vue
Normal file
5
src/views/(builtin)/wip/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<LookForward />
|
||||||
|
</template>
|
||||||
5
src/views/manage/api/index.vue
Normal file
5
src/views/manage/api/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageApi</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/dictionary/index.vue
Normal file
5
src/views/manage/dictionary/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageDictionary</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/menu/index.vue
Normal file
5
src/views/manage/menu/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageMenu</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/organization/index.vue
Normal file
5
src/views/manage/organization/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageOrganization</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/permission/index.vue
Normal file
5
src/views/manage/permission/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManagePermission</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/role/index.vue
Normal file
5
src/views/manage/role/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageRole</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/route/index.vue
Normal file
5
src/views/manage/route/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageRoute</div>
|
||||||
|
</template>
|
||||||
5
src/views/manage/user/index.vue
Normal file
5
src/views/manage/user/index.vue
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>ManageUser</div>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user