Skip to content

Commit 74b1983

Browse files
committed
feat(app): 生产环境mock、功能组件、路由完善
1 parent 9160bf6 commit 74b1983

File tree

17 files changed

+71
-242
lines changed

17 files changed

+71
-242
lines changed

config/constant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ 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';
24+
// export const ICONFONTURL = '//at.alicdn.com/t/font_2927003_tz5qryon1k.js';
25+
export const ICONFONTURL = '//at.alicdn.com/t/font_3004192_9jmc1z9neiw.js'; // 去色版
2526

2627
// 包依赖分析
2728
export const ANALYSIS = false;

config/vite/plugin/mock.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ export function configMockPlugin(isBuild: boolean) {
99
ignore: /^\_/,
1010
mockPath: 'mock',
1111
localEnabled: !isBuild,
12-
prodEnabled: true,
12+
prodEnabled: isBuild, // 为了演示,线上开启 mock
13+
// 开发环境无需关系
14+
// injectCode 只受prodEnabled影响
15+
// https://github.com/anncwb/vite-plugin-mock/issues/9
16+
// 下面这段代码会被注入 main.ts
1317
injectCode: `
14-
import { setupProdMockServer } from '../mock/_createProductionServer';
18+
import { setupProdMockServer } from '../mock/_createProdMockServer';
1519
1620
setupProdMockServer();
1721
`,

src/App.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@
99
import zhCN from 'ant-design-vue/es/locale/zh_CN';
1010
import { useTitle } from '/@/hooks/useTitle';
1111
12+
// date-picker 国际化失效问题
13+
// 引入dist下的文件:import 'moment/dist/locale/zh-cn'
14+
// 确保 moment版本一致
15+
import moment from 'moment';
16+
import 'moment/dist/locale/zh-cn';
17+
moment.locale('zh_CN');
18+
1219
useTitle();
1320
</script>

src/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ declare module 'vue' {
2020
AMenu: typeof import('ant-design-vue/es')['Menu'];
2121
AMenuItem: typeof import('ant-design-vue/es')['MenuItem'];
2222
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'];
23+
ARangePicker: typeof import('ant-design-vue/es')['RangePicker'];
2324
AResult: typeof import('ant-design-vue/es')['Result'];
2425
ARow: typeof import('ant-design-vue/es')['Row'];
2526
ASelect: typeof import('ant-design-vue/es')['Select'];

src/components/Table/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
:pagination="pagination"
2020
:loading="loading"
2121
@change="handleTableChange"
22+
:scroll="scroll"
2223
>
2324
<!-- slot 写法自定义 操作列 -->
2425
<!-- <template #[item]="data" v-for="item in Object.keys($slots)" :key="item">
@@ -71,6 +72,7 @@
7172
'items' /* Filter筛选列组件:包含的项 */,
7273
'model' /* Filter筛选列组件:form model */,
7374
'resKey',
75+
'scroll',
7476
],
7577
// emits: ['onSearch'],
7678
setup(props) {

src/enums/authEnum.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,4 @@ export enum AuthEnum {
2424
role_update = '/v1/role/update',
2525
// 删除角色
2626
role_delete = '/v1/role/delete',
27-
28-
/**
29-
* 合约管理
30-
*/
31-
// 新增合约
32-
contract_create = '/v1/contract/deploy',
33-
// 查看详情
34-
contract_detail = '/v1/contract/detail',
35-
36-
/**
37-
* 浏览器
38-
*/
39-
// 区块信息
40-
explorer_blockList = '/v1/explorer/block',
41-
// 交易信息
42-
explorer_transactionList = '/v1/explorer/transactionListByAllBlock',
4327
}

src/layouts/BasicLayout.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
import { usePermissioStore } from '/@/store/modules/permission';
7979
import { useBreadcrumbTitle } from '../hooks/useBreadcrumbTitle';
8080
import { APP_TITLE } from '../../config/constant';
81-
import prolayoutSetting from './constant';
81+
import prolayoutSetting, { onlySideMenuPath } from './constant';
8282
8383
import type { BasicLayoutProps } from '@ant-design-vue/pro-layout';
8484
import type { RouteContextProps } from '@ant-design-vue/pro-layout';
@@ -96,8 +96,11 @@
9696
onUnmounted(() => {
9797
permissioStore.resetState();
9898
});
99-
100-
const menuData = clearMenuItem(router.getRoutes()).filter((n) => n.path.startsWith('/app/'));
99+
// 标准写法参考官方文档 https://github.com/vueComponent/pro-layout
100+
// 这里我是根据自身需求在导航栏菜单只展示指定路由
101+
const menuData = clearMenuItem(router.getRoutes()).filter((n) =>
102+
onlySideMenuPath.includes(n.path),
103+
);
101104
102105
const state = reactive<Omit<RouteContextProps, 'menuData'>>({
103106
collapsed: false, // default value

src/layouts/constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ const prolayoutSetting: Omit<BasicLayoutProps, 'menuData'> = {
3131
iconfontUrl: ICONFONTURL,
3232
};
3333
export default prolayoutSetting;
34+
35+
export const onlySideMenuPath = ['/app/home', '/app/website', '/app/others'];

src/router/README.md

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

src/router/router.config.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import BasicLayout from '/@/layouts/BasicLayout.vue';
22
import BlankLayout from '/@/layouts/BlankLayout.vue';
33
import type { RouteRecordRaw } from 'vue-router';
44

5-
export const accessRoutes = [
5+
export const accessRoutes: RouteRecordRaw[] = [
66
{
77
path: '/app',
88
name: 'app',
@@ -32,16 +32,29 @@ export const accessRoutes = [
3232
},
3333
},
3434
{
35-
path: '/app/page2',
36-
name: 'page2',
37-
component: () => import('/@/views/page2/index.vue'),
38-
redirect: '/app/page2/index',
35+
path: '/app/others',
36+
name: 'others',
37+
component: BlankLayout,
38+
// redirect: '/app/others/index',
3939
meta: {
4040
title: '其他菜单',
41-
keepAlive: true,
42-
icon: 'heyueguanli',
43-
auth: ['page2'],
41+
icon: 'xitongrizhi',
42+
auth: ['others'],
4443
},
44+
children: [
45+
{
46+
path: '/app/others/about',
47+
name: 'about',
48+
component: () => import('/@/views/others/about/index.vue'),
49+
meta: { title: '关于', keepAlive: true, breadcrumb: true },
50+
},
51+
{
52+
path: '/app/others/antdv',
53+
name: 'antdv',
54+
component: () => import('/@/views/others/antdv/index.vue'),
55+
meta: { title: '组件', keepAlive: true, breadcrumb: true },
56+
},
57+
],
4558
},
4659
{
4760
path: '/sys/account',

0 commit comments

Comments
 (0)