chore: 完成项目多维度优化与功能迭代

本次提交包含多项改进:
1. 新增Vitest测试配置与相关测试用例
2. 完善Deep Link监听与OAuth回调支持
3. 修复并优化多个React组件的依赖与性能
4. 更新后端API域名与端点地址
5. 优化KV存储服务实现与类型定义
6. 调整用户信息展示与权限相关逻辑
7. 重构部分业务逻辑,使用useCallback优化性能
8. 更新依赖包与Cargo.lock依赖版本
This commit is contained in:
Yukino_fox
2026-07-05 10:28:36 +08:00
parent 6f197babf6
commit 21c1183b1d
32 changed files with 1889 additions and 1280 deletions
+57 -4
View File
@@ -256,6 +256,57 @@ function MainContent(): React.JSX.Element {
}
}, [refreshPermissionFromAuth])
// 监听 Deep Link 事件(用于 OAuth 回调)
useEffect(() => {
const api = (window as any).api
if (!api || typeof api.onDeepLink !== "function") return
let disposed = false
let unlisten: (() => void) | null = null
api
.onDeepLink((url: string) => {
console.log("[DeepLink] Received URL:", url)
if (url.startsWith("secscore://oauth")) {
// 解析 OAuth 回调参数
const urlObj = new URL(url)
const code = urlObj.searchParams.get("code")
const state = urlObj.searchParams.get("state")
const error = urlObj.searchParams.get("error")
if (error) {
console.error("[DeepLink] OAuth error:", error)
messageApi.error("登录失败: " + error)
return
}
if (code && state) {
// 发送自定义事件,让 OAuthCallback 组件处理
window.dispatchEvent(
new CustomEvent("ss:oauth-deep-link", {
detail: { code, state },
})
)
}
}
})
.then((fn: () => void) => {
if (disposed) {
fn()
return
}
unlisten = fn
})
.catch((err: any) => {
console.error("[DeepLink] Failed to listen:", err)
})
return () => {
disposed = true
if (unlisten) unlisten()
}
}, [messageApi])
useEffect(() => {
const api = (window as any).api
if (!api || typeof api.onSettingChanged !== "function") return
@@ -531,10 +582,12 @@ function MainContent(): React.JSX.Element {
}, [messageApi, refreshPermissionFromAuth, t])
const handleOAuthSuccess = (userInfo: {
user_id: string
email: string
name: string
github_username?: string
user_id?: string
id?: string
email?: string
name?: string
avatar?: string
avatar_url?: string
}) => {
// OAuth 登录仅用于云服务,不修改本地权限
setOAuthUserName(userInfo.name || null)