Skip to content

Commit f33eecd

Browse files
committed
feat: 添加标签页页面
1 parent a4c7693 commit f33eecd

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { useRouter } from '@/features/router';
2+
import type { LocationQueryRaw } from '@/features/router/query';
3+
import { useTabActions, useTabLabel } from '@/features/tab/tabHooks';
4+
5+
const Tab = () => {
6+
const { t } = useTranslation();
7+
8+
const { resetTabLabel, setTabLabel } = useTabLabel();
9+
10+
const { removeActiveTab, removeTabById } = useTabActions();
11+
12+
const { navigate, push } = useRouter();
13+
14+
function changeTabLabel(value: string) {
15+
setTabLabel(value);
16+
}
17+
18+
function resetLabel() {
19+
resetTabLabel();
20+
}
21+
22+
function goMultiTab(query?: LocationQueryRaw) {
23+
push('/function/multi-tab', query);
24+
}
25+
26+
function removeAboutTab() {
27+
removeTabById('/about');
28+
}
29+
30+
function goAbout() {
31+
navigate('/about');
32+
}
33+
34+
return (
35+
<ASpace
36+
className="w-full"
37+
direction="vertical"
38+
size={16}
39+
>
40+
<ACard
41+
className='"card-wrapper'
42+
size="small"
43+
title={t('page.function.tab.tabOperate.title')}
44+
variant="borderless"
45+
>
46+
<ADivider orientation="left">{t('page.function.tab.tabOperate.addTab')}</ADivider>
47+
<AButton onClick={goAbout}>{t('page.function.tab.tabOperate.addTabDesc')}</AButton>
48+
49+
<ADivider orientation="left">{t('page.function.tab.tabOperate.closeTab')}</ADivider>
50+
<ASpace size={16}>
51+
<AButton onClick={removeActiveTab}>{t('page.function.tab.tabOperate.closeCurrentTab')}</AButton>
52+
53+
<AButton onClick={removeAboutTab}>{t('page.function.tab.tabOperate.closeAboutTab')}</AButton>
54+
</ASpace>
55+
56+
<ADivider orientation="left">{t('page.function.tab.tabOperate.addMultiTab')}</ADivider>
57+
<ASpace
58+
wrap
59+
className="m-0!"
60+
size={16}
61+
>
62+
<AButton onClick={() => goMultiTab()}>{t('page.function.tab.tabOperate.addMultiTabDesc1')}</AButton>
63+
64+
<AButton
65+
onClick={() => {
66+
goMultiTab({ a: '1' });
67+
}}
68+
>
69+
{t('page.function.tab.tabOperate.addMultiTabDesc2')}
70+
</AButton>
71+
</ASpace>
72+
</ACard>
73+
74+
<ACard
75+
className='"card-wrapper'
76+
size="small"
77+
title={t('page.function.tab.tabTitle.title')}
78+
variant="borderless"
79+
>
80+
<ADivider orientation="left">{t('page.function.tab.tabTitle.changeTitle')}</ADivider>
81+
82+
<AInput.Search
83+
allowClear
84+
className="max-w-240px"
85+
enterButton={t('page.function.tab.tabTitle.change')}
86+
onSearch={changeTabLabel}
87+
/>
88+
89+
<ADivider orientation="left">{t('page.function.tab.tabTitle.resetTitle')}</ADivider>
90+
<AButton onClick={resetLabel}>{t('page.function.tab.tabTitle.reset')}</AButton>
91+
</ACard>
92+
</ASpace>
93+
);
94+
};
95+
96+
export const handle = {
97+
i18nKey: 'route.function_tab',
98+
icon: 'ic:round-tab',
99+
keepAlive: true,
100+
order: 1,
101+
title: 'function_tab'
102+
};
103+
104+
export default Tab;

0 commit comments

Comments
 (0)