Skip to content

Commit 6346a6e

Browse files
author
wyc001122
committed
Merge branch 'fix/vben-tree-disabled-functionality' of github.com:wyc001122/vue-vben-admin into fix/vben-tree-disabled-functionality
2 parents 177ca52 + 2630bde commit 6346a6e

File tree

7 files changed

+57
-9
lines changed

7 files changed

+57
-9
lines changed

packages/@core/ui-kit/shadcn-ui/src/components/button/button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface VbenButtonGroupProps
3636
btnClass?: any;
3737
gap?: number;
3838
multiple?: boolean;
39-
options?: { label: CustomRenderType; value: ValueType }[];
39+
options?: { [key: string]: any; label: CustomRenderType; value: ValueType }[];
4040
showIcon?: boolean;
4141
size?: 'large' | 'middle' | 'small';
4242
}

packages/@core/ui-kit/shadcn-ui/src/components/button/check-button-group.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,17 @@ async function onBtnClick(value: ValueType) {
119119
<CircleCheckBig v-else-if="innerValue.includes(btn.value)" />
120120
<Circle v-else />
121121
</div>
122-
<slot name="option" :label="btn.label" :value="btn.value">
122+
<slot name="option" :label="btn.label" :value="btn.value" :data="btn">
123123
<VbenRenderContent :content="btn.label" />
124124
</slot>
125125
</Button>
126126
</VbenButtonGroup>
127127
</template>
128128
<style lang="scss" scoped>
129129
.vben-check-button-group {
130+
display: flex;
131+
flex-wrap: wrap;
132+
130133
&:deep(.size-large) button {
131134
.icon-wrapper {
132135
margin-right: 0.3rem;
@@ -159,5 +162,16 @@ async function onBtnClick(value: ValueType) {
159162
}
160163
}
161164
}
165+
166+
&.no-gap > :deep(button):nth-of-type(1) {
167+
border-right-width: 0;
168+
}
169+
170+
&.no-gap {
171+
:deep(button + button) {
172+
margin-right: -1px;
173+
border-left-width: 1px;
174+
}
175+
}
162176
}
163177
</style>

packages/effects/hooks/src/use-tabs.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ComputedRef } from 'vue';
12
import type { RouteLocationNormalized } from 'vue-router';
23

34
import { useRoute, useRouter } from 'vue-router';
@@ -53,7 +54,24 @@ export function useTabs() {
5354
await tabbarStore.closeTabByKey(key, router);
5455
}
5556

56-
async function setTabTitle(title: string) {
57+
/**
58+
* 设置当前标签页的标题
59+
*
60+
* @description 支持设置静态标题字符串或动态计算标题
61+
* @description 动态标题会在每次渲染时重新计算,适用于多语言或状态相关的标题
62+
*
63+
* @param title - 标题内容
64+
* - 静态标题: 直接传入字符串
65+
* - 动态标题: 传入 ComputedRef
66+
*
67+
* @example
68+
* // 静态标题
69+
* setTabTitle('标签页')
70+
*
71+
* // 动态标题(多语言)
72+
* setTabTitle(computed(() => t('page.title')))
73+
*/
74+
async function setTabTitle(title: ComputedRef<string> | string) {
5775
tabbarStore.setUpdateTime();
5876
await tabbarStore.setTabTitle(route, title);
5977
}

packages/effects/layouts/src/authentication/authentication.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const { authPanelCenter, authPanelLeft, authPanelRight, isDark } =
3838

3939
<template>
4040
<div
41-
:class="[isDark]"
41+
:class="[isDark ? 'dark' : '']"
4242
class="flex min-h-full flex-1 select-none overflow-x-hidden"
4343
>
4444
<template v-if="toolbar">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { default as AuthPageLayout } from './authentication.vue';
2+
export * from './types';

packages/stores/src/modules/tabbar.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ComputedRef } from 'vue';
12
import type { Router, RouteRecordNormalized } from 'vue-router';
23

34
import type { TabDefinition } from '@vben-core/typings';
@@ -401,10 +402,23 @@ export const useTabbarStore = defineStore('core-tabbar', {
401402

402403
/**
403404
* @zh_CN 设置标签页标题
404-
* @param tab
405-
* @param title
405+
*
406+
* @zh_CN 支持设置静态标题字符串或计算属性作为动态标题
407+
* @zh_CN 当标题为计算属性时,标题会随计算属性值变化而自动更新
408+
* @zh_CN 适用于需要根据状态或多语言动态更新标题的场景
409+
*
410+
* @param {TabDefinition} tab - 标签页对象
411+
* @param {ComputedRef<string> | string} title - 标题内容,支持静态字符串或计算属性
412+
*
413+
* @example
414+
* // 设置静态标题
415+
* setTabTitle(tab, '新标签页');
416+
*
417+
* @example
418+
* // 设置动态标题
419+
* setTabTitle(tab, computed(() => t('common.dashboard')));
406420
*/
407-
async setTabTitle(tab: TabDefinition, title: string) {
421+
async setTabTitle(tab: TabDefinition, title: ComputedRef<string> | string) {
408422
const findTab = this.tabs.find(
409423
(item) => getTabPath(item) === getTabPath(tab),
410424
);

playground/src/views/examples/button-group/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const checkValue = ref(['a', 'b']);
1919
2020
const options = [
2121
{ label: '选项1', value: 'a' },
22-
{ label: '选项2', value: 'b' },
22+
{ label: '选项2', value: 'b', num: 999 },
2323
{ label: '选项3', value: 'c' },
2424
{ label: '选项4', value: 'd' },
2525
{ label: '选项5', value: 'e' },
@@ -168,10 +168,11 @@ function onBtnClick(value: any) {
168168
:options="options"
169169
v-bind="compProps"
170170
>
171-
<template #option="{ label, value }">
171+
<template #option="{ label, value, data }">
172172
<div class="flex items-center">
173173
<span>{{ label }}</span>
174174
<span class="ml-2 text-gray-400">{{ value }}</span>
175+
<span v-if="data.num" class="white ml-2">{{ data.num }}</span>
175176
</div>
176177
</template>
177178
</VbenCheckButtonGroup>

0 commit comments

Comments
 (0)