Settings.vue
3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!--
* @Author: 赵丽婷
* @Date: 2025-11-10 10:30:43
* @LastEditors: 赵丽婷
* @LastEditTime: 2025-12-04 14:10:55
* @FilePath: \LinkMed\linkmed-vue3\src\pages\Settings.vue
* @Description:
* Copyright (c) 2025 by 北京连心医疗科技有限公司, All Rights Reserved.
-->
<template>
<div class="settings-root">
<div :class="['settings-sidebar-wrapper', { 'is-collapsed': isCollapsed }]">
<SettingsSidebar
class="settings-sidebar"
:activeKey="activeKey"
:isCollapsed="isCollapsed"
@select="handleSelect"
@toggle="toggleSidebar"
/>
</div>
<div class="settings-content">
<SettingsPanel :activeKey="activeKey" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import { DArrowLeft, DArrowRight } from "@element-plus/icons-vue";
import SettingsSidebar from "@/components/Settings/SettingsSidebar.vue";
import SettingsPanel from "@/components/Settings/SettingsPanel.vue";
const route = useRoute();
const router = useRouter();
const activeKey = ref("general");
const isCollapsed = ref(false);
const toggleSidebar = () => {
isCollapsed.value = !isCollapsed.value;
};
const handleSelect = (key: string) => {
if (key === "helpCenter") {
router.push({ name: "HelpCenter" });
} else {
activeKey.value = key;
}
};
// 根据URL参数设置默认标签页
onMounted(() => {
const tab = route.query.tab as string;
if (
tab &&
[
"general", // 通用设置
"shortcut", // 快捷键设置
"profile", // 账号信息
"authentication", // 信息认证
"membersRecords", // 充值中心
"memberReferral", // 会员推荐
// "knowledge", // 暂时隐藏
// "ai", // 暂时隐藏
// "apikey", // 暂时隐藏
].includes(tab)
) {
activeKey.value = tab;
}
});
// 监听路由参数变化
watch(
() => route.query.tab,
(newTab) => {
if (
newTab &&
[
"general",
"shortcut",
"profile",
"authentication",
"membersRecords",
"memberReferral",
// "knowledge", // 暂时隐藏
// "ai", // 暂时隐藏
// "apikey", // 暂时隐藏
].includes(newTab as string)
) {
activeKey.value = newTab as string;
}
},
);
// 监听 activeKey 变化,同步更新路由参数
watch(activeKey, (newKey) => {
// 只有当路由参数与当前 activeKey 不一致时才更新路由
if (route.query.tab !== newKey) {
router
.replace({
name: "Settings",
query: { tab: newKey },
})
.catch((err) => {
if (err.name !== "NavigationDuplicated") {
console.error("Navigation error:", err);
}
});
}
});
</script>
<style scoped lang="scss">
.settings-root {
display: flex;
height: 100%;
width: 100%;
background: var(--color-bg, #18181a);
}
.settings-sidebar-wrapper {
display: flex;
flex-direction: column;
width: 260px;
background: var(--color-card, #232323);
border-right: 1px solid var(--color-border, #333);
transition: width 0.3s ease;
overflow: hidden;
&.is-collapsed {
width: 64px;
min-width: 64px;
}
}
.settings-sidebar {
flex: 1;
width: 100% !important;
min-width: 0 !important;
max-width: none !important;
border-right: none !important;
}
.settings-content {
flex: 1;
min-width: 0;
background: var(--color-bg, #18181a);
padding: 0;
display: flex;
flex-direction: column;
overflow-y: auto;
}
@media (max-width: 1024px) {
.settings-sidebar-wrapper {
// 平板模式下的特殊样式可以放在这里
}
}
</style>