完善桌面端界面、发布检查与邮箱域名同步
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled

This commit is contained in:
Cheng Zhou
2026-07-01 10:49:31 +08:00
parent c923f887a0
commit 9cac75e85c
32 changed files with 5392 additions and 2684 deletions
+130 -3
View File
@@ -3,9 +3,9 @@
<header class="preferences-header">
<div>
<p class="preferences-kicker">CTMS Desktop</p>
<h3>桌面偏好</h3>
<h3>系统偏好</h3>
</div>
<el-button text :icon="Close" aria-label="关闭桌面偏好" @click="emit('close-request')" />
<el-button text :icon="Close" aria-label="关闭系统偏好" @click="emit('close-request')" />
</header>
<section class="preference-section">
@@ -17,6 +17,29 @@
</div>
</section>
<section class="preference-section">
<div class="section-title">外观</div>
<div class="preference-row">
<div>
<div class="row-title">界面主题</div>
<div class="row-desc">切换桌面工作台与系统弹窗的明暗配色</div>
</div>
<div class="theme-segmented" role="group" aria-label="界面主题">
<button
v-for="option in themeOptions"
:key="option.value"
type="button"
class="theme-option"
:class="{ active: desktopTheme === option.value }"
@click="setTheme(option.value)"
>
<el-icon><component :is="option.icon" /></el-icon>
<span>{{ option.label }}</span>
</button>
</div>
</div>
</section>
<section class="preference-section">
<div class="section-title">通知与更新</div>
<div class="preference-row">
@@ -63,7 +86,7 @@
import { computed, onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { Close } from "@element-plus/icons-vue";
import { Close, Moon, Sunny } from "@element-plus/icons-vue";
import {
getDesktopNotificationSubscription,
setDesktopNotificationSubscription,
@@ -74,7 +97,10 @@ import {
getDesktopServerUrl,
getNotificationPermission,
isDesktopUpdaterAvailable,
readDesktopThemePreference,
requestNotificationPermission,
setDesktopThemePreference,
type DesktopThemePreference,
type NotificationPermissionState,
} from "../runtime";
import { checkDesktopUpdateAndPrompt } from "../session/desktopUpdateManager";
@@ -92,13 +118,19 @@ const desktopUpdaterAvailable = isDesktopUpdaterAvailable();
const desktopNotificationsEnabled = ref(false);
const desktopNotificationLoading = ref(false);
const desktopUpdateChecking = ref(false);
const desktopTheme = ref<DesktopThemePreference>(readDesktopThemePreference());
const notificationPermission = ref<NotificationPermissionState>("unsupported");
const themeOptions = [
{ value: "light" as const, label: "明亮", icon: Sunny },
{ value: "dark" as const, label: "暗黑", icon: Moon },
];
const clientMetadataRows = computed(() => [
{ label: "客户端", value: `${clientMetadata.clientType} ${clientMetadata.version}` },
{ label: "平台", value: clientMetadata.platform },
{ label: "构建通道", value: clientMetadata.channel },
{ label: "提交", value: clientMetadata.commit },
{ label: "主题", value: desktopTheme.value === "dark" ? "暗黑" : "明亮" },
{ label: "服务器", value: desktopServerUrl.value || "未配置" },
{
label: "能力",
@@ -168,6 +200,10 @@ const checkDesktopUpdateNow = async () => {
}
};
const setTheme = (theme: DesktopThemePreference) => {
desktopTheme.value = setDesktopThemePreference(theme);
};
const copyClientMetadata = async () => {
const text = clientMetadataRows.value.map((row) => `${row.label}: ${row.value}`).join("\n");
await navigator.clipboard?.writeText(text);
@@ -273,6 +309,45 @@ code {
gap: 10px;
}
.theme-segmented {
display: inline-grid;
grid-template-columns: repeat(2, minmax(76px, 1fr));
gap: 4px;
padding: 4px;
border: 1px solid #dbe6f2;
border-radius: 9px;
background: #f1f5f9;
}
.theme-option {
appearance: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
min-width: 76px;
height: 30px;
padding: 0 10px;
border: 0;
border-radius: 7px;
background: transparent;
color: #64748b;
cursor: pointer;
font: inherit;
font-size: 12px;
font-weight: 700;
}
.theme-option:hover {
color: #0f172a;
}
.theme-option.active {
background: #ffffff;
color: #24496f;
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.metadata-panel {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
@@ -299,4 +374,56 @@ dd {
font-size: 12px;
overflow-wrap: anywhere;
}
:global([data-ctms-theme="dark"] .desktop-preferences-dialog .el-dialog__body) {
background: #111827;
}
:global([data-ctms-theme="dark"]) .desktop-preferences {
color: #e5edf7;
}
:global([data-ctms-theme="dark"]) .preferences-kicker {
color: #93c5fd;
}
:global([data-ctms-theme="dark"]) h3,
:global([data-ctms-theme="dark"]) .row-title,
:global([data-ctms-theme="dark"]) dd,
:global([data-ctms-theme="dark"]) code {
color: #f8fafc;
}
:global([data-ctms-theme="dark"]) .section-title,
:global([data-ctms-theme="dark"]) .server-label,
:global([data-ctms-theme="dark"]) .row-desc,
:global([data-ctms-theme="dark"]) dt {
color: #94a3b8;
}
:global([data-ctms-theme="dark"]) .server-card,
:global([data-ctms-theme="dark"]) .preference-row,
:global([data-ctms-theme="dark"]) .metadata-panel {
border-color: #26364a;
background: #172033;
}
:global([data-ctms-theme="dark"]) .theme-segmented {
border-color: #26364a;
background: #0f172a;
}
:global([data-ctms-theme="dark"]) .theme-option {
color: #94a3b8;
}
:global([data-ctms-theme="dark"]) .theme-option:hover {
color: #f8fafc;
}
:global([data-ctms-theme="dark"]) .theme-option.active {
background: #243247;
color: #bfdbfe;
box-shadow: none;
}
</style>
+12
View File
@@ -95,4 +95,16 @@ describe("Login protocol agreement", () => {
expect(source).toContain("width: clamp(480px, 34vw, 560px);");
expect(source).toContain("max-width: calc(100vw - 40px);");
});
it("uses only server-configured email domains on web and desktop", () => {
const source = readLoginView();
expect(source).toContain('fetchEmailDomains()');
expect(source).toContain(':disabled="availableEmailDomains.length === 0"');
expect(source).toContain("const availableEmailDomains = computed(() => configuredEmailDomains.value)");
expect(source).toContain("configuredEmailDomains.value.includes(domain)");
expect(source).not.toContain("preservedEmailDomain");
expect(source).not.toContain("showDomainSelect");
expect(source).not.toContain("email-domain-input");
});
});
+18 -35
View File
@@ -159,22 +159,14 @@
<span class="email-at-sign">@</span>
<div class="email-domain-wrapper">
<select
v-if="showDomainSelect"
v-model="form.emailDomain"
class="email-domain-field"
aria-label="邮箱域名"
:disabled="availableEmailDomains.length === 0"
>
<option v-for="domain in availableEmailDomains" :key="domain" :value="domain">{{ domain }}</option>
</select>
<input
v-else
v-model.trim="form.emailDomain"
type="text"
class="email-domain-field email-domain-input"
placeholder="邮箱域名"
aria-label="邮箱域名"
/>
<svg v-if="showDomainSelect" class="email-domain-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="m6 9 6 6 6-6"/></svg>
<svg class="email-domain-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="m6 9 6 6 6-6"/></svg>
</div>
</div>
</el-form-item>
@@ -201,12 +193,9 @@
<span> </span>
</el-button>
<!-- 注册与忘记密码左右分立 -->
<!-- 忘记密码与注册 -->
<div class="forgot-register-row">
<RouterLink to="/forgot-password" class="forgot-link">忘记密码</RouterLink>
<RouterLink v-if="showDesktopServerSettings" to="/desktop/server-settings" class="server-settings-link">
服务器设置
</RouterLink>
<RouterLink to="/register" class="register-link">新用户注册</RouterLink>
</div>
</el-form>
@@ -282,7 +271,6 @@ const AGREE_PROTOCOL_KEY = "ctms_agree_protocol";
const formRef = ref<FormInstance>();
const form = reactive({ email: "", emailLocal: "", emailDomain: "", password: "", agreeProtocol: false });
const configuredEmailDomains = ref<string[]>([]);
const preservedEmailDomain = ref("");
const rules: FormRules<typeof form> = {
email: [
@@ -305,13 +293,7 @@ const refreshDesktopServerUrl = () => {
};
const normalizeDomain = (value: string) => value.trim().toLowerCase().replace(/^@/, "");
const availableEmailDomains = computed(() => Array.from(new Set([
...configuredEmailDomains.value,
preservedEmailDomain.value,
].filter(Boolean))));
const showDomainSelect = computed(
() => configuredEmailDomains.value.length > 0 || Boolean(preservedEmailDomain.value)
);
const availableEmailDomains = computed(() => configuredEmailDomains.value);
const syncEmailFromParts = () => {
const local = form.emailLocal.trim().toLowerCase();
@@ -325,14 +307,13 @@ const applyEmailValue = (email: string) => {
const separator = normalized.lastIndexOf("@");
if (separator > 0) {
form.emailLocal = normalized.slice(0, separator);
form.emailDomain = normalizeDomain(normalized.slice(separator + 1));
preservedEmailDomain.value = configuredEmailDomains.value.includes(form.emailDomain)
? ""
: form.emailDomain;
const domain = normalizeDomain(normalized.slice(separator + 1));
form.emailDomain = configuredEmailDomains.value.includes(domain)
? domain
: configuredEmailDomains.value[0] || "";
} else {
form.emailLocal = normalized;
form.emailDomain = configuredEmailDomains.value[0] || "";
preservedEmailDomain.value = "";
}
syncEmailFromParts();
};
@@ -343,8 +324,12 @@ const loadEmailDomains = async () => {
configuredEmailDomains.value = Array.from(new Set(
data.items.map(normalizeDomain).filter(Boolean)
));
if (!configuredEmailDomains.value.includes(form.emailDomain)) {
form.emailDomain = configuredEmailDomains.value[0] || "";
}
} catch {
configuredEmailDomains.value = [];
form.emailDomain = "";
}
};
@@ -980,8 +965,7 @@ const onSubmit = async () => {
padding: 6px 0;
}
.email-local-field::placeholder,
.email-domain-input::placeholder {
.email-local-field::placeholder {
color: #94a3b8;
}
@@ -1013,10 +997,9 @@ const onSubmit = async () => {
cursor: pointer;
}
.email-domain-input {
width: 150px;
padding-right: 4px;
cursor: text;
.email-domain-field:disabled {
color: #94a3b8;
cursor: not-allowed;
}
.email-domain-chevron {
@@ -1101,7 +1084,7 @@ const onSubmit = async () => {
margin-top: 20px;
}
.forgot-link, .register-link, .server-settings-link {
.forgot-link, .register-link {
font-size: 13px;
color: #2563eb;
text-decoration: none;
@@ -1109,7 +1092,7 @@ const onSubmit = async () => {
transition: color 0.15s;
}
.forgot-link:hover, .register-link:hover, .server-settings-link:hover {
.forgot-link:hover, .register-link:hover {
color: #1d4ed8;
text-decoration: underline;
}
+5 -3
View File
@@ -449,12 +449,14 @@ const loadEmailDomains = async () => {
try {
const { data } = await fetchEmailDomains();
emailDomains.value = normalizeDomains(data.items);
if (!form.emailDomain && emailDomains.value.length > 0) {
form.emailDomain = emailDomains.value[0];
syncEmailFromParts();
if (!emailDomains.value.includes(form.emailDomain)) {
form.emailDomain = emailDomains.value[0] || "";
}
syncEmailFromParts();
} catch {
emailDomains.value = [];
form.emailDomain = "";
syncEmailFromParts();
}
};
+5 -1
View File
@@ -4,7 +4,11 @@ import { resolve } from "node:path";
const readProjects = () => readFileSync(resolve(__dirname, "./Projects.vue"), "utf8");
const readRouter = () => readFileSync(resolve(__dirname, "../../router/index.ts"), "utf8");
const readLayout = () => readFileSync(resolve(__dirname, "../../components/Layout.vue"), "utf8");
const readLayout = () => [
"../../components/WebLayout.vue",
"../../components/DesktopLayout.vue",
"../../components/layout/navigation.ts",
].map(path => readFileSync(resolve(__dirname, path), "utf8")).join("\n");
describe("project management access", () => {
it("shows project management to all signed-in users while keeping system operations admin-only", () => {