Skip to content

Commit 0b53cb0

Browse files
committed
🐛 修复表格列表loading状态问题 #874
1 parent 5aa21b8 commit 0b53cb0

4 files changed

Lines changed: 34 additions & 30 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "1.2.0-beta.3",
3+
"version": "1.2.0-beta.4",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"author": "CodFrm",
66
"license": "GPLv3",

scripts/changlog.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ function generateChangelog() {
3636
// 使用正则表达式替换 (by (\w) -> (by @$1
3737
// 删除owner
3838
console.log("🔄 处理文件内容,添加 @ 符号...");
39-
let updatedContent = content.replaceAll(" (by 王一之)", "");
40-
updatedContent = updatedContent.replaceAll(" (by CodFrm)", "");
41-
updatedContent = updatedContent.replace(/\(by (\w)/g, "(by @$1");
39+
// 处理用户名
40+
let usernameMap = {
41+
王一之: "CodFrm",
42+
CodFrm: "CodFrm",
43+
wangyizhi: "CodFrm",
44+
};
45+
for (const [name, username] of Object.entries(usernameMap)) {
46+
const regex = new RegExp(`\\(by ${name}\\)`, "g");
47+
content = content.replaceAll(regex, `(by @${username})`);
48+
}
49+
const updatedContent = content.replace(/\(by (\w)/g, "(by @$1");
4250

4351
// 检查是否有内容被替换
4452
if (content !== updatedContent) {

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_scriptcat__",
4-
"version": "1.2.0.1400",
4+
"version": "1.2.0.1500",
55
"author": "CodFrm",
66
"description": "__MSG_scriptcat_description__",
77
"options_ui": {

src/pages/options/routes/ScriptList/hooks.tsx

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,29 @@ export function useScriptList() {
5757
useEffect(() => {
5858
let mounted = true;
5959
setLoadingList(true);
60-
fetchScriptList()
61-
.then(async (list) => {
60+
fetchScriptList().then(async (list) => {
61+
if (!mounted) return;
62+
setScriptList(list);
63+
setLoadingList(false);
64+
for await (const { chunkResults } of loadScriptFavicons(list)) {
6265
if (!mounted) return;
63-
setScriptList(list);
64-
for await (const { chunkResults } of loadScriptFavicons(list)) {
65-
if (!mounted) return;
66-
setScriptList((list) => {
67-
const scriptMap = new Map<string, ScriptLoading>();
68-
for (const s of list) {
69-
scriptMap.set(s.uuid, s);
70-
}
71-
const altered = new Set();
72-
for (const item of chunkResults) {
73-
const script = scriptMap.get(item.uuid);
74-
if (script) {
75-
altered.add(item.uuid);
76-
script.favorite = item.fav;
77-
}
66+
setScriptList((list) => {
67+
const scriptMap = new Map<string, ScriptLoading>();
68+
for (const s of list) {
69+
scriptMap.set(s.uuid, s);
70+
}
71+
const altered = new Set();
72+
for (const item of chunkResults) {
73+
const script = scriptMap.get(item.uuid);
74+
if (script) {
75+
altered.add(item.uuid);
76+
script.favorite = item.fav;
7877
}
79-
return list.map((entry) => (altered.has(entry.uuid) ? { ...entry } : entry));
80-
});
81-
}
82-
})
83-
.finally(() => {
84-
if (!mounted) return;
85-
setLoadingList(false);
86-
});
78+
}
79+
return list.map((entry) => (altered.has(entry.uuid) ? { ...entry } : entry));
80+
});
81+
}
82+
});
8783
return () => {
8884
mounted = false;
8985
};

0 commit comments

Comments
 (0)