Skip to content

Commit

Permalink
fix: 修复GM_xmlhttpRequest的content_type问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SSmJaE committed Mar 18, 2023
1 parent 5591f67 commit b60e57e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/api/welearn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class WELearnAPI {
}

// @requestErrorHandler("上传失败")
@perSession("HAS_UPLOAD")
static async upload(byUser = false) {
const response = await request.post<ICommonResponse>("/upload/", {
body: {
Expand Down
6 changes: 5 additions & 1 deletion src/utils/polyfill/request/implement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export function requestForUserscript<T = any>(
GM_xmlhttpRequest({
url: getFullUrl(url, query),
method: method as any,
headers,
// GM_xmlhttpRequest需要手动设置Content-Type,不然默认是text/plain,后端无法识别
headers: {
"Content-Type": "application/json;charset=UTF-8",
...headers,
},
data: typeof body === "object" ? JSON.stringify(body) : body,
timeout: 5000,
responseType: "json",
Expand Down
7 changes: 6 additions & 1 deletion src/views/components/PopOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export default function PopOver({
],
});

const hover = useHover(context);
const hover = useHover(context, {
delay: {
// open: 200,
close: 250,
},
});

const { getReferenceProps, getFloatingProps } = useInteractions([hover]);

Expand Down

0 comments on commit b60e57e

Please sign in to comment.