Skip to content

Commit b45243c

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

11 files changed

Lines changed: 655 additions & 127 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: 72 additions & 90 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>
@@ -72,11 +58,9 @@
7258
</template>
7359

7460
<script lang="ts" setup>
75-
import { ref, watch, onMounted, computed, nextTick, provide } from 'vue';
61+
import { ref, watch, computed, nextTick, provide } from 'vue';
7662
import { useI18n } from 'vue-i18n';
7763
import {
78-
Container as TinyContainer,
79-
Layout as TinyLayout,
8064
Modal as tinyModal,
8165
Tabs,
8266
TabItem,
@@ -96,14 +80,16 @@
9680
// 动态切换
9781
const router = useRouter();
9882
const appStore = useAppStore();
99-
const changefooter = ref('#fff');
83+
const footerColor = ref('#fff');
10084
10185
const { t } = useI18n();
10286
const tabStore = useTabStore();
10387
10488
const tabsHistory = computed(() => tabStore.data);
10589
const currentTabName = ref();
10690
91+
const { isMenuCollapsed } = appStore;
92+
10793
const reloadKey = ref('');
10894
const reloadMenu = () => {
10995
reloadKey.value = 'menu';
@@ -203,6 +189,39 @@
203189
// 是否显示切换框架结构
204190
const myPattern = ref('legend');
205191
192+
const layoutMode = {
193+
// 传奇布局
194+
legend: {
195+
navbar: true,
196+
menu: true,
197+
footer: true,
198+
},
199+
// 简约布局
200+
simple: {
201+
navbar: false,
202+
menu: true,
203+
footer: false,
204+
},
205+
// 时尚布局
206+
fashion: {
207+
navbar: true,
208+
menu: true,
209+
footer: false,
210+
},
211+
// 经典布局
212+
classic: {
213+
navbar: true,
214+
menu: false,
215+
footer: true,
216+
},
217+
// 默认布局
218+
default: {
219+
navbar: true,
220+
menu: true,
221+
footer: false,
222+
},
223+
}
224+
206225
// 主题配置
207226
const disTheme = ref(false);
208227
const theme = new TinyThemeTool();
@@ -227,9 +246,9 @@
227246
228247
watch(appStore.$state, (newValue, oldValue) => {
229248
if (newValue.theme === 'dark') {
230-
changefooter.value = '#262323;';
249+
footerColor.value = '#262323;';
231250
} else {
232-
changefooter.value = '#fff;';
251+
footerColor.value = '#fff;';
233252
}
234253
});
235254
// 初始化默认主题
@@ -241,24 +260,6 @@
241260
height: 100%;
242261
}
243262
244-
.layout-navbar {
245-
position: fixed;
246-
left: 0;
247-
z-index: 999;
248-
width: 100%;
249-
height: 60px;
250-
background-color: #fff;
251-
box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.2);
252-
}
253-
254-
.menu-wrapper {
255-
width: inherit;
256-
height: 92vh;
257-
margin-top: v-bind(top);
258-
overflow-x: hidden;
259-
overflow-y: auto;
260-
}
261-
262263
.global-setting {
263264
position: fixed;
264265
top: 280px;
@@ -268,30 +269,6 @@
268269
height: 30px;
269270
}
270271
271-
.layout :deep(.tiny-container .tiny-container__aside) {
272-
z-index: 100;
273-
background: #fff;
274-
border-left: 1px solid #ccc;
275-
box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.1);
276-
}
277-
278-
.layout :deep(.tiny-container .tiny-container__main) {
279-
background-color: #f5f6f7;
280-
}
281-
282-
.layout :deep(.layout-content) {
283-
height: 100%;
284-
padding: 0 10px;
285-
overflow: hidden;
286-
}
287-
288-
.layout :deep(.tiny-container .tiny-container__footer) {
289-
display: flex;
290-
justify-content: center;
291-
padding-top: 15px;
292-
background-color: #f5f6f7;
293-
}
294-
295272
// 组件无法固定非message的modal类型距离顶部距离
296273
:deep(.tiny-modal__box) {
297274
top: 8px !important;
@@ -319,6 +296,11 @@
319296
padding: 0 16px;
320297
}
321298
299+
:deep(.tiny-tree-menu .tiny-tree) {
300+
height: 100%;
301+
overflow: auto;
302+
}
303+
322304
.theme-box {
323305
position: fixed;
324306
top: 88%;

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)