Show WeCom machine name after brand title on shell and login.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-02 11:43:02 +08:00
parent 9427d9c429
commit ead3545df8
5 changed files with 72 additions and 5 deletions
+12
View File
@@ -32,6 +32,18 @@ export function getUsername(): string | null {
return localStorage.getItem(USER_KEY);
}
/** 与企微通知同一机器名(公开接口,登录前可用)。 */
export async function fetchMachineName(): Promise<string> {
try {
const res = await fetch(`${getApiBase()}/api/auth/branding`);
if (!res.ok) return "";
const data = (await res.json()) as { machine_name?: string };
return String(data.machine_name || "").trim();
} catch {
return "";
}
}
function tokenExpiresAtMs(): number | null {
const raw = localStorage.getItem(TOKEN_EXP_KEY);
if (!raw) return null;