增加SC版本检查按钮 - #795
增加SC版本检查按钮#795
Conversation
|
原来的逻辑我觉得是足够了的,有更新的时候会显示出来 有时候因为更新了服务端提供的版本号,但是浏览器自己没有自动更新,或者还在审核,用户也会产生疑问,所以我都打算放弃这个功能了 扩展自身也没有自动更新的功能,只能等浏览器自己更新,我觉得不用特别处理 |
有些用户看不到检查更新会不放心 我觉得至少用户可以知道GitHub有新版本是好事 |
|
@cyfung1031 可以修改为点击版本号实现检查一次更新 如有更新打开更新页面,但是这里有个问题,跳转到GitHub release,用户通过edge/chrome扩展商店安装的,打开也没有作用,用户也无法通过商店去手动进行升级,感觉这个功能除了制造焦虑有点鸡肋 |
There was a problem hiding this comment.
Pull Request Overview
这个PR为ScriptCat浏览器扩展的popup页面增加了版本检查按钮功能,让用户可以通过点击版本号来检查更新。
- 增加了版本检查状态管理和用户交互功能
- 改进了版本显示的UI/UX设计,使用Tooltip提示信息
- 启用了UnoCSS的媒体查询暗色模式支持
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| uno.config.ts | 启用UnoCSS暗色模式支持,为新的UI功能提供样式基础 |
| src/pages/popup/App.tsx | 实现版本检查功能,包括状态管理、API调用和交互式UI组件 |
| ]).then(([resp]: [{ data: { notice: string; version: string } }, any]) => { | ||
| let newCheckUpdateState = 0; | ||
| setCheckUpdate((items) => { | ||
| if (resp.data.version === items.version) { | ||
| newCheckUpdateState = 2; | ||
| return items; | ||
| } | ||
| const isRead = items.notice !== resp.data.notice ? false : items.isRead; | ||
| const newCheckUpdate = Object.assign(resp.data, { isRead: isRead }); | ||
| systemConfig.setCheckUpdate(newCheckUpdate); | ||
| return newCheckUpdate; | ||
| }); | ||
| setCheckUpdateStatus(() => newCheckUpdateState); | ||
| }); |
There was a problem hiding this comment.
fetch请求缺少错误处理,如果网络请求失败或API返回错误,会导致UI卡在检查状态。应该添加.catch()处理错误情况并重置checkUpdateStatus状态。
| ]).then(([resp]: [{ data: { notice: string; version: string } }, any]) => { | |
| let newCheckUpdateState = 0; | |
| setCheckUpdate((items) => { | |
| if (resp.data.version === items.version) { | |
| newCheckUpdateState = 2; | |
| return items; | |
| } | |
| const isRead = items.notice !== resp.data.notice ? false : items.isRead; | |
| const newCheckUpdate = Object.assign(resp.data, { isRead: isRead }); | |
| systemConfig.setCheckUpdate(newCheckUpdate); | |
| return newCheckUpdate; | |
| }); | |
| setCheckUpdateStatus(() => newCheckUpdateState); | |
| }); | |
| ]) | |
| .then(([resp]: [{ data: { notice: string; version: string } }, any]) => { | |
| let newCheckUpdateState = 0; | |
| setCheckUpdate((items) => { | |
| if (resp.data.version === items.version) { | |
| newCheckUpdateState = 2; | |
| return items; | |
| } | |
| const isRead = items.notice !== resp.data.notice ? false : items.isRead; | |
| const newCheckUpdate = Object.assign(resp.data, { isRead: isRead }); | |
| systemConfig.setCheckUpdate(newCheckUpdate); | |
| return newCheckUpdate; | |
| }); | |
| setCheckUpdateStatus(() => newCheckUpdateState); | |
| }) | |
| .catch((error) => { | |
| // Handle error: reset checkUpdateStatus so UI does not get stuck | |
| setCheckUpdateStatus(0); | |
| // Optionally log the error | |
| // console.error("Failed to check update:", error); | |
| }); |
There was a problem hiding this comment.
@CodFrm 以前的commit/PR 没有 copilot review 吧。AI有一堆疑问~
There was a problem hiding this comment.
@CodFrm 以前的commit/PR 没有 copilot review 吧。AI有一堆疑问~
什么意思?这个功能我确实是最近才用上的
| fetch(`${ExtServer}api/v1/system/version?version=${ExtVersion}`).then((resp) => resp.json()), | ||
| // 加 800ms delay 避免过快显示 | ||
| new Promise((resolve) => setTimeout(resolve, 800)), | ||
| ]).then(([resp]: [{ data: { notice: string; version: string } }, any]) => { |
There was a problem hiding this comment.
API响应类型定义不完整,使用any类型会失去类型安全性。建议为第二个Promise定义明确的类型,例如[APIResponse, void]。
| ]).then(([resp]: [{ data: { notice: string; version: string } }, any]) => { | |
| ]).then(([resp]: [{ data: { notice: string; version: string } }, void]) => { |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

概述
close #793
变更内容
截图
用戶按一按就放心了