Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "naive-ui-admin",
"version": "2.0.0",
"type": "module",
"author": {
"name": "Ahjung",
"email": "[email protected]",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const constantRouter: RouteRecordRaw[] = [LoginRoute, RootRoute, Redirect

const router = createRouter({
history: createWebHistory(),
routes: constantRouter,
routes: [...constantRouter, ...asyncRoutes],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里似乎不太妥,asyncRoutes期望是有权限控制的,在路由守卫里面会根据权限动态添加进去

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我再尝试其他处理方式

strict: true,
scrollBehavior: () => ({ left: 0, top: 0 }),
});
Expand Down
20 changes: 7 additions & 13 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { UserConfig, ConfigEnv } from 'vite';
import { loadEnv } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import { resolve } from 'path';
import { wrapperEnv } from './build/utils';
import { createVitePlugins } from './build/vite/plugin';
import { OUTPUT_DIR } from './build/constant';
import { createProxy } from './build/vite/proxy';
import pkg from './package.json';
import { format } from 'date-fns';

const { dependencies, devDependencies, name, version } = pkg;

const __APP_INFO__ = {
Expand All @@ -18,25 +18,19 @@ function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir);
}

export default ({ command, mode }: ConfigEnv): UserConfig => {
export default defineConfig(({ command, mode }) => {
const root = process.cwd();
const env = loadEnv(mode, root);
const viteEnv = wrapperEnv(env);
const { VITE_PUBLIC_PATH, VITE_PORT, VITE_PROXY } = viteEnv;
const isBuild = command === 'build';

return {
base: VITE_PUBLIC_PATH,
esbuild: {},
resolve: {
alias: [
{
find: /\/#\//,
replacement: pathResolve('types') + '/',
},
{
find: '@',
replacement: pathResolve('src') + '/',
},
{ find: /\/#\//, replacement: pathResolve('types') + '/' },
{ find: '@', replacement: pathResolve('src') + '/' },
],
dedupe: ['vue'],
},
Expand All @@ -63,4 +57,4 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
chunkSizeWarningLimit: 2000,
},
};
};
});