3 Commits
1.6 ... 1.6.50

Author SHA1 Message Date
HolographicHat
4417feab53 encode uri to avoid charset problem 2022-04-17 23:46:11 +08:00
HolographicHat
28080dbafd fix 2022-04-17 22:54:35 +08:00
HolographicHat
a8b6419157 Update README.md 2022-04-16 21:52:50 +08:00
7 changed files with 25 additions and 33 deletions

View File

@@ -36,3 +36,6 @@
4. Q: 原神进门后没有自动退出,程序输出停留在“加载完成” 4. Q: 原神进门后没有自动退出,程序输出停留在“加载完成”
A: 关闭代理后重试 A: 关闭代理后重试
5. Q: 网络错误,请检查网络后重试 (21-x)
A: 如果你是校园网用户使用流量上网并重试如果你是海外用户打开config.json将oversea_api的值设置为true并重试

View File

@@ -2,8 +2,8 @@ const fs = require("fs")
const axios = require("axios") const axios = require("axios")
const readline = require("readline") const readline = require("readline")
const { randomUUID } = require("crypto") const { randomUUID } = require("crypto")
const { loadCache, log } = require("./utils") const { loadCache, log, openUrl } = require("./utils")
const { openUrl, checkSnapFastcall, copyToClipboard } = require("./native") const { checkSnapFastcall, copyToClipboard } = require("./native")
const exportToSeelie = proto => { const exportToSeelie = proto => {
const out = { achievements: {} } const out = { achievements: {} }

View File

@@ -1,28 +1,19 @@
#include "utils.h" #include "utils.h"
#include "define.h" #include "define.h"
string GBKToUTF8(const wstring& src) { wstring StringToWString(const string &src, UINT codePage) {
int len = WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr); int len = MultiByteToWideChar(codePage, 0, src.c_str(), -1, nullptr, 0);
auto *buffer = new CHAR[len];
WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, buffer, len, nullptr, nullptr);
string strTemp(buffer);
delete[] buffer;
return strTemp;
}
wstring StringToWString(const string &src) {
int len = MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, nullptr, 0);
auto *buffer = new WCHAR[len]; auto *buffer = new WCHAR[len];
MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, buffer, len); MultiByteToWideChar(codePage, 0, src.c_str(), -1, buffer, len);
wstring strTemp(buffer); wstring strTemp(buffer);
delete[] buffer; delete[] buffer;
return strTemp; return strTemp;
} }
string WStringToString(const wstring &src) { string WStringToString(const wstring &src, UINT codePage) {
int len = WideCharToMultiByte(CP_ACP, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr); int len = WideCharToMultiByte(codePage, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr);
auto *buffer = new CHAR[len]; auto *buffer = new CHAR[len];
WideCharToMultiByte(CP_ACP, 0, src.c_str(), -1, buffer, len, nullptr, nullptr); WideCharToMultiByte(codePage, 0, src.c_str(), -1, buffer, len, nullptr, nullptr);
string strTemp(buffer); string strTemp(buffer);
delete[] buffer; delete[] buffer;
return strTemp; return strTemp;
@@ -51,11 +42,7 @@ LSTATUS OpenFile(Env env, Napi::String &result, HWND parent) {
open.lpstrFilter = L"国服/国际服主程序 (YuanShen/GenshinImpact.exe)\0YuanShen.exe;GenshinImpact.exe\0"; open.lpstrFilter = L"国服/国际服主程序 (YuanShen/GenshinImpact.exe)\0YuanShen.exe;GenshinImpact.exe\0";
open.lStructSize = sizeof(open); open.lStructSize = sizeof(open);
if(GetOpenFileName(&open)) { if(GetOpenFileName(&open)) {
if (GetACP() == 936) { result = GetACP() == 936 ? Napi::String::New(env, WStringToString(file, CP_UTF8)) : Napi::String::New(env, WStringToString(file));
result = Napi::String::New(env, GBKToUTF8(file));
} else {
result = Napi::String::New(env, WStringToString(file));
}
return ERROR_SUCCESS; return ERROR_SUCCESS;
} else { } else {
return ERROR_ERRORS_ENCOUNTERED; return ERROR_ERRORS_ENCOUNTERED;

View File

@@ -2,8 +2,8 @@
#include "define.h" #include "define.h"
string WStringToString(const wstring &src); string WStringToString(const wstring &src, UINT codePage = CP_ACP);
wstring StringToWString(const string &src); wstring StringToWString(const string &src, UINT codePage = CP_ACP);
LSTATUS OpenFile(Env env, Napi::String &result, HWND parent = GetConsoleWindow()); LSTATUS OpenFile(Env env, Napi::String &result, HWND parent = GetConsoleWindow());
BOOL EnablePrivilege(Env env, const wstring &name); BOOL EnablePrivilege(Env env, const wstring &name);
void Log(Env env, const string &msg); void Log(Env env, const string &msg);

View File

@@ -36,22 +36,22 @@ const cleanUp = () => {
const c = { const c = {
finalName: `${name}-Win7`, forWin7: false,
nodeVersion: "14.19.1",
sevenZipPath: "\"C:/Program Files/7-Zip/7z.exe\"" sevenZipPath: "\"C:/Program Files/7-Zip/7z.exe\""
}; };
(async () => { (async () => {
console.log(c) const fn = c.forWin7 ? `${name}-Win7` : name
const nv = c.forWin7 ? "14.19.1" : "16.14.2"
log("Generate and compile version info") log("Generate and compile version info")
generateAndCompileVersionInfo() generateAndCompileVersionInfo()
log("Modify executable file resources") log("Modify executable file resources")
const path = `C:/Users/holog/.pkg-cache/v3.3/built-v${c.nodeVersion}-win-x64` const path = `C:/Users/holog/.pkg-cache/v3.3/built-v${nv}-win-x64`
generateScript(path) generateScript(path)
execSync(`rh.exe -script tmp.script`) execSync(`rh.exe -script tmp.script`)
cleanUp() cleanUp()
log("Build and compress package") log("Build and compress package")
await pkg.exec(`../app.js -t node${c.nodeVersion.split(".")[0]}-win-x64 -C Brotli --build -o ${c.finalName}.exe`.split(" ")) await pkg.exec(`../app.js -t node${nv.split(".")[0]}-win-x64 -C Brotli --build -o ${fn}.exe`.split(" "))
execSync(`${c.sevenZipPath} a ${c.finalName}.7z ${c.finalName}.exe -mx=9 -myx=9 -mmt=4 -sdel -stl`) execSync(`${c.sevenZipPath} a ${fn}.7z ${fn}.exe -mx=9 -myx=9 -mmt=4 -sdel -stl`)
log("Done") log("Done")
})() })()

View File

@@ -122,6 +122,8 @@ const checkPortIsUsing = () => {
} }
} }
const openUrl = url => native.openUrl(encodeURI(url))
const splitPacket = buf => { const splitPacket = buf => {
let offset = 0 let offset = 0
let arr = [] let arr = []
@@ -290,5 +292,5 @@ class KPacket {
module.exports = { module.exports = {
log, encodeProto, decodeProto, initConfig, splitPacket, upload, brotliCompressSync, brotliDecompressSync, log, encodeProto, decodeProto, initConfig, splitPacket, upload, brotliCompressSync, brotliDecompressSync,
setupHost, loadCache, debug, checkUpdate, KPacket, checkGameIsRunning, checkPortIsUsing setupHost, loadCache, debug, checkUpdate, KPacket, checkGameIsRunning, checkPortIsUsing, openUrl
} }

View File

@@ -1,7 +1,7 @@
const version = { const version = {
code: 7, code: 7,
name: "1.6", name: "1.6.50",
isDev: false isDev: true
} }
module.exports = { version } module.exports = { version }