Skip to content

Commit 1ae2e40

Browse files
committed
fix: 修复-全局组件大小
1 parent 4f7a152 commit 1ae2e40

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

Diff for: src/App.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
import { defineComponent } from 'vue';
99
import { ElConfigProvider } from 'element-plus';
1010
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
11+
import { mapState } from 'pinia';
12+
import store from '@/store';
1113
1214
export default defineComponent({
1315
components: {
1416
ElConfigProvider
1517
},
18+
computed: {
19+
...mapState(store.app, ['size'])
20+
},
1621
data() {
1722
return {
1823
locale: zhCn,
19-
zIndex: 3000,
20-
size: 'default'
24+
zIndex: 3000
2125
};
2226
}
2327
});

Diff for: src/components/SizeSelect/index.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default defineComponent({
2424
sizeOptions: [
2525
{ label: 'Default', value: 'default' },
2626
{ label: 'Large', value: 'large' },
27-
{ label: 'small', value: 'default' }
27+
{ label: 'Small', value: 'small' }
2828
]
2929
};
3030
},
@@ -35,7 +35,6 @@ export default defineComponent({
3535
},
3636
methods: {
3737
handleSetSize(size) {
38-
this.$ELEMENT.size = size;
3938
store.app().setSize(size);
4039
this.refreshView();
4140
ElMessage({

Diff for: src/layout/components/Navbar.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
<screenfull id="screenfull" class="right-menu-item hover-effect" />
1515

16-
<!-- <el-tooltip content="Global Size" effect="dark" placement="bottom">
16+
<el-tooltip content="Global Size" effect="dark" placement="bottom">
1717
<size-select id="size-select" class="right-menu-item hover-effect" />
18-
</el-tooltip> -->
18+
</el-tooltip>
1919

2020
</template>
2121

@@ -57,7 +57,7 @@ import Breadcrumb from '@/components/Breadcrumb';
5757
import Hamburger from '@/components/Hamburger';
5858
import ErrorLog from '@/components/ErrorLog';
5959
import Screenfull from '@/components/Screenfull';
60-
// import SizeSelect from '@/components/SizeSelect';
60+
import SizeSelect from '@/components/SizeSelect';
6161
import Search from '@/components/HeaderSearch';
6262
import { defineComponent } from 'vue';
6363
import { CaretBottom } from '@element-plus/icons-vue';
@@ -68,7 +68,7 @@ export default defineComponent({
6868
Hamburger,
6969
ErrorLog,
7070
Screenfull,
71-
// SizeSelect,
71+
SizeSelect,
7272
Search,
7373
CaretBottom
7474
},

Diff for: src/store/modules/app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface IAppState {
77
withoutAnimation: boolean;
88
};
99
device: 'desktop' | 'mobile';
10-
size: string;
10+
size: 'large' | 'default' | 'small';
1111
}
1212

1313
export default defineStore({
@@ -18,7 +18,7 @@ export default defineStore({
1818
withoutAnimation: false
1919
},
2020
device: 'desktop',
21-
size: Cookies.get('size') || 'medium'
21+
size: Cookies.get('size') || 'default'
2222
}),
2323
getters: {},
2424
actions: {

0 commit comments

Comments
 (0)