mirror of
https://github.com/HolographicHat/Yae.git
synced 2026-03-19 02:49:47 +08:00
encode uri to avoid charset problem
This commit is contained in:
@@ -2,8 +2,8 @@ const fs = require("fs")
|
||||
const axios = require("axios")
|
||||
const readline = require("readline")
|
||||
const { randomUUID } = require("crypto")
|
||||
const { loadCache, log } = require("./utils")
|
||||
const { openUrl, checkSnapFastcall, copyToClipboard } = require("./native")
|
||||
const { loadCache, log, openUrl } = require("./utils")
|
||||
const { checkSnapFastcall, copyToClipboard } = require("./native")
|
||||
|
||||
const exportToSeelie = proto => {
|
||||
const out = { achievements: {} }
|
||||
|
||||
@@ -171,9 +171,7 @@ namespace native {
|
||||
|
||||
Value openUrl(const CallbackInfo &info) {
|
||||
Env env = info.Env();
|
||||
string nUrl = info[0].As<Napi::String>().Utf8Value();
|
||||
wstring url = GetACP() == 936 ? StringToWString(nUrl, CP_UTF8) : StringToWString(nUrl);
|
||||
Log(env, L"openUrl: " + url);
|
||||
wstring url = StringToWString(info[0].As<Napi::String>().Utf8Value());
|
||||
HINSTANCE retcode = ShellExecute(GetConsoleWindow(), L"open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
|
||||
return Napi::Number::New(env, (INT_PTR)retcode); // NOLINT(cppcoreguidelines-narrowing-conversions)
|
||||
}
|
||||
|
||||
@@ -42,11 +42,7 @@ LSTATUS OpenFile(Env env, Napi::String &result, HWND parent) {
|
||||
open.lpstrFilter = L"国服/国际服主程序 (YuanShen/GenshinImpact.exe)\0YuanShen.exe;GenshinImpact.exe\0";
|
||||
open.lStructSize = sizeof(open);
|
||||
if(GetOpenFileName(&open)) {
|
||||
if (GetACP() == 936) {
|
||||
result = Napi::String::New(env, WStringToString(file, CP_UTF8));
|
||||
} else {
|
||||
result = Napi::String::New(env, WStringToString(file));
|
||||
}
|
||||
result = GetACP() == 936 ? Napi::String::New(env, WStringToString(file, CP_UTF8)) : Napi::String::New(env, WStringToString(file));
|
||||
return ERROR_SUCCESS;
|
||||
} else {
|
||||
return ERROR_ERRORS_ENCOUNTERED;
|
||||
|
||||
4
utils.js
4
utils.js
@@ -122,6 +122,8 @@ const checkPortIsUsing = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const openUrl = url => native.openUrl(encodeURI(url))
|
||||
|
||||
const splitPacket = buf => {
|
||||
let offset = 0
|
||||
let arr = []
|
||||
@@ -290,5 +292,5 @@ class KPacket {
|
||||
|
||||
module.exports = {
|
||||
log, encodeProto, decodeProto, initConfig, splitPacket, upload, brotliCompressSync, brotliDecompressSync,
|
||||
setupHost, loadCache, debug, checkUpdate, KPacket, checkGameIsRunning, checkPortIsUsing
|
||||
setupHost, loadCache, debug, checkUpdate, KPacket, checkGameIsRunning, checkPortIsUsing, openUrl
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user