Skip to content

Commit fe25ee2

Browse files
committed
chore(app): 优化代码
1 parent 1a2e128 commit fe25ee2

File tree

12 files changed

+30
-124
lines changed

12 files changed

+30
-124
lines changed

config/constant.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
// 应用名
7-
export const APP_TITLE = 'vite-vue3-admin';
7+
export const APP_TITLE = 'Vite-Vue3-Admin';
88

99
// 本地服务端口
1010
export const VITE_PORT = 3000;
@@ -21,7 +21,6 @@ export const MOCK_API_BASE_URL = '/mock/api';
2121
export const MOCK_API_TARGET_URL = 'http://localhost:3000';
2222

2323
// iconfontUrl
24-
// export const ICONFONTURL = '//at.alicdn.com/t/font_2927003_tz5qryon1k.js';
2524
export const ICONFONTURL = '//at.alicdn.com/t/font_3004192_9jmc1z9neiw.js'; // 去色版
2625

2726
// 包依赖分析

config/vite/optimizer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @name configManualChunk
3+
* @description chunk 拆包优化
4+
*/
5+
16
const vendorLibs: { match: string[]; output: string }[] = [
27
{
38
match: ['ant-design-vue'],

config/vite/plugin/autoImport.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @name AutoImportDeps
3+
* @description 按需加载,自动引入依赖
4+
*/
15
import AutoImport from 'unplugin-auto-import/vite';
26

37
export const AutoImportDeps = () =>

config/vite/plugin/component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @name autoRegistryComponents
3+
* @description 按需加载,自动引入组件
4+
*/
15
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
26
import Components from 'unplugin-vue-components/vite';
37

config/vite/plugin/mock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export function configMockPlugin(isBuild: boolean) {
99
ignore: /^\_/,
1010
mockPath: 'mock',
1111
localEnabled: !isBuild,
12-
prodEnabled: isBuild, // 为了演示,线上开启 mock
13-
// 开发环境无需关系
12+
prodEnabled: isBuild, // 为了演示,线上开启 mock,实际开发请关闭,会影响打包体积
13+
// 开发环境无需关心
1414
// injectCode 只受prodEnabled影响
1515
// https://github.com/anncwb/vite-plugin-mock/issues/9
1616
// 下面这段代码会被注入 main.ts

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite Vue3 TypeScript App</title>
7+
<title>Vite-Vue3-Admin</title>
88
</head>
99
<body>
1010
<div id="app"></div>

src/components.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
declare module 'vue' {
66
export interface GlobalComponents {
77
AAlert: typeof import('ant-design-vue/es')['Alert'];
8+
AAvatar: typeof import('ant-design-vue/es')['Avatar'];
89
ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb'];
910
AButton: typeof import('ant-design-vue/es')['Button'];
1011
ACard: typeof import('ant-design-vue/es')['Card'];
@@ -24,9 +25,11 @@ declare module 'vue' {
2425
AMenuItem: typeof import('ant-design-vue/es')['MenuItem'];
2526
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'];
2627
ARangePicker: typeof import('ant-design-vue/es')['RangePicker'];
28+
AResult: typeof import('ant-design-vue/es')['Result'];
2729
ARow: typeof import('ant-design-vue/es')['Row'];
2830
ASelect: typeof import('ant-design-vue/es')['Select'];
2931
ASpace: typeof import('ant-design-vue/es')['Space'];
32+
ASpin: typeof import('ant-design-vue/es')['Spin'];
3033
ATable: typeof import('ant-design-vue/es')['Table'];
3134
Icon: typeof import('./components/Icon/index.vue')['default'];
3235
Modal: typeof import('./components/Modal/index.vue')['default'];

src/components/Upload/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
accept: {
2626
type: String,
2727
default: () => {
28-
return '.sol';
28+
return '.doc';
2929
},
3030
},
3131
size: {
@@ -44,7 +44,7 @@
4444
headers: {
4545
Authorization: localStorage.getItem('x-auth-token'),
4646
},
47-
action: location.origin + '/api/v1/contract/upload',
47+
action: location.origin + '/api/v1/upload',
4848
});
4949
5050
const fileList = ref([]);

src/layouts/BasicLayout/components/Header.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="logo-wrap">
44
<router-link :to="{ path: '/' }">
55
<img :src="logo" class="logo" />
6-
<h1 class="title"> SimpleChain联盟链 </h1>
6+
<h1 class="title"> {{ APP_TITLE }} </h1>
77
<!-- <span class="subTitle">基础版</span> -->
88
</router-link>
99
</div>
@@ -15,6 +15,7 @@
1515
<script setup lang="ts">
1616
import RightContent from './RightContent.vue';
1717
import logo from '/@/assets/images/logo.png';
18+
import { APP_TITLE } from '../../../../config/constant';
1819
</script>
1920
<style lang="less" scoped>
2021
.header {

src/utils/defaultVariable.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/utils/validate.js

Lines changed: 0 additions & 104 deletions
This file was deleted.

vite.config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createVitePlugins } from './config/vite/plugin';
44
import proxy from './config/vite/proxy';
55
import { VITE_DROP_CONSOLE, VITE_PORT } from './config/constant';
66
import { generateModifyVars } from './config/themeConfig';
7+
import { configManualChunk } from './config/vite/optimizer';
78

89
function pathResolve(dir: string) {
910
return resolve(process.cwd(), '.', dir);
@@ -58,11 +59,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
5859
drop_console: VITE_DROP_CONSOLE,
5960
},
6061
},
61-
// rollupOptions: {
62-
// output: {
63-
// manualChunks: configManualChunk,
64-
// },
65-
// },
62+
rollupOptions: {
63+
output: {
64+
manualChunks: configManualChunk,
65+
},
66+
},
6667
// Turning off brotliSize display can slightly reduce packaging time
6768
brotliSize: false,
6869
chunkSizeWarningLimit: 2000,

0 commit comments

Comments
 (0)