Skip to content

Commit 165c46c

Browse files
committed
🐛 修复界面模式切换
1 parent 79cb27c commit 165c46c

4 files changed

Lines changed: 78 additions & 14 deletions

File tree

src/pages/components/ScriptMenuList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ const MenuItem: React.FC<MenuItemProps> = ({ menu, uuid }) => {
324324
htmlType="submit"
325325
icon={<IconMenu />}
326326
title={menu.options?.title}
327-
style={{ display: "block", width: "100%", borderTopColor: "#E5E6EB" }}
327+
style={{ display: "block", width: "100%" }}
328328
>
329329
{menu.name}
330330
{menu.options?.accessKey && `(${menu.options.accessKey.toUpperCase()})`}

src/pages/store/features/config.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@ export const configSlice = createAppSlice({
2626
lightMode: localStorage.lightMode || "auto",
2727
},
2828
reducers: (create) => {
29-
// 初始化黑夜模式
30-
setAutoMode();
29+
// 判断模式
30+
switch (localStorage.lightMode) {
31+
case "dark":
32+
document.body.setAttribute("arco-theme", "dark");
33+
editor.setTheme("vs-dark");
34+
break;
35+
case "light":
36+
document.body.removeAttribute("arco-theme");
37+
editor.setTheme("vs");
38+
break;
39+
case "auto":
40+
setAutoMode();
41+
break;
42+
}
3143
return {
3244
setDarkMode: create.reducer((state, action: PayloadAction<"light" | "dark" | "auto">) => {
33-
localStorage.loghtMode = action.payload;
45+
localStorage.lightMode = action.payload;
3446
state.lightMode = action.payload;
3547
if (action.payload === "auto") {
3648
setAutoMode();

src/template/scriptcat.d.tpl

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,44 @@ declare function GM_getResourceText(name: string): string | undefined;
9797

9898
declare function GM_getResourceURL(name: string, isBlobUrl?: boolean): string | undefined;
9999

100-
declare function GM_registerMenuCommand(
100+
function GM_registerMenuCommand(
101101
name: string,
102-
listener: () => void,
102+
listener: (inputValue?: any) => void,
103103
optionsOrAccessKey?:
104-
| string
105104
| {
106-
id?: number | string;
107-
accessKey?: string;
105+
id?: number;
108106
autoClose?: boolean;
109107
title?: string;
108+
accessKey?: string;
110109
}
110+
| string
111111
): number;
112112

113113
declare function GM_unregisterMenuCommand(id: number): void;
114114

115+
/**
116+
* 注册一个菜单输入框, 允许用户输入值, 并在输入完成后用回调函数
117+
*/
118+
declare function CAT_registerMenuInput(
119+
name: string,
120+
listener: (inputValue?: any) => void,
121+
optionsOrAccessKey?:
122+
| {
123+
id?: number;
124+
autoClose?: boolean;
125+
title?: string;
126+
accessKey?: string;
127+
// 可选输入框
128+
inputType?: "text" | "number" | "boolean";
129+
inputLabel?: string;
130+
inputDefaultValue?: string | number | boolean;
131+
inputPlaceholder?: string;
132+
}
133+
| string
134+
): number;
135+
136+
declare const CAT_unregisterMenuInput: typeof GM_unregisterMenuCommand;
137+
115138
declare function GM_openInTab(url: string, options: GMTypes.OpenTabOptions): tab;
116139
declare function GM_openInTab(url: string, loadInBackground: boolean): tab;
117140
declare function GM_openInTab(url: string): tab;
@@ -294,6 +317,10 @@ declare namespace GMTypes {
294317
[key: string]: string | boolean | number | undefined;
295318
};
296319

320+
interface CookieDetailsPartitionKeyType {
321+
topLevelSite?: string;
322+
}
323+
297324
interface CookieDetails {
298325
url?: string;
299326
name?: string;
@@ -304,6 +331,7 @@ declare namespace GMTypes {
304331
session?: boolean;
305332
httpOnly?: boolean;
306333
expirationDate?: number;
334+
partitionKey?: CookieDetailsPartitionKeyType;
307335
}
308336

309337
interface Cookie {

src/types/scriptcat.d.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { ScriptMenuItem } from "@App/app/service/service_worker/popup";
2-
31
// @copyright https://github.com/silverwzw/Tampermonkey-Typescript-Declaration
42

53
declare const unsafeWindow: Window;
@@ -99,15 +97,41 @@ declare function GM_getResourceText(name: string): string | undefined;
9997

10098
declare function GM_getResourceURL(name: string, isBlobUrl?: boolean): string | undefined;
10199

102-
declare function GM_registerMenuCommand(
100+
function GM_registerMenuCommand(
103101
name: string,
104102
listener: (inputValue?: any) => void,
105-
optionsOrAccessKey?: ScriptMenuItem["options"] | string
103+
optionsOrAccessKey?:
104+
| {
105+
id?: number;
106+
autoClose?: boolean;
107+
title?: string;
108+
accessKey?: string;
109+
}
110+
| string
106111
): number;
107112

108113
declare function GM_unregisterMenuCommand(id: number): void;
109114

110-
declare const CAT_registerMenuInput: typeof GM_registerMenuCommand;
115+
/**
116+
* 注册一个菜单输入框, 允许用户输入值, 并在输入完成后用回调函数
117+
*/
118+
declare function CAT_registerMenuInput(
119+
name: string,
120+
listener: (inputValue?: any) => void,
121+
optionsOrAccessKey?:
122+
| {
123+
id?: number;
124+
autoClose?: boolean;
125+
title?: string;
126+
accessKey?: string;
127+
// 可选输入框
128+
inputType?: "text" | "number" | "boolean";
129+
inputLabel?: string;
130+
inputDefaultValue?: string | number | boolean;
131+
inputPlaceholder?: string;
132+
}
133+
| string
134+
): number;
111135

112136
declare const CAT_unregisterMenuInput: typeof GM_unregisterMenuCommand;
113137

0 commit comments

Comments
 (0)