mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
Replace the Tauri/sidecar architecture with an Electron main process. Adds an electron/ directory (main, preload, handlers, core integrations for @xmcl/*), electron-builder.yml, TypeScript electron config and declarations, and updated IPC utilities (ipc.ts) so frontend uses ipcRenderer/ipcMain. Removes Tauri sidecar and src-tauri artifacts, deletes sidecar sources and keys, updates .gitignore, VSCode recommendations, package scripts and icons, and updates documentation (README, AGENTS, DEV) and frontend stores/apis to reflect the Electron-based architecture and config/auth persistence changes.
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import electron from 'electron';
|
|
const { app } = electron;
|
|
|
|
export interface AuthData {
|
|
username: string;
|
|
uuid: string;
|
|
accessToken: string;
|
|
refreshToken: string;
|
|
xboxProfile: string;
|
|
}
|
|
|
|
const authFile = (): string => {
|
|
if (app.isPackaged) {
|
|
return path.join(path.dirname(app.getPath('exe')), 'koring-auth.json');
|
|
}
|
|
return path.join(__dirname, '..', 'koring-auth.json');
|
|
};
|
|
|
|
export function readAuth(): AuthData {
|
|
const filePath = authFile();
|
|
if (!fs.existsSync(filePath)) {
|
|
return { username: '', uuid: '', accessToken: '', refreshToken: '', xboxProfile: '' };
|
|
}
|
|
try {
|
|
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
return JSON.parse(raw) as AuthData;
|
|
} catch {
|
|
return { username: '', uuid: '', accessToken: '', refreshToken: '', xboxProfile: '' };
|
|
}
|
|
}
|
|
|
|
export function writeAuth(auth: AuthData): void {
|
|
const filePath = authFile();
|
|
fs.writeFileSync(filePath, JSON.stringify(auth, null, 2), 'utf-8');
|
|
}
|
|
|
|
export function deleteAuth(): void {
|
|
const filePath = authFile();
|
|
if (fs.existsSync(filePath)) {
|
|
fs.unlinkSync(filePath);
|
|
}
|
|
}
|