refactor: scipt and request

This commit is contained in:
手瓜一十雪 2024-05-14 10:16:30 +08:00
parent 00a8715e58
commit 93cb662282
4 changed files with 14 additions and 11 deletions

View File

@ -2,7 +2,6 @@ function Get-QQpath {
try {
$key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ"
$uninstallString = $key.UninstallString
throw "get QQ path error:"
return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe"
} catch {
throw "get QQ path error: $_"

View File

@ -2,7 +2,6 @@ function Get-QQpath {
try {
$key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ"
$uninstallString = $key.UninstallString
throw "get QQ path error:"
return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe"
} catch {
throw "get QQ path error: $_"

View File

@ -63,9 +63,10 @@ export class RequestUtil {
try {
let response;
if (method.toUpperCase() === 'POST') {
response = await fetch(url, { ...requestInit, body: data });
//console.log({ method: 'POST', ...requestInit, body: data });
response = await fetch(url, { method: 'POST', ...requestInit, body: data });
} else {
response = await fetch(url, { ...requestInit });
response = await fetch(url, { method: method, ...requestInit });
}
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);

View File

@ -14,12 +14,16 @@ export async function postLoginStatus() {
'referrer': 'https://napcat.demo.cn/login?type=onebot11'
}
};
await RequestUtil.HttpGetText('https://napcat.wumiao.wang/api/send',
'POST',
StatesData, {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'
});
resolve(true);
try {
await RequestUtil.HttpGetText('https://napcat.wumiao.wang/api/send',
'POST',
JSON.stringify(StatesData), {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'
});
resolve(true);
} catch {
reject('umami post failed')
}
});
}