feat(desktop-client): add settings window and switch default API to production

- Open a dedicated settings BrowserWindow with general / login / diagnostics / about tabs
- Persist openAtLogin and keepRunningInBackground via desktop-settings.json; hide main window instead of quitting when background mode is on
- Default API base URL now points to api.shengxintui.com; LoginView and SettingsView share a single constant
- Restore wangyihao session cookies on probe and silent refresh, and accept the legacy http://mp.163.com console origin
- Drop the standalone diagnostics view in favor of the settings tab

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-30 22:00:01 +08:00
parent 40ef60eae2
commit baff51295a
13 changed files with 1110 additions and 226 deletions
@@ -33,6 +33,7 @@ interface ResolvedDeviceInfo {
const sessionStorageKey = "geo.desktop.session.v1";
const apiBaseURLStorageKey = "geo.desktop.api-base-url";
export const DEFAULT_API_BASE_URL = import.meta.env.VITE_DESKTOP_API_BASE_URL ?? "https://api.shengxintui.com";
const session = shallowRef<DesktopSession | null>(readStoredSession());
const apiBaseURL = shallowRef(readStoredApiBaseURL());
@@ -75,14 +76,14 @@ function persistSession(next: DesktopSession | null): void {
function readStoredApiBaseURL(): string {
if (typeof window === "undefined") {
return "http://localhost:8080";
return DEFAULT_API_BASE_URL;
}
return window.localStorage.getItem(apiBaseURLStorageKey) ?? "http://localhost:8080";
return window.localStorage.getItem(apiBaseURLStorageKey) ?? DEFAULT_API_BASE_URL;
}
function persistApiBaseURL(value: string): void {
const trimmed = value.trim() || "http://localhost:8080";
const trimmed = value.trim() || DEFAULT_API_BASE_URL;
apiBaseURL.value = trimmed;
if (typeof window !== "undefined") {
@@ -499,6 +500,12 @@ async function logout(): Promise<void> {
}
if (typeof window !== "undefined") {
window.addEventListener("storage", (event) => {
if (event.key === apiBaseURLStorageKey) {
apiBaseURL.value = event.newValue?.trim() || DEFAULT_API_BASE_URL;
void syncRuntimeSessionToMain();
}
});
void syncStoredDesktopClientDeviceInfo();
}