-
Notifications
You must be signed in to change notification settings - Fork 314
[v1.3] updateResource 相关代码调整 #1193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v1.3
Are you sure you want to change the base?
[v1.3] updateResource 相关代码调整 #1193
Conversation
|
UI 部份另行处理 |
| await this.scriptCodeDAO.save({ | ||
| uuid: script.uuid, | ||
| code: param.code, | ||
| }); | ||
| logger.info("install success"); | ||
|
|
||
| // Cache更新 & 下载资源 | ||
| await Promise.all([ | ||
| compiledResourceUpdatePromise, | ||
| this.resourceService.updateResourceByType(script, "require"), | ||
| this.resourceService.updateResourceByType(script, "require-css"), | ||
| this.resourceService.updateResourceByType(script, "resource"), | ||
| this.resourceService.updateResourceByTypes(script, ["require", "require-css", "resource"]), | ||
| ]); | ||
| // 如果资源不完整,还是要接受安装吗??? | ||
|
|
||
| // 广播一下 | ||
| // Runtime 會負責更新 CompiledResource | ||
| this.publishInstallScript(script, { update, upsertBy }); | ||
|
|
||
| return { update }; | ||
| }) | ||
| .catch((e: any) => { | ||
| logger.error("install error", Logger.E(e)); | ||
| throw e; | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodFrm scriptDAO 先 save 了显示成功。 如果资源下载失败,忽略掉是故意的吗?
是的话我就不改这做法
否则就改成下载不了不安装不更新
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
故意的,资源失败不影响脚本保存。不过这块逻辑可能还得优化一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那我这个 PR 先不处理这个,先维持
| const updateTime = oldResources?.updatetime; | ||
| // 资源最后更新是24小时内则不更新 | ||
| // 这里是假设 resources 都是 static. 使用者应该加 ?d=xxxx 之类的方式提示SC要更新资源 | ||
| if (updateTime && updateTime > Date.now() - 86400_000) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodFrm 原代码有这个 updateTime 检查操作。但脚本更新可以是每6小时做一次。如果脚本更新了但资源不更新,好像有点奇怪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前考虑过不做这个检查,感觉也可以,资源加载下来就不再失效,除非修改url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我先不改动。你有需要再改一下吧
概述 Descriptions
我都不知道要怎么说明了
反正就是有问题的部份改了
有些觉得奇怪的,我没有改,只加了 comment
变更内容 Changes
截图 Screenshots