汇出 & 汇入 - 修正不依照脚本最后修改日期时间问题#951
Merged
CodFrm merged 7 commits intoscriptscat:develop/raw-messagefrom Nov 15, 2025
Merged
Conversation
Closed
3fe5a8d to
c383cec
Compare
c383cec to
3a4bc2a
Compare
Contributor
There was a problem hiding this comment.
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() |
Comment on lines
317
to
318
| createtime: ts || Math.min(ts, now), | ||
| updatetime: ts || Math.min(ts, now), |
There was a problem hiding this comment.
逻辑错误:当 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),
Suggested change
| createtime: ts || Math.min(ts, now), | |
| updatetime: ts || Math.min(ts, now), | |
| createtime: ts || now, | |
| updatetime: ts || now, |
CodFrm
reviewed
Nov 14, 2025
| } | ||
|
|
||
| async create(path: string): Promise<FileWriter> { | ||
| async create(path: string, _opts?: FileCreateOptions): Promise<FileWriter> { |
Member
There was a problem hiding this comment.
不用的话,最后一个参数可以不填写
Suggested change
| async create(path: string, _opts?: FileCreateOptions): Promise<FileWriter> { | |
| async create(path: string): Promise<FileWriter> { |
| install(script: Script, code: string, upsertBy: InstallSource = "user"): Promise<{ update: boolean }> { | ||
| return this.doThrow("install", { script, code, upsertBy }); | ||
| install(params: { | ||
| details: Script; |
Member
There was a problem hiding this comment.
不用 script 了吗?后续也是 details、script 变来变去的
Suggested change
| details: Script; | |
| script: Script; |
Collaborator
Author
There was a problem hiding this comment.
日后可能会把 subscribe 和 script 都用同一个变数名
用哪个都没所谓
Collaborator
Author
There was a problem hiding this comment.
我还是先改回 script. 日后有机会再处理名字
Merged
CodFrm
pushed a commit
that referenced
this pull request
Nov 15, 2025
* 修正汇出汇入不依照脚本最后修改日期时间问题 * 修正 ValueStorage ts 问题 * 調整 setValues * 小修正 * 修正 * details -> script * 名字统一为 zipFile (cherry picked from commit d061699)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述 Descriptions
依存: #949
汇出 & 汇入 - 修正不依照脚本最后修改日期时间问题
变更内容 Changes
截图 Screenshots