mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
- 引入 electron-updater 实现自动更新功能 - 新增 Java 环境扫描与校验的 IPC 处理逻辑 - 实现离线账号登录功能 - 新增配置变更跨进程广播机制 - 重构游戏启动逻辑,使用主进程内存配置作为唯一权威来源 - 新增界面显示与语言设置的配置页面 - 添加 Windows 平台自动发布 CI 流水线 - 迁移旧版配置/认证文件到用户数据目录 - 修复崩溃日志路径、表单控件等多项 bug - 重构设置页组件系统统一界面样式
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import electron from 'electron';
|
|
const { ipcMain } = electron;
|
|
import { readAuth, writeAuth, deleteAuth } from '../auth';
|
|
import { offlineLogin } from '../core/auth';
|
|
|
|
export function registerAuthHandlers() {
|
|
ipcMain.handle('auth:get', () => {
|
|
try {
|
|
const auth = readAuth();
|
|
return { success: true, data: auth, error: null };
|
|
} catch (e: unknown) {
|
|
return { success: false, data: null, error: String(e) };
|
|
}
|
|
});
|
|
|
|
ipcMain.handle('auth:save', (_event, auth) => {
|
|
try {
|
|
writeAuth(auth);
|
|
return { success: true, data: null, error: null };
|
|
} catch (e: unknown) {
|
|
return { success: false, data: null, error: String(e) };
|
|
}
|
|
});
|
|
|
|
ipcMain.handle('auth:delete', () => {
|
|
try {
|
|
deleteAuth();
|
|
return { success: true, data: null, error: null };
|
|
} catch (e: unknown) {
|
|
return { success: false, data: null, error: String(e) };
|
|
}
|
|
});
|
|
|
|
// 离线账号登录(离线模式不需要微软 OAuth,用户名即可生成 UUID)
|
|
ipcMain.handle('auth:offline-login', async (_event, payload: { username: string }) => {
|
|
try {
|
|
const username = (payload?.username || '').trim();
|
|
if (!username) {
|
|
return { success: false, data: null, error: '用户名不能为空' };
|
|
}
|
|
if (username.length > 16) {
|
|
return { success: false, data: null, error: '用户名长度不能超过 16 个字符' };
|
|
}
|
|
const data = await offlineLogin(username);
|
|
return { success: true, data, error: null };
|
|
} catch (e: unknown) {
|
|
return { success: false, data: null, error: String(e) };
|
|
}
|
|
});
|
|
}
|