Skip to content

Commit 1a2e128

Browse files
author
sunss
committed
refactor(BasicLayout): 重构布局组件,删除pro-layout依赖,fix主题变量问题,包优化
1 parent b61d9ce commit 1a2e128

18 files changed

+849
-671
lines changed

config/vite/optimizer.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
const vendorLibs: { match: string[]; output: string }[] = [
2-
// {
3-
// match: ['xlsx'],
4-
// output: 'xlsx',
5-
// },
2+
{
3+
match: ['ant-design-vue'],
4+
output: 'antdv',
5+
},
6+
{
7+
match: ['echarts'],
8+
output: 'echarts',
9+
},
610
];
711

812
// @ts-ignore

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"serve": "npm run dev",
2828
"dev": "vite",
2929
"build": "vite build",
30-
"build:check":"vue-tsc --noEmit && vite build",
31-
"build:github":"vite build --base=/vite-vue3-ts/",
30+
"build:check": "vue-tsc --noEmit && vite build",
31+
"build:github": "vite build --base=/vite-vue3-ts/",
3232
"build:no-cache": "yarn clean:cache && npm run build",
3333
"preview": "vite preview",
3434
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
@@ -40,7 +40,6 @@
4040
"prepare": "husky install"
4141
},
4242
"dependencies": {
43-
"@ant-design-vue/pro-layout": "^3.1.3",
4443
"@ant-design/icons-vue": "^6.0.1",
4544
"@vueuse/core": "^6.8.0",
4645
"@vueuse/head": "^0.6.0",

pnpm-lock.yaml

Lines changed: 390 additions & 427 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components.d.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
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'];
98
ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb'];
109
AButton: typeof import('ant-design-vue/es')['Button'];
1110
ACard: typeof import('ant-design-vue/es')['Card'];
@@ -18,18 +17,17 @@ declare module 'vue' {
1817
AFormItem: typeof import('ant-design-vue/es')['FormItem'];
1918
AInput: typeof import('ant-design-vue/es')['Input'];
2019
AInputSearch: typeof import('ant-design-vue/es')['InputSearch'];
20+
ALayout: typeof import('ant-design-vue/es')['Layout'];
21+
ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent'];
22+
ALayoutHeader: typeof import('ant-design-vue/es')['LayoutHeader'];
2123
AMenu: typeof import('ant-design-vue/es')['Menu'];
2224
AMenuItem: typeof import('ant-design-vue/es')['MenuItem'];
2325
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'];
2426
ARangePicker: typeof import('ant-design-vue/es')['RangePicker'];
25-
AResult: typeof import('ant-design-vue/es')['Result'];
2627
ARow: typeof import('ant-design-vue/es')['Row'];
2728
ASelect: typeof import('ant-design-vue/es')['Select'];
2829
ASpace: typeof import('ant-design-vue/es')['Space'];
29-
ASpin: typeof import('ant-design-vue/es')['Spin'];
3030
ATable: typeof import('ant-design-vue/es')['Table'];
31-
ATabPane: typeof import('ant-design-vue/es')['TabPane'];
32-
ATabs: typeof import('ant-design-vue/es')['Tabs'];
3331
Icon: typeof import('./components/Icon/index.vue')['default'];
3432
Modal: typeof import('./components/Modal/index.vue')['default'];
3533
Table: typeof import('./components/Table/index.vue')['default'];

src/layouts/BasicLayout.vue

Lines changed: 0 additions & 167 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<a-layout-header class="header">
3+
<div class="logo-wrap">
4+
<router-link :to="{ path: '/' }">
5+
<img :src="logo" class="logo" />
6+
<h1 class="title"> SimpleChain联盟链 </h1>
7+
<!-- <span class="subTitle">基础版</span> -->
8+
</router-link>
9+
</div>
10+
<div>
11+
<RightContent />
12+
</div>
13+
</a-layout-header>
14+
</template>
15+
<script setup lang="ts">
16+
import RightContent from './RightContent.vue';
17+
import logo from '/@/assets/images/logo.png';
18+
</script>
19+
<style lang="less" scoped>
20+
.header {
21+
display: flex;
22+
align-items: center;
23+
justify-content: space-between;
24+
height: 100%;
25+
height: 80px;
26+
padding: 0 16px;
27+
background: #ffffff;
28+
box-shadow: 0 1px 4px #00152914;
29+
z-index: 1;
30+
.logo-wrap {
31+
height: 100%;
32+
a {
33+
display: flex;
34+
align-items: center;
35+
height: 100%;
36+
}
37+
.title {
38+
margin: 0;
39+
margin-left: 12px;
40+
font-size: 18px;
41+
color: #000000;
42+
}
43+
.logo {
44+
width: 48px;
45+
height: 48px;
46+
}
47+
}
48+
}
49+
</style>

src/layouts/components/RightContent.vue renamed to src/layouts/BasicLayout/components/RightContent.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</a-menu-item>
1212
</a-menu>
1313
</template>
14-
<Space class="rowCC" align="baseline" direction="horizontal">
14+
<Space class="wrap" align="baseline" direction="horizontal">
1515
<Icon align="2px" type="xitongshezhi" />
1616
<span class="setting">系统设置</span>
1717
<Icon align="2px" type="xialajiantou" />
@@ -24,13 +24,22 @@
2424
import { Space } from 'ant-design-vue';
2525
import { useUserStore } from '/@/store/modules/user';
2626
import { navs as myNavs } from './constant';
27+
import { usePermissioStore } from '/@/store/modules/permission';
2728
2829
const store = useUserStore();
30+
const permissioStore = usePermissioStore();
2931
const router = useRouter();
3032
3133
const navs = ref(myNavs);
3234
const selectedKeys = ref<string[]>([]);
3335
36+
watchEffect(() => {
37+
const modules = permissioStore.getModules;
38+
if (modules.length && permissioStore.getIsAdmin === 0) {
39+
navs.value = unref(navs).filter((n) => (n.auth ? modules.includes(n.auth) : true));
40+
}
41+
});
42+
3443
watchEffect(() => {
3544
if (router.currentRoute) {
3645
const matched = router.currentRoute.value.matched.concat();
@@ -51,7 +60,7 @@
5160
display: flex;
5261
justify-content: center;
5362
padding-right: 16px;
54-
.rowCC {
63+
.wrap {
5564
height: 55px;
5665
5766
.setting {

0 commit comments

Comments
 (0)