Files
IM/frontend/web/src/views/settings/SettingMenu.vue
T

261 lines
6.0 KiB
Vue

<template>
<div class="im-settings-container">
<section class="menu-sidebar">
<h2 class="sidebar-title">系统设置</h2>
<div class="menu-list">
<button
v-for="item in menuItems"
:key="item.id"
:class="['menu-item', { active: activeTab === item.id }]"
@click="activeTab = item.id"
>
<span class="item-icon" v-html="item.icon"></span>
<span class="item-text">{{ item.name }}</span>
</button>
</div>
<div class="sidebar-footer">版本 v2.4.0</div>
</section>
<main class="main-panel">
<header class="panel-header">
<h1>{{ currentMenuName }}</h1>
<p>配置您的个性化通讯偏好</p>
</header>
<div class="panel-body">
<div v-if="activeTab === 'notifications'" class="setting-group">
<div v-for="(val, key) in notificationSettings" :key="key" class="setting-row">
<div class="row-info">
<div class="row-label">{{ key }}</div>
<div class="row-desc">开启后系统将实时同步您的通知偏好</div>
</div>
<label class="toggle-switch">
<input type="checkbox" v-model="notificationSettings[key]">
<span class="slider"></span>
</label>
</div>
</div>
<div v-else class="empty-placeholder">
<span class="icon">⚙️</span>
<p>{{ currentMenuName }} 功能开发中...</p>
</div>
</div>
<footer class="panel-footer">
<button class="btn-cancel" @click="reset">重置</button>
<button class="btn-save" @click="save">保存更改</button>
</footer>
</main>
</div>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
import feather from 'feather-icons'
const activeTab = ref('notifications')
const menuItems = [
{ id: 'profile', name: '个人资料', icon: feather.icons['user-check'].toSvg() },
{ id: 'notifications', name: '通知设置', icon: feather.icons['bell'].toSvg() },
{ id: 'security', name: '账号安全', icon: feather.icons['shield'].toSvg() },
{ id: 'general', name: '通用设置', icon: feather.icons['settings'].toSvg() }
]
const currentMenuName = computed(() => menuItems.find(i => i.id === activeTab.value)?.name)
const notificationSettings = reactive({
'声音提醒': true,
'桌面弹窗': true,
'仅在免打扰外提醒': false
})
const save = () => alert('设置已生效')
const reset = () => location.reload()
</script>
<style scoped>
/* 变量定义 */
:component {
--active-color: #00a884;
--bg-sidebar: #f7f9fa;
--bg-hover: #f0f2f5;
--text-main: #111b21;
--text-dim: #667781;
--border: #e9edef;
}
/* 核心容器:填满外部 */
.im-settings-container {
display: flex;
width: 100%;
height: 100%; /* 绝对铺满 */
background: #ffffff;
font-family: sans-serif;
overflow: hidden;
}
/* 左侧样式 */
.menu-sidebar {
width: 260px;
background: #eee;
border-right: 1px solid #d6d6d6;
display: flex;
flex-direction: column;
flex-shrink: 0;
}
.sidebar-title {
padding: 30px 24px;
font-size: 20px;
font-weight: 700;
color: var(--text-main);
margin: 0;
}
.menu-list {
flex: 1;
padding: 0 12px;
overflow-y: auto;
}
.menu-item {
width: 100%;
padding: 14px 16px;
display: flex;
align-items: center;
border: none;
background: transparent;
border-radius: 10px;
cursor: pointer;
margin-bottom: 4px;
transition: 0.2s;
color: var(--text-dim);
}
.menu-item:hover { background: #c6c6c6; }
.menu-item.active {
background: #c6c6c6;
color: var(--text-main);
font-weight: 600;
}
.item-icon { margin-right: 12px; font-size: 18px; }
.sidebar-footer {
padding: 20px;
text-align: center;
font-size: 12px;
color: #cbd5e1;
}
/* 右侧内容样式 */
.main-panel {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
background-color: #f5f5f5;
}
.panel-header {
padding: 40px 50px 20px;
}
.panel-header h1 { font-size: 26px; color: var(--text-main); margin: 0 0 8px 0; }
.panel-header p { font-size: 14px; color: var(--text-dim); margin: 0; }
.panel-body {
flex: 1;
padding: 0 50px;
overflow-y: auto;
}
.setting-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24px 0;
border-bottom: 1px solid var(--border);
}
.row-label { font-weight: 500; color: var(--text-main); margin-bottom: 4px; }
.row-desc { font-size: 13px; color: var(--text-dim); }
/* 开关组件 */
.toggle-switch {
position: relative;
width: 46px;
height: 24px;
flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
position: absolute;
cursor: pointer;
inset: 0;
background-color: #d1d5db;
transition: .3s;
border-radius: 24px;
}
.slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .3s;
border-radius: 50%;
}
input:checked + .slider { background-color: #0075ae; }
input:checked + .slider:before { transform: translateX(22px); }
/* 底部操作 */
.panel-footer {
padding: 30px 50px;
display: flex;
justify-content: flex-end;
gap: 16px;
}
.btn-cancel {
background: none;
border: none;
color: var(--text-dim);
cursor: pointer;
font-weight: 500;
}
.btn-save {
background: #000000;
color: white;
border: none;
padding: 12px 32px;
border-radius: 25px;
font-weight: 600;
cursor: pointer;
box-shadow: 0 4px 10px rgba(0, 168, 132, 0.2);
}
.empty-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 200px;
color: #cbd5e1;
}
/* 响应式:窄容器自动堆叠 */
@media (max-width: 650px) {
.im-settings-container { flex-direction: column; }
.menu-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
.menu-list { display: flex; overflow-x: auto; padding: 10px; }
.menu-item { white-space: nowrap; width: auto; margin-right: 8px; margin-bottom: 0; }
.sidebar-title, .sidebar-footer { display: none; }
}
</style>