diff --git a/.eslintignore b/.eslintignore index c4a92ff39..18ed6bd81 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ !.env-config.ts components.d.ts +router-page.d.ts diff --git a/.gitignore b/.gitignore index 1f0bea9af..872102ee2 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,6 @@ stats.html *.sw? /src/typings/components.d.ts +/src/typings/router-page.d.ts package-lock.json yarn.lock diff --git a/build/plugins/index.ts b/build/plugins/index.ts index 5ca6534c6..67de5b336 100644 --- a/build/plugins/index.ts +++ b/build/plugins/index.ts @@ -9,13 +9,24 @@ import unplugin from './unplugin'; import mock from './mock'; import visualizer from './visualizer'; import compress from './compress'; +import soybeanjs from './soybeanjs'; /** * vite插件 * @param viteEnv - 环境变量配置 */ export function setupVitePlugins(viteEnv: ImportMetaEnv): (PluginOption | PluginOption[])[] { - const plugins = [vue(), vueJsx(), VitePWA(), html(viteEnv), ...unplugin(viteEnv), unocss(), mock, progress()]; + const plugins = [ + vue(), + vueJsx(), + VitePWA(), + html(viteEnv), + ...unplugin(viteEnv), + unocss(), + mock, + progress(), + soybeanjs() + ]; if (viteEnv.VITE_VISUALIZER === 'Y') { plugins.push(visualizer as PluginOption); diff --git a/build/plugins/soybeanjs.ts b/build/plugins/soybeanjs.ts new file mode 100644 index 000000000..3886db11a --- /dev/null +++ b/build/plugins/soybeanjs.ts @@ -0,0 +1,18 @@ +import routerPage from '@soybeanjs/router-page'; + +export default function createSoybeanjsPlugin() { + return routerPage({ + pagesFormatter: names => { + /** 系统的内置路由,该文件夹名称不作为RouteKey */ + const SYSTEM_VIEW = 'system-view'; + + const result = names + .filter(name => name !== SYSTEM_VIEW) + .map(name => { + return name.replace(`${SYSTEM_VIEW}_`, ''); + }); + + return result; + } + }); +} diff --git a/package.json b/package.json index 58ccb16fc..99cb56b77 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "@iconify/json": "^2.1.133", "@iconify/vue": "^4.0.0", "@soybeanjs/cli": "^0.1.2", + "@soybeanjs/router-page": "0.2.0", "@tauri-apps/cli": "^1.1.1", "@types/bmapgl": "^0.0.5", "@types/crypto-js": "^4.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02ce7e01a..68a583937 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,7 @@ specifiers: '@iconify/json': ^2.1.133 '@iconify/vue': ^4.0.0 '@soybeanjs/cli': ^0.1.2 + '@soybeanjs/router-page': 0.2.0 '@soybeanjs/vue-admin-layout': ^1.1.1 '@soybeanjs/vue-admin-tab': ^1.0.5 '@tauri-apps/cli': ^1.1.1 @@ -107,6 +108,7 @@ devDependencies: '@iconify/json': 2.1.133 '@iconify/vue': 4.0.0_vue@3.2.41 '@soybeanjs/cli': 0.1.2 + '@soybeanjs/router-page': 0.2.0 '@tauri-apps/cli': 1.1.1 '@types/bmapgl': 0.0.5 '@types/crypto-js': 4.1.1 @@ -2014,6 +2016,12 @@ packages: prompts: 2.4.2 dev: true + /@soybeanjs/router-page/0.2.0: + resolution: {integrity: sha512-3vZlw3o+AzPS2TrL2zRSxEeNMOXVW48y8VO1RK74d3uG8/6XXxJDhlOFmNqgk/EQ5qDDwW5ofnbj7S3oYGBcFQ==} + dependencies: + fast-glob: 3.2.12 + dev: true + /@soybeanjs/vue-admin-layout/1.1.1_vue@3.2.41: resolution: {integrity: sha512-cWbHsjuDB7QkDuYnxfQETmDxlN19JCffrssz6gab4UMP8fw1WL9qukKE/eWLzZoWFCaVJXE/ODEZb4QQLuMuUw==} peerDependencies: