style: 全站接入深色主题,按新规则整改界面取值
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
<template>
|
||||
<div class="head surface-card">
|
||||
<div class="head surface-card" :class="{ 'compact-head': compactHead }">
|
||||
<el-button
|
||||
v-if="showBackButton"
|
||||
text
|
||||
class="back-btn"
|
||||
:aria-label="backLabel"
|
||||
@click="goBack"
|
||||
>
|
||||
← {{ backLabel }}
|
||||
<el-icon class="btn-icon"><ArrowLeft /></el-icon>
|
||||
<span class="btn-label">← {{ backLabel }}</span>
|
||||
</el-button>
|
||||
<template v-if="pageTitle">
|
||||
<h1 class="head-title">{{ pageTitle }}</h1>
|
||||
@@ -15,13 +17,21 @@
|
||||
<p class="brand-title">学习进度跟踪系统</p>
|
||||
<p class="brand-subtitle">把学习变成可记录、可回顾、可持续的日常流程</p>
|
||||
</div>
|
||||
<el-tooltip :content="themeActionLabel" placement="bottom">
|
||||
<el-button text class="theme-btn" :aria-label="themeActionLabel" @click="toggleTheme">
|
||||
<el-icon class="btn-icon"><Sunny v-if="isDark" /><Moon v-else /></el-icon>
|
||||
<span class="btn-label">{{ themeActionLabel }}</span>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
v-if="showAiUsageEntry"
|
||||
plain
|
||||
class="ai-usage-btn"
|
||||
aria-label="AI 用量统计"
|
||||
@click="openAiUsage"
|
||||
>
|
||||
AI 用量统计
|
||||
<el-icon class="btn-icon"><DataLine /></el-icon>
|
||||
<span class="btn-label">AI 用量统计</span>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!isLoginRoute"
|
||||
@@ -29,9 +39,11 @@
|
||||
plain
|
||||
class="logout-btn"
|
||||
:loading="loggingOut"
|
||||
aria-label="退出登录"
|
||||
@click="handleLogout"
|
||||
>
|
||||
退出登录
|
||||
<el-icon class="btn-icon"><SwitchButton /></el-icon>
|
||||
<span class="btn-label">退出登录</span>
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -40,11 +52,16 @@
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ArrowLeft, DataLine, Moon, Sunny, SwitchButton } from "@element-plus/icons-vue";
|
||||
import router from "@/router";
|
||||
import { clearRecallIdentity } from "@/utils/recallCache";
|
||||
import { logout } from "@/api/login";
|
||||
import { useTheme } from "@/components/composables/useTheme";
|
||||
|
||||
const route = useRoute();
|
||||
const isLoginRoute = computed(() => route.path === "/login");
|
||||
// 整页画布页(自由回忆)里页头浮在导图上,窄屏只留图标,把纵向空间让给内容
|
||||
const compactHead = computed(() => route.meta.recallWorkspace === true);
|
||||
const showBackButton = computed(() => route.path !== "/login" && route.path !== "/welcome");
|
||||
const pageTitle = computed(() => route.meta?.title as string | undefined);
|
||||
// 返回目标由路由 meta 声明,未声明时回首页
|
||||
@@ -53,6 +70,7 @@ const backLabel = computed(() => (route.meta?.backLabel as string | undefined) |
|
||||
// 有多个入口的页面(如复习详情)优先回到用户来路,无历史时回退到声明的上级
|
||||
const backUseHistory = computed(() => route.meta?.backUseHistory === true);
|
||||
const loggingOut = ref(false);
|
||||
const { isDark, themeActionLabel, toggleTheme } = useTheme();
|
||||
|
||||
// 白名单来自登录响应写入的 localStorage;头部组件只挂载一次,
|
||||
// 因此换账号登录后要按路由变化重新读取,避免残留上一个账号的入口。
|
||||
@@ -87,6 +105,7 @@ const handleLogout = async () => {
|
||||
} catch {
|
||||
// 后端退出失败时,仍然清理前端登录态,避免用户被卡住。
|
||||
}
|
||||
clearRecallIdentity();
|
||||
localStorage.removeItem("isLoggedIn");
|
||||
localStorage.removeItem("aiAdmin");
|
||||
ElMessage.success("已退出登录");
|
||||
@@ -102,7 +121,7 @@ defineExpose({ isLoginRoute, showBackButton, pageTitle, backTo, backLabel, loggi
|
||||
<style scoped>
|
||||
.head {
|
||||
min-height: 82px;
|
||||
padding: 14px 18px;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -155,6 +174,14 @@ defineExpose({ isLoginRoute, showBackButton, pageTitle, backTo, backLabel, loggi
|
||||
}
|
||||
|
||||
/* 次级入口:中性描边,不与主按钮「退出登录」抢视觉 */
|
||||
.theme-btn {
|
||||
color: var(--green-700);
|
||||
}
|
||||
|
||||
.theme-btn:hover {
|
||||
color: var(--green-800);
|
||||
}
|
||||
|
||||
.ai-usage-btn {
|
||||
border-color: var(--border-soft);
|
||||
color: var(--green-700);
|
||||
@@ -165,6 +192,16 @@ defineExpose({ isLoginRoute, showBackButton, pageTitle, backTo, backLabel, loggi
|
||||
color: var(--green-800);
|
||||
}
|
||||
|
||||
/* 深色切换在桌面也保留图标(其他按钮只在画布页窄屏显示图标) */
|
||||
.theme-btn .btn-icon {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* 图标只在画布页窄屏出现,其余形态保持文字按钮 */
|
||||
.btn-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.head {
|
||||
align-items: flex-start;
|
||||
@@ -172,8 +209,41 @@ defineExpose({ isLoginRoute, showBackButton, pageTitle, backTo, backLabel, loggi
|
||||
}
|
||||
|
||||
.logout-btn,
|
||||
.theme-btn,
|
||||
.ai-usage-btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 画布页保持一行:文字换成图标,不再把整块页头竖向堆三行 */
|
||||
.compact-head .btn-icon {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.compact-head .btn-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.head.compact-head {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.compact-head .head-title {
|
||||
font-size: 16px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.compact-head .back-btn,
|
||||
.compact-head .logout-btn,
|
||||
.compact-head .theme-btn,
|
||||
.compact-head .ai-usage-btn {
|
||||
width: auto;
|
||||
flex-shrink: 0;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user