Skip to content

Commit 6c4c84a

Browse files
committed
GMApiRequest 代码调整,GM_log 代码修正,@connect判断修正
1 parent 080a859 commit 6c4c84a

5 files changed

Lines changed: 142 additions & 108 deletions

File tree

src/app/service/content/gm_api.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,7 @@ export default class GMApi extends GM_Base {
456456
if (typeof message !== "string") {
457457
message = JSON.stringify(message);
458458
}
459-
const requestParams: any[] = [message, level];
460-
if (labels.length > 0) {
461-
requestParams.push(labels);
462-
}
463-
this.sendMessage("GM_log", requestParams);
459+
this.sendMessage("GM_log", [message, level, labels.length ? labels : undefined]);
464460
}
465461

466462
@GMContext.API()
@@ -758,7 +754,7 @@ export default class GMApi extends GM_Base {
758754
this.sendMessage("CAT_fileStorage", ["config"]);
759755
return;
760756
}
761-
const sendDetails: { [key: string]: string } = {
757+
const sendDetails: CATType.CATFileStorageDetails = {
762758
baseDir: details.baseDir || "",
763759
path: details.path || "",
764760
filename: details.filename,
@@ -1056,7 +1052,7 @@ export default class GMApi extends GM_Base {
10561052
timeout: details.timeout,
10571053
cookie: details.cookie,
10581054
anonymous: details.anonymous,
1059-
},
1055+
} as GMTypes.DownloadDetails,
10601056
]).then((con) => {
10611057
connect = con;
10621058
connect.onMessage((data) => {
@@ -1257,7 +1253,7 @@ export default class GMApi extends GM_Base {
12571253
onclose() {},
12581254
};
12591255

1260-
this.sendMessage("GM_openInTab", [url, option]).then((id) => {
1256+
this.sendMessage("GM_openInTab", [url, option as GMTypes.SWOpenTabOptions]).then((id) => {
12611257
if (!this.EE) return;
12621258
if (id) {
12631259
tabid = id;
@@ -1338,7 +1334,7 @@ export default class GMApi extends GM_Base {
13381334
}
13391335

13401336
@GMContext.API({})
1341-
GM_setClipboard(data: string, info?: string | { type?: string; mimetype?: string }, cb?: () => void) {
1337+
GM_setClipboard(data: string, info?: GMTypes.GMClipboardInfo, cb?: () => void) {
13421338
if (this.isInvalidContext()) return;
13431339
this.sendMessage("GM_setClipboard", [data, info])
13441340
.then(() => {

0 commit comments

Comments
 (0)