Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7580ec4
[v1.3] 修正React重绘问题 (ScriptCard & ScriptTable)
cyfung1031 Feb 1, 2026
4d4d2c4
Update ScriptCard.tsx
cyfung1031 Feb 1, 2026
968f849
remove unless key
cyfung1031 Feb 1, 2026
b2fe5c3
css fix
cyfung1031 Feb 1, 2026
e97d66e
css fix
cyfung1031 Feb 1, 2026
2a2a885
As per AIs' suggestions, DraggableContainer should be simple enough f…
cyfung1031 Feb 2, 2026
8386f7e
加注釋
cyfung1031 Feb 2, 2026
5e1b141
Merge branch 'release/v1.3' into pr-973-04
cyfung1031 Feb 2, 2026
0f8dbc2
fix
cyfung1031 Feb 2, 2026
2a28304
Merge branch 'release/v1.3' into pr-973-04
cyfung1031 Feb 4, 2026
e703f6c
O(prev.length * chunkResults.length) -> O(prev.length)
cyfung1031 Feb 8, 2026
579a37b
统一签名:去掉 ScriptCardItemProps 的 t 参数,并把这里改为 handleRunStop(item)。
cyfung1031 Feb 8, 2026
421ebda
searchOrFilter -> enableKeywordSearch
cyfung1031 Feb 8, 2026
63805bd
Merge branch 'release/v1.3' into pr-973-04
cyfung1031 Feb 8, 2026
4080014
fix TypeScript, change "all" to null, reconstruct sortScript
cyfung1031 Feb 8, 2026
76d4b1c
还是拿掉 transition 效果会比较好
cyfung1031 Feb 8, 2026
9531f61
fix rowSelection
cyfung1031 Feb 8, 2026
cf9d2a4
重构 columns 与 components, 稳定 Table render function 参考
cyfung1031 Feb 8, 2026
0a00fbf
open 和 close 写反了
cyfung1031 Feb 8, 2026
ee0c839
语言改变 或 sidebarOpen 改变时,更新 columns
cyfung1031 Feb 8, 2026
dd29d84
优化排序 & 恢复动画
CodFrm Feb 11, 2026
9b4d2b5
Merge branch 'release/v1.3' into pr/cyfung1031/1182
CodFrm Feb 11, 2026
fdb973e
批量更新
CodFrm Feb 11, 2026
e2ab598
整理代码
CodFrm Feb 11, 2026
84ddcaf
整理代码
CodFrm Feb 11, 2026
05b64d3
修訂: sortableIdsString 不 memo
cyfung1031 Feb 12, 2026
1ce78dc
handleRowSelectionChange 没有依存也不放进元件,只需要在第一次放进 rowSelection的 memo
cyfung1031 Feb 12, 2026
a276ce4
删除sortScript的promise和handleRowSelectionChange
CodFrm Feb 12, 2026
1693a52
Merge branch 'release/v1.3' into pr/cyfung1031/1182
CodFrm Feb 12, 2026
e02173e
sortScriptDeferred -> sortScript
cyfung1031 Feb 12, 2026
f6e56e2
修正动画
cyfung1031 Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/service/service_worker/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export class ScriptClient extends Client {
return this.do("requestCheckUpdate", uuid);
}

sortScript(active: string, over: string) {
return this.do("sortScript", { active, over });
sortScript(data: { before: string[]; after: string[] }) {
return this.do("sortScript", data);
}

pinToTop(uuids: string[]) {
Expand Down
100 changes: 57 additions & 43 deletions src/app/service/service_worker/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { type ResourceService } from "./resource";
import { type ValueService } from "./value";
import { compileScriptCode } from "../content/utils";
import { type SystemConfig } from "@App/pkg/config/config";
import { arrayMove } from "@dnd-kit/sortable";
import type {
TScriptRunStatus,
TDeleteScript,
Expand Down Expand Up @@ -1211,58 +1210,73 @@ export class ScriptService {
return scripts;
}

async sortScript({ active, over }: { active: string; over: string }) {
const scripts = await this.scriptDAO.all();
scripts.sort((a, b) => a.sort - b.sort);
let oldIndex = 0;
let newIndex = 0;
scripts.forEach((item, index) => {
if (item.uuid === active) {
oldIndex = index;
} else if (item.uuid === over) {
newIndex = index;
}
});
const newSort = arrayMove(scripts, oldIndex, newIndex);
const updatetime = Date.now();
for (let i = 0, l = newSort.length; i < l; i += 1) {
const item = newSort[i];
if (item.sort !== i) {
item.sort = i;
await this.scriptDAO.update(item.uuid, { sort: i, updatetime });
}
}
// 脚本排序,after为排序后的uuid列表
async sortScript({ after }: { before: string[]; after: string[] }) {
const daoAll = await this.scriptDAO.all();
const scripts = daoAll.sort((a, b) => a.sort - b.sort);
const sortingMap: Map<string, number> = new Map(after.map((uuid, index) => [uuid, index]));

// 排序 scripts 并更新 sort 字段
const batchUpdate: Record<string, Partial<Script>> = {};

const newList = (
await Promise.all(
scripts.map(async (script) => {
const newSort = sortingMap.get(script.uuid);
if (newSort !== undefined && script.sort !== newSort) {
batchUpdate[script.uuid] = { sort: newSort };
script.sort = newSort;
}
return script;
})
)
).sort((a, b) => a.sort - b.sort);

await this.scriptDAO.updates(batchUpdate);

this.mq.publish<TSortedScript[]>(
"sortedScripts",
newSort.map(({ uuid, sort }) => ({ uuid, sort }))
newList.map(({ uuid, sort }) => ({ uuid, sort }))
);
}

// 将指定 uuid 列表的脚本置顶,其他脚本排序不变
async pinToTop(uuids: string[]) {
const scripts = await this.scriptDAO.all();
const m = uuids.length;
const oldSorts = new Map<string, number>();
for (const script of scripts) {
oldSorts.set(script.uuid, script.sort);
const idx = uuids.indexOf(script.uuid);
if (idx >= 0) {
script.sort = idx;
const daoAll = await this.scriptDAO.all();
const sortingMap: Map<string, number> = new Map(uuids.map((uuid, index) => [uuid, index]));
// 排序 scripts 并更新 sort 字段
const scripts = daoAll.sort((a, b) => {
// 将 sortingMap 中有的 uuid 放在前面,其他的放在后面,且保持原有顺序
const aIndex = sortingMap.get(a.uuid);
const bIndex = sortingMap.get(b.uuid);
if (aIndex !== undefined && bIndex !== undefined) {
return aIndex - bIndex;
} else if (aIndex !== undefined) {
return -1;
} else if (bIndex !== undefined) {
return 1;
} else {
script.sort += m;
return a.sort - b.sort;
}
}
scripts.sort((a, b) => a.sort - b.sort);
const updatetime = Date.now();
for (let i = 0, l = scripts.length; i < l; i += 1) {
const item = scripts[i];
item.sort = i;
if (item.sort !== oldSorts.get(item.uuid)) {
await this.scriptDAO.update(item.uuid, { sort: i, updatetime });
}
}
});

const batchUpdate: Record<string, Partial<Script>> = {};

const newList = await Promise.all(
scripts.map(async (script, index) => {
const newSort = index;
if (script.sort !== newSort) {
batchUpdate[script.uuid] = { sort: newSort };
script.sort = newSort;
}
return script;
})
);
await this.scriptDAO.updates(batchUpdate);

this.mq.publish<TSortedScript[]>(
"sortedScripts",
scripts.map(({ uuid, sort }) => ({ uuid, sort }))
newList.map(({ uuid, sort }) => ({ uuid, sort }))
);
}

Expand Down
1 change: 1 addition & 0 deletions src/locales/ach-UG/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"starting_script": "crwdns8176:0crwdne8176:0",
"starting_updates": "crwdns8178:0crwdne8178:0",
"script_started": "crwdns8180:0crwdne8180:0",
"operation_failed": "Operation failed",
"batch_operations": "crwdns8182:0crwdne8182:0",
"export": "crwdns8184:0crwdne8184:0",
"delete": "crwdns8186:0crwdne8186:0",
Expand Down
1 change: 1 addition & 0 deletions src/locales/de-DE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "Skript wird gestartet...",
"starting_updates": "Batch-Update wird gestartet...",
"script_started": "Skript gestartet",
"operation_failed": "Vorgang fehlgeschlagen",
"batch_operations": "Batch-Operationen",
"export": "Exportieren",
"delete": "Löschen",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "Starting Script...",
"starting_updates": "Starting Batch Updates...",
"script_started": "Script Started",
"operation_failed": "Operation failed",
"batch_operations": "Batch Operations",
"export": "Export",
"delete": "Delete",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja-JP/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "スクリプトを開始中...",
"starting_updates": "一括更新を開始中...",
"script_started": "スクリプトが開始しました",
"operation_failed": "操作に失敗しました",
"batch_operations": "一括操作",
"export": "エクスポート",
"delete": "削除",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru-RU/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "Запуск скрипта...",
"starting_updates": "Массовое обновление...",
"script_started": "Скрипт запущен",
"operation_failed": "Операция не выполнена",
"batch_operations": "Пакетные операции",
"export": "Экспорт",
"delete": "Удалить",
Expand Down
1 change: 1 addition & 0 deletions src/locales/vi-VN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "Đang khởi động script...",
"starting_updates": "Đang khởi động cập nhật hàng loạt...",
"script_started": "Script đã khởi động",
"operation_failed": "Thao tác thất bại",
"batch_operations": "Thao tác hàng loạt",
"export": "Xuất",
"delete": "Xóa",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "正在启动脚本...",
"starting_updates": "正在批量更新...",
"script_started": "脚本已启动",
"operation_failed": "操作失败",
"batch_operations": "批量操作",
"export": "导出",
"delete": "删除",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"starting_script": "正在啟動腳本...",
"starting_updates": "正在批次更新...",
"script_started": "腳本已啟動",
"operation_failed": "操作失敗",
"batch_operations": "批次操作",
"export": "匯出",
"delete": "刪除",
Expand Down
Loading
Loading