-
Notifications
You must be signed in to change notification settings - Fork 299
汇出 & 汇入 - 修正不依照脚本最后修改日期时间问题 #951
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
汇出 & 汇入 - 修正不依照脚本最后修改日期时间问题 #951
Conversation
3fe5a8d to
c383cec
Compare
c383cec to
3a4bc2a
Compare
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.
Pull Request Overview
这个 PR 修复了脚本备份导出和导入功能中不保留脚本最后修改时间的问题(issue #936)。主要通过创建 JSZip 时区处理工具类,在备份数据中添加 lastModificationDate 字段,并在导入/导出时正确设置文件修改时间。
- 新增
jszip-x.ts工具类处理 JSZip 的 UTC 时区问题 - 在备份数据结构中添加
lastModificationDate字段 - 更新文件系统接口以支持
FileCreateOptions参数传递修改时间 - 修改脚本安装接口以支持指定创建和更新时间
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/pkg/utils/jszip-x.ts | 新增 JSZip 包装工具类,处理时区偏移问题,提供 createJSZip 和 loadAsyncJSZip 方法 |
| src/pkg/backup/struct.ts | 在 ScriptBackupData 和 SubscribeBackupData 中添加可选的 lastModificationDate 字段 |
| src/pkg/backup/import.ts | 解析备份文件时从文件元数据中读取 updatetime 并设置为 lastModificationDate |
| src/pkg/backup/export.ts | 导出时根据 lastModificationDate 设置文件的修改时间 |
| src/pkg/backup/utils.ts | 更新类型引用从 JSZip 改为 JSZipFile |
| src/pkg/backup/backup.test.ts | 更新测试用例以验证 lastModificationDate 字段 |
| src/pages/import/App.tsx | 导入时传递 createtime 和 updatetime 到 scriptClient.install |
| src/pages/install/App.tsx | 更新 scriptClient.install 调用参数结构 |
| src/pages/options/routes/script/ScriptEditor.tsx | 更新 scriptClient.install 调用参数结构 |
| src/pages/components/CloudScriptPlan/index.tsx | 使用 createJSZip 替代 new JSZip() |
| src/app/service/service_worker/script.ts | installScript 方法添加 createtime 和 updatetime 可选参数 |
| src/app/service/service_worker/synchronize.ts | 导出备份时计算并设置 lastModificationDate,使用 createJSZip |
| src/app/service/service_worker/value.ts | 重构 getScriptValue 方法以返回详细信息 |
| src/app/service/service_worker/resource.ts | importResource 方法中使用资源的时间戳(存在逻辑错误) |
| src/app/service/service_worker/client.ts | 更新 ScriptClient.install 方法签名 |
| packages/filesystem/filesystem.ts | 添加 FileCreateOptions 类型定义 |
| packages/filesystem/zip/*.ts | 实现文件修改时间的读写,处理时区转换 |
| packages/filesystem/webdav/*.ts | 添加 FileCreateOptions 参数支持(未实现) |
| packages/filesystem/onedrive/*.ts | 添加 FileCreateOptions 参数支持(未实现) |
| packages/filesystem/googledrive/*.ts | 添加 FileCreateOptions 参数支持(未实现) |
| packages/filesystem/dropbox/*.ts | 添加 FileCreateOptions 参数支持(未实现) |
| packages/filesystem/baidu/*.ts | 添加 FileCreateOptions 参数支持(未实现) |
| packages/cloudscript/local.ts | 更新类型引用从 JSZip 改为 JSZipFile |
| scripts/pack.js | 使用 createJSZip 替代 new JSZip() |
| createtime: ts || Math.min(ts, now), | ||
| updatetime: ts || Math.min(ts, now), |
Copilot
AI
Nov 14, 2025
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.
逻辑错误:当 ts 为 0 时,ts || Math.min(ts, now) 会因为 ts 为假值而计算 Math.min(0, now),结果为 0。但当 ts 有值时,会直接返回 ts 而不会执行 Math.min。
正确的逻辑应该是:
createtime: ts || now,
updatetime: ts || now,或者如果需要确保不使用未来时间:
createtime: Math.min(ts || now, now),
updatetime: Math.min(ts || now, now),| createtime: ts || Math.min(ts, now), | |
| updatetime: ts || Math.min(ts, now), | |
| createtime: ts || now, | |
| updatetime: ts || now, |
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.
resolved in af4f346
| } | ||
|
|
||
| async create(path: string): Promise<FileWriter> { | ||
| async create(path: string, _opts?: FileCreateOptions): Promise<FileWriter> { |
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.
不用的话,最后一个参数可以不填写
| async create(path: string, _opts?: FileCreateOptions): Promise<FileWriter> { | |
| async create(path: string): Promise<FileWriter> { |
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.
接口有两个参数
表示清晰
| install(script: Script, code: string, upsertBy: InstallSource = "user"): Promise<{ update: boolean }> { | ||
| return this.doThrow("install", { script, code, upsertBy }); | ||
| install(params: { | ||
| details: Script; |
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.
不用 script 了吗?后续也是 details、script 变来变去的
| details: Script; | |
| script: Script; |
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.
日后可能会把 subscribe 和 script 都用同一个变数名
用哪个都没所谓
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.
我还是先改回 script. 日后有机会再处理名字
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.
* 修正汇出汇入不依照脚本最后修改日期时间问题 * 修正 ValueStorage ts 问题 * 調整 setValues * 小修正 * 修正 * details -> script * 名字统一为 zipFile (cherry picked from commit d061699)
概述 Descriptions
依存: #949
汇出 & 汇入 - 修正不依照脚本最后修改日期时间问题
变更内容 Changes
截图 Screenshots