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 { try {
$key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" $key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ"
$uninstallString = $key.UninstallString $uninstallString = $key.UninstallString
throw "get QQ path error:"
return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe" return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe"
} catch { } catch {
throw "get QQ path error: $_" throw "get QQ path error: $_"

View File

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

View File

@ -63,9 +63,10 @@ export class RequestUtil {
try { try {
let response; let response;
if (method.toUpperCase() === 'POST') { 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 { } else {
response = await fetch(url, { ...requestInit }); response = await fetch(url, { method: method, ...requestInit });
} }
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); 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' 'referrer': 'https://napcat.demo.cn/login?type=onebot11'
} }
}; };
await RequestUtil.HttpGetText('https://napcat.wumiao.wang/api/send', try {
'POST', await RequestUtil.HttpGetText('https://napcat.wumiao.wang/api/send',
StatesData, { 'POST',
'Content-Type': 'application/json', JSON.stringify(StatesData), {
'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' '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); });
resolve(true);
} catch {
reject('umami post failed')
}
}); });
} }