Merge pull request #65 from yunxilyf/main

fix:修复初始化的时候获取微信启动路径出现错误问题
This commit is contained in:
xuncha
2026-01-21 18:34:25 +08:00
committed by GitHub
4 changed files with 46 additions and 42 deletions

View File

@@ -16,7 +16,7 @@ jobs:
- name: Check out git repository - name: Check out git repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Install Node.js - name: Install Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
@@ -32,51 +32,20 @@ jobs:
run: | run: |
VERSION=${GITHUB_REF_NAME#v} VERSION=${GITHUB_REF_NAME#v}
echo "Syncing package.json version to $VERSION" echo "Syncing package.json version to $VERSION"
npm version $VERSION --no-git-tag-version npm version $VERSION --no-git-tag-version --allow-same-version
- name: Build Frontend & Type Check - name: Build Frontend & Type Check
run: | run: |
npx tsc npx tsc
npx vite build npx vite build
- name: Build Changelog - name: Inject Configuration
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
outputFile: "release-notes.md"
configurationJson: |
{
"template": "# v${{ github.ref_name }} 更新日志\n\n{{CHANGELOG}}\n\n---\n> 此更新由系统自动构建",
"categories": [
{
"title": "## 新功能",
"filter": { "pattern": "^feat.*:.*", "flags": "i" }
},
{
"title": "## 修复",
"filter": { "pattern": "^fix.*:.*", "flags": "i" }
},
{
"title": "## 性能与维护",
"filter": { "pattern": "^(chore|docs|perf|refactor|ci|style|test).*:.*", "flags": "i" }
}
],
"ignore_labels": [],
"commitMode": true,
"empty_summary": "## 更新详情\n- 常规代码优化与维护"
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check Changelog Content
shell: bash shell: bash
run: | run: |
echo "=== RELEASE NOTES CONTENT START ===" npm pkg set build.releaseInfo.releaseNotes="修复了一些已知问题"
cat release-notes.md
echo "=== RELEASE NOTES CONTENT END ==="
- name: Package and Publish - name: Package and Publish
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
npx electron-builder --publish always -c.releaseInfo.releaseNotesFile=release-notes.md npx electron-builder --publish always

View File

@@ -33,6 +33,7 @@ export class KeyService {
private ReadProcessMemory: any = null private ReadProcessMemory: any = null
private MEMORY_BASIC_INFORMATION: any = null private MEMORY_BASIC_INFORMATION: any = null
private TerminateProcess: any = null private TerminateProcess: any = null
private QueryFullProcessImageNameW: any = null
// User32 // User32
private EnumWindows: any = null private EnumWindows: any = null
@@ -194,6 +195,7 @@ export class KeyService {
this.OpenProcess = this.kernel32.func('OpenProcess', 'HANDLE', ['uint32', 'bool', 'uint32']) this.OpenProcess = this.kernel32.func('OpenProcess', 'HANDLE', ['uint32', 'bool', 'uint32'])
this.CloseHandle = this.kernel32.func('CloseHandle', 'bool', ['HANDLE']) this.CloseHandle = this.kernel32.func('CloseHandle', 'bool', ['HANDLE'])
this.TerminateProcess = this.kernel32.func('TerminateProcess', 'bool', ['HANDLE', 'uint32']) this.TerminateProcess = this.kernel32.func('TerminateProcess', 'bool', ['HANDLE', 'uint32'])
this.QueryFullProcessImageNameW = this.kernel32.func('QueryFullProcessImageNameW', 'bool', ['HANDLE', 'uint32', this.koffi.out('uint16*'), this.koffi.out('uint32*')])
this.VirtualQueryEx = this.kernel32.func('VirtualQueryEx', 'uint64', ['HANDLE', 'uint64', this.koffi.out(this.koffi.pointer(this.MEMORY_BASIC_INFORMATION)), 'uint64']) this.VirtualQueryEx = this.kernel32.func('VirtualQueryEx', 'uint64', ['HANDLE', 'uint64', this.koffi.out(this.koffi.pointer(this.MEMORY_BASIC_INFORMATION)), 'uint64'])
this.ReadProcessMemory = this.kernel32.func('ReadProcessMemory', 'bool', ['HANDLE', 'uint64', 'void*', 'uint64', this.koffi.out(this.koffi.pointer('uint64'))]) this.ReadProcessMemory = this.kernel32.func('ReadProcessMemory', 'bool', ['HANDLE', 'uint64', 'void*', 'uint64', this.koffi.out(this.koffi.pointer('uint64'))])
@@ -310,7 +312,46 @@ export class KeyService {
} }
} }
private async getProcessExecutablePath(pid: number): Promise<string | null> {
if (!this.ensureKernel32()) return null
// 0x1000 = PROCESS_QUERY_LIMITED_INFORMATION
const hProcess = this.OpenProcess(0x1000, false, pid)
if (!hProcess) return null
try {
const sizeBuf = Buffer.alloc(4)
sizeBuf.writeUInt32LE(1024, 0)
const pathBuf = Buffer.alloc(1024 * 2)
const ret = this.QueryFullProcessImageNameW(hProcess, 0, pathBuf, sizeBuf)
if (ret) {
const len = sizeBuf.readUInt32LE(0)
return pathBuf.toString('ucs2', 0, len * 2)
}
return null
} catch (e) {
console.error('获取进程路径失败:', e)
return null
} finally {
this.CloseHandle(hProcess)
}
}
private async findWeChatInstallPath(): Promise<string | null> { private async findWeChatInstallPath(): Promise<string | null> {
// 0. 优先尝试获取正在运行的微信进程路径
try {
const pid = await this.findWeChatPid()
if (pid) {
const runPath = await this.getProcessExecutablePath(pid)
if (runPath && existsSync(runPath)) {
console.log('发现正在运行的微信进程,使用路径:', runPath)
return runPath
}
}
} catch (e) {
console.error('尝试获取运行中微信路径失败:', e)
}
// 1. Registry - Uninstall Keys // 1. Registry - Uninstall Keys
const uninstallKeys = [ const uninstallKeys = [
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall', 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',

6
package-lock.json generated
View File

@@ -8537,12 +8537,6 @@
"sherpa-onnx-win-x64": "^1.12.23" "sherpa-onnx-win-x64": "^1.12.23"
} }
}, },
"node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-darwin-x64": {
"optional": true
},
"node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-linux-arm64": {
"optional": true
},
"node_modules/sherpa-onnx-win-ia32": { "node_modules/sherpa-onnx-win-ia32": {
"version": "1.12.23", "version": "1.12.23",
"resolved": "https://registry.npmmirror.com/sherpa-onnx-win-ia32/-/sherpa-onnx-win-ia32-1.12.23.tgz", "resolved": "https://registry.npmmirror.com/sherpa-onnx-win-ia32/-/sherpa-onnx-win-ia32-1.12.23.tgz",

Binary file not shown.