mirror of
https://github.com/wux1an/wxapkg.git
synced 2026-04-22 15:27:21 +08:00
feat: introduce a new detection method for mini-program installation path
This commit is contained in:
@@ -24,17 +24,16 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
@@ -74,7 +73,7 @@ jobs:
|
||||
run: .\upx-4.2.2-win64\upx.exe --best --lzma build\bin\${{ matrix.artifact_name }}.exe
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.artifact_name }}
|
||||
path: build/bin/${{ matrix.upload_name }}
|
||||
@@ -87,12 +86,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
bin
|
||||
frontend/dist
|
||||
frontend/node_modules
|
||||
frontend/package.json.md5
|
||||
build/linux/appimage/build
|
||||
build/windows/nsis/MicrosoftEdgeWebview2Setup.exe
|
||||
.idea
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
## ⚒️ 安装
|
||||
|
||||
直接从 [Releases](https://github.com/wux1an/wxapkg/releases) 下载对应平台的预编译版本,双击运行即可。
|
||||
直接从 [Releases](https://github.com/wux1an/wxapkg/releases/latest) 下载对应平台的预编译版本,双击运行即可。
|
||||
|
||||
## 🛠️ 自行编译
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
76b526931f8dba5372a5c35a12d5edac
|
||||
@@ -42,6 +42,7 @@ function openFolder(folder: string) {
|
||||
function confirmScan(path: ScanPathItem) {
|
||||
AppService.ScanWxapkgItem(path.path, path.scan)
|
||||
.then((v: WxapkgItem[]) => {
|
||||
if (!v) v = []
|
||||
wxapkgItems.value = v
|
||||
toast.info('扫描小程序完成', `共 ${v.length} 个结果`)
|
||||
})
|
||||
|
||||
@@ -122,7 +122,7 @@ watch(visible, (newValue) => {
|
||||
<div class="log-box" v-if="!loading && scanResult?.Logs?.trim()">
|
||||
<button class="log-toggle" @click="logsExpanded = !logsExpanded">
|
||||
<i class="pi" :class="logsExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
|
||||
{{ logsExpanded ? '收起' : '展开' }}检测日志
|
||||
{{ logsExpanded ? '收起' : '展开' }}检测日志 · 未找到目录?请先在微信中打开任意小程序触发目录创建
|
||||
</button>
|
||||
<pre v-if="logsExpanded" class="log-content">{{ scanResult.Logs }}</pre>
|
||||
</div>
|
||||
|
||||
+36
-13
@@ -3,6 +3,7 @@
|
||||
package wechat
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -16,33 +17,55 @@ func (m *macosPlatform) GetDefaultPaths() PathScanResult {
|
||||
var b strings.Builder
|
||||
log := func(line string) { b.WriteString(line + "\n") }
|
||||
|
||||
var result []string
|
||||
var paths []string
|
||||
|
||||
userHomeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log("获取用户目录失败: " + err.Error())
|
||||
return PathScanResult{Paths: result, Logs: b.String()}
|
||||
return PathScanResult{Paths: paths, Logs: b.String()}
|
||||
}
|
||||
|
||||
// v3
|
||||
// ── Step 1: 微信 v3 ──
|
||||
v3Path := filepath.Join(userHomeDir, "Library/Containers/com.tencent.xinWeChat/Data/.wxapplet/packages")
|
||||
log("1. 检测 v3\n 路径: " + v3Path)
|
||||
if fileInfo, err := os.Stat(v3Path); err == nil && fileInfo.IsDir() {
|
||||
log(" 结果: 有效")
|
||||
result = append(result, v3Path)
|
||||
log(fmt.Sprintf("1. 【成功】检测微信 v3 (3.x 版本) - 成功\n 路径: %s", v3Path))
|
||||
paths = append(paths, v3Path)
|
||||
} else {
|
||||
log(" 结果: 目录不存在")
|
||||
log(fmt.Sprintf("1. 【失败】检测微信 v3 (3.x 版本) - 目录不存在\n 路径: %s", v3Path))
|
||||
}
|
||||
|
||||
// v4
|
||||
// ── Step 2: 微信 v4 ──
|
||||
v4Path := filepath.Join(userHomeDir, "Library/Containers/com.tencent.xinWeChat/Data/Documents/app_data/radium/Applet/packages")
|
||||
log("2. 检测 v4\n 路径: " + v4Path)
|
||||
if fileInfo, err := os.Stat(v4Path); err == nil && fileInfo.IsDir() {
|
||||
log(" 结果: 有效")
|
||||
result = append(result, v4Path)
|
||||
log(fmt.Sprintf("2. 【成功】检测微信 v4 (4.x 版本) - 成功\n 路径: %s", v4Path))
|
||||
paths = append(paths, v4Path)
|
||||
} else {
|
||||
log(" 结果: 目录不存在")
|
||||
log(fmt.Sprintf("2. 【失败】检测微信 v4 (4.x 版本) - 目录不存在\n 路径: %s", v4Path))
|
||||
}
|
||||
|
||||
return PathScanResult{Paths: result, Logs: b.String()}
|
||||
// ── Step 3: 微信 v4 多用户 ──
|
||||
v4UsersPath := filepath.Join(userHomeDir, "Library/Containers/com.tencent.xinWeChat/Data/Documents/app_data/radium/users")
|
||||
entries, err := os.ReadDir(v4UsersPath)
|
||||
if err != nil {
|
||||
log(fmt.Sprintf("3. 【失败】检测微信 v4 多用户 (4.x 版本) - 目录不存在\n 路径: %s", v4UsersPath))
|
||||
} else {
|
||||
var found []string
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
userAppletPath := filepath.Join(v4UsersPath, entry.Name(), "applet", "packages")
|
||||
if fileInfo, err := os.Stat(userAppletPath); err == nil && fileInfo.IsDir() {
|
||||
paths = append(paths, userAppletPath)
|
||||
found = append(found, entry.Name())
|
||||
}
|
||||
}
|
||||
if len(found) == 0 {
|
||||
log(fmt.Sprintf("3. 【失败】检测微信 v4 多用户 (4.x 版本) - 未找到有效用户\n 路径: %s", v4UsersPath))
|
||||
} else {
|
||||
log(fmt.Sprintf("3. 【成功】检测微信 v4 多用户 (4.x 版本) - 成功\n 路径: %s\n 有效用户: %s", v4UsersPath, strings.Join(found, ", ")))
|
||||
}
|
||||
}
|
||||
|
||||
return PathScanResult{Paths: paths, Logs: b.String()}
|
||||
}
|
||||
|
||||
+12
-18
@@ -21,50 +21,44 @@ func (m *windowsPlatform) GetDefaultPaths() PathScanResult {
|
||||
|
||||
var paths []string
|
||||
|
||||
// ── Step 1: v4 根目录 ──
|
||||
// ── Step 1: 微信 v4 根目录 ──
|
||||
appDataDir, _ := os.UserConfigDir()
|
||||
v4Path := filepath.Join(appDataDir, "Tencent", "xwechat", "radium", "Applet", "packages")
|
||||
log(fmt.Sprintf("1. 检测 v4 根目录\n 路径: %s", v4Path))
|
||||
if fileInfo, err := os.Stat(v4Path); err == nil && fileInfo.IsDir() {
|
||||
log(" 结果: 有效")
|
||||
log(fmt.Sprintf("1. 【成功】检测微信 v4 (4.x 版本) - 成功\n 路径: %s", v4Path))
|
||||
paths = append(paths, v4Path)
|
||||
} else {
|
||||
log(" 结果: 目录不存在")
|
||||
log(fmt.Sprintf("1. 【失败】检测微信 v4 (4.x 版本) - 目录不存在\n 路径: %s", v4Path))
|
||||
}
|
||||
|
||||
// ── Step 2: v3 注册表 ──
|
||||
log("2. 读取 v3 注册表\n 键: HKCU\\Software\\Tencent\\WeChat\\FileSavePath")
|
||||
// ── Step 2: 微信 v3 注册表 ──
|
||||
wechatKey, err := registry.OpenKey(registry.CURRENT_USER, `Software\Tencent\WeChat`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
log(" 结果: 读取失败")
|
||||
log("2. 【失败】检测微信 v3 (3.x 版本) - 未找到注册表项\n 键: HKCU\\Software\\Tencent\\WeChat\\FileSavePath")
|
||||
} else {
|
||||
defer wechatKey.Close()
|
||||
value, _, err := wechatKey.GetStringValue("FileSavePath")
|
||||
if err != nil {
|
||||
log(" 结果: 未找到该值")
|
||||
log("2. 【失败】检测微信 v3 (3.x 版本) - 未找到注册表值\n 键: HKCU\\Software\\Tencent\\WeChat\\FileSavePath")
|
||||
} else {
|
||||
log(fmt.Sprintf(" 原始值: %q", value))
|
||||
if value == "MyDocument:" {
|
||||
value = filepath.Join(os.Getenv("USERPROFILE"), "Documents")
|
||||
log(fmt.Sprintf(" 转换值: %s", value))
|
||||
}
|
||||
v3Path := filepath.Join(value, "WeChat Files")
|
||||
log(fmt.Sprintf(" 最终路径: %s", v3Path))
|
||||
if fileInfo, err := os.Stat(v3Path); err == nil && fileInfo.IsDir() {
|
||||
log(" 结果: 有效")
|
||||
log(fmt.Sprintf("2. 【成功】检测微信 v3 (3.x 版本) - 成功\n 键: HKCU\\Software\\Tencent\\WeChat\\FileSavePath\n 路径: %s", v3Path))
|
||||
paths = append(paths, v3Path)
|
||||
} else {
|
||||
log(" 结果: 目录不存在")
|
||||
log(fmt.Sprintf("2. 【失败】检测微信 v3 (3.x 版本) - 目录不存在\n 键: HKCU\\Software\\Tencent\\WeChat\\FileSavePath\n 路径: %s", v3Path))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Step 3: v4 users ──
|
||||
// ── Step 3: 微信 v4 多用户 ──
|
||||
usersDir := filepath.Join(appDataDir, "Tencent", "xwechat", "radium", "users")
|
||||
log(fmt.Sprintf("3. 扫描 v4 用户目录\n 路径: %s", usersDir))
|
||||
entries, err := os.ReadDir(usersDir)
|
||||
if err != nil || entries == nil {
|
||||
log(" 结果: 未找到")
|
||||
log(fmt.Sprintf("3. 【失败】检测微信 v4 多用户 (4.x 版本) - 目录不存在\n 路径: %s", usersDir))
|
||||
} else {
|
||||
var found []string
|
||||
for _, entry := range entries {
|
||||
@@ -78,9 +72,9 @@ func (m *windowsPlatform) GetDefaultPaths() PathScanResult {
|
||||
}
|
||||
}
|
||||
if len(found) == 0 {
|
||||
log(" 结果: 未找到有效用户")
|
||||
log(fmt.Sprintf("3. 【失败】检测微信 v4 多用户 (4.x 版本) - 未找到有效用户\n 路径: %s", usersDir))
|
||||
} else {
|
||||
log(fmt.Sprintf(" 有效用户: %v", found))
|
||||
log(fmt.Sprintf("3. 【成功】检测微信 v4 多用户 (4.x 版本) - 成功\n 路径: %s\n 有效用户: %s", usersDir, strings.Join(found, ", ")))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user