Skip to content

Commit 83e51e0

Browse files
committed
feat: import unocss and add menu collapse
1 parent 082fe25 commit 83e51e0

11 files changed

Lines changed: 646 additions & 79 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ coverage
1010
dist
1111
yarn.lock
1212
.env
13+
.history
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ module.exports = {
8080
'no-param-reassign': 0,
8181
'prefer-regex-literals': 0,
8282
'import/no-extraneous-dependencies': 0,
83+
"import/no-unresolved": 0,
8384
},
8485
};

template/tinyvue/config/vite.config.base.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import vue from '@vitejs/plugin-vue';
44
import vueJsx from '@vitejs/plugin-vue-jsx';
55
import svgLoader from 'vite-svg-loader';
66
import eslint from 'vite-plugin-eslint';
7+
import UnoCSS from 'unocss/vite';
78

89
const config = {
910
plugins: [
1011
vue(),
1112
vueJsx(),
1213
svgLoader({ svgoConfig: {} }),
1314
eslint({ cache: false }), // 禁用缓存‌
15+
UnoCSS(),
1416
],
1517
build: {
1618
outDir: resolve(__dirname, '../dist'),

template/tinyvue/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"private": true,
66
"author": "Tiny Team",
77
"license": "MIT",
8+
"type": "module",
89
"scripts": {
910
"start": "vite --config ./config/vite.config.dev.ts --port 3031",
1011
"build": "vite build --config ./config/vite.config.prod.ts",
@@ -40,8 +41,8 @@
4041
"@opentiny/vue": "^3.21.0",
4142
"@opentiny/vue-icon": "^3.21.0",
4243
"@opentiny/vue-locale": "^3.20.0",
43-
"@opentiny/vue-theme": "^3.21.0",
4444
"@opentiny/vue-search-box": "^0.0.1",
45+
"@opentiny/vue-theme": "^3.21.0",
4546
"@types/mockjs": "^1.0.10",
4647
"@types/node": "^22.7.4",
4748
"@vueuse/core": "^10.11.1",
@@ -110,6 +111,7 @@
110111
"ts-node": "^10.9.2",
111112
"tsx": "^4.19.1",
112113
"typescript": "^4.9.5",
114+
"unocss": "66.1.0-beta.11",
113115
"unplugin-vue-components": "^0.17.21",
114116
"vite": "^6.1.0",
115117
"vite-plugin-compression": "^0.5.1",

template/tinyvue/pnpm-lock.yaml

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

template/tinyvue/src/assets/style/menu.less

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
// 菜单宽度
2-
:deep(.tiny-tree-menu) {
3-
width: 250px;
4-
}
5-
61
// 去除默认右边竖线
72
:deep(.tiny-tree-menu::before) {
83
border-right: none;

template/tinyvue/src/components/menu/index.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
:data="MenuData"
66
:show-filter="false"
77
node-key="id"
8-
wrap
8+
99
:default-expanded-keys="expandeArr"
1010
only-check-children
1111
check-strictly
12+
menu-collapsible
1213
@current-change="currentChange"
14+
@collapse-change="collapseChange"
15+
class="h-[calc(100vh-60px)]"
1316
>
1417
<template #default="slotScope">
1518
<template v-for="(item, index) in routerTitle" :key="index">
@@ -30,7 +33,7 @@
3033
import router from '@/router';
3134
import { ITreeNodeData } from '@/router/guard/menu';
3235
import * as icons from '@opentiny/vue-icon';
33-
import { useTabStore } from '@/store';
36+
import { useTabStore, useAppStore } from '@/store';
3437
import { useDeepClone } from '@/hooks/useDeepClone';
3538
3639
const menuStore = useMenuStore();
@@ -39,6 +42,7 @@
3942
type SideMenuData = (ITreeNodeData & { meta: { url: string } })[];
4043
4144
let routerTitle = [] as any;
45+
const appStore = useAppStore();
4246
4347
const filtter = (treeNodeDatas: ITreeNodeData[]) => {
4448
const menus: SideMenuData = [];
@@ -78,6 +82,10 @@
7882
router.replace({ name: data.label });
7983
};
8084
85+
const collapseChange = (value) => {
86+
appStore.isMenuCollapsed = value
87+
}
88+
8189
const findId = (name: string, path: string) => {
8290
const dfs = (item, url: string[]) => {
8391
if (url.join('/') === path) {

template/tinyvue/src/layout/default-layout.vue

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,33 @@
11
<template>
22
<div class="layout">
3-
<tiny-container :aside-width="250" :pattern="myPattern">
4-
<template #header>
5-
<tiny-layout>
6-
<div class="layout-navbar">
7-
<NavBar />
8-
</div>
9-
</tiny-layout>
10-
</template>
11-
<template #aside>
12-
<tiny-layout class="layout-sider">
13-
<div class="menu-wrapper">
14-
<Suspense>
15-
<Menu v-if="reloadKey !== 'menu'" />
16-
</Suspense>
17-
</div>
18-
</tiny-layout>
19-
</template>
20-
<tiny-layout class="layout-content">
21-
<Tabs
22-
:key="tabsRefreshKey"
23-
v-model="currentTabName"
24-
with-close
25-
@click="onClick"
26-
@close="onClose"
27-
>
28-
<tab-item
29-
v-for="(history, idx) of tabsHistory"
30-
:key="idx"
31-
:title="t(history.name)"
32-
:name="history.link"
33-
></tab-item>
34-
</Tabs>
35-
<PageLayout />
36-
</tiny-layout>
37-
<template #footer>
38-
<tiny-layout>
39-
<div class="layout-footer">
40-
<Footer />
41-
</div>
42-
</tiny-layout>
43-
</template>
44-
</tiny-container>
3+
<div>
4+
<div class="shadow-[0_4px_6px_#0003] relative z-[999]">
5+
<NavBar v-if="layoutMode[myPattern].navbar"/>
6+
</div>
7+
<div class="flex">
8+
<Suspense>
9+
<Menu v-if="reloadKey !== 'menu' && layoutMode[myPattern].menu" class="shadow-[0_4px_12px_#0000001a] z-[100]" />
10+
</Suspense>
11+
<div class="text-[#ccc] bg-[#f5f6f7] pl-[10px] pr-[10px] flex-1 h-[calc(100vh-60px)]" :style="{ width: isMenuCollapsed ? '100%' : 'calc(100% - 220px)' }">
12+
<Tabs
13+
:key="tabsRefreshKey"
14+
v-model="currentTabName"
15+
with-close
16+
@click="onClick"
17+
@close="onClose"
18+
>
19+
<tab-item
20+
v-for="(history, idx) of tabsHistory"
21+
:key="idx"
22+
:title="t(history.name)"
23+
:name="history.link"
24+
></tab-item>
25+
</Tabs>
26+
<PageLayout class="!h-[calc(100%-120px)]" />
27+
<Footer v-if="layoutMode[myPattern].footer" class="h-[60px]" />
28+
</div>
29+
</div>
30+
</div>
4531
<div class="theme-box" @click="themeVisible">
4632
<img src="@/assets/images/theme.png" />
4733
</div>
@@ -104,6 +90,8 @@
10490
const tabsHistory = computed(() => tabStore.data);
10591
const currentTabName = ref();
10692
93+
const { isMenuCollapsed } = appStore;
94+
10795
const reloadKey = ref('');
10896
const reloadMenu = () => {
10997
reloadKey.value = 'menu';
@@ -203,6 +191,39 @@
203191
// 是否显示切换框架结构
204192
const myPattern = ref('legend');
205193
194+
const layoutMode = {
195+
// 传奇布局
196+
legend: {
197+
navbar: true,
198+
menu: true,
199+
footer: true,
200+
},
201+
// 简约布局
202+
simple: {
203+
navbar: false,
204+
menu: true,
205+
footer: false,
206+
},
207+
// 时尚布局
208+
fashion: {
209+
navbar: true,
210+
menu: true,
211+
footer: false,
212+
},
213+
// 经典布局
214+
classic: {
215+
navbar: true,
216+
menu: false,
217+
footer: true,
218+
},
219+
// 默认布局
220+
default: {
221+
navbar: true,
222+
menu: true,
223+
footer: false,
224+
},
225+
}
226+
206227
// 主题配置
207228
const disTheme = ref(false);
208229
const theme = new TinyThemeTool();

template/tinyvue/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import '@/assets/style/global.less';
1212
import config from '../hwc-exports.json';
1313
import chinaMap from './assets/china.json';
1414
import '@opentiny/vue-search-box/index.css';
15+
import 'virtual:uno.css';
1516

1617
registerMap('china', chinaMap as any);
1718
const app = createApp(App);

template/tinyvue/src/views/list/search-table/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="search-container-list">
3-
<Breadcrumb :items="['menu.list.searchTable']" />
3+
<Breadcrumb :items="['menu.list', 'menu.list.searchTable']" />
44

55
<div class="search-table-container">
66
<tiny-fullscreen

0 commit comments

Comments
 (0)