feat:uniapp模块
This commit is contained in:
11
uniapp/scripts/adb-debug.ps1
Normal file
11
uniapp/scripts/adb-debug.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
# 用法:先启动 App,再运行此脚本
|
||||
adb devices
|
||||
Write-Host "`n=== 已安装的 uni 包 ==="
|
||||
adb shell pm list packages | findstr /i uni
|
||||
|
||||
Write-Host "`n=== 清空日志,请手动点开 App ==="
|
||||
adb logcat -c
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
Write-Host "`n=== 抓取 DCloud / 崩溃 / WebView 日志(30秒)==="
|
||||
adb logcat -v time -t 800 | findstr /i "dcloud uni jyuan UNIOPTICAL NIOPTICAL AndroidRuntime FATAL chromium bootstrap splash WebView loadUrl"
|
||||
26
uniapp/scripts/patch-app-config.js
Normal file
26
uniapp/scripts/patch-app-config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 强制 App 使用 webview 渲染,避免 renderer:auto 在部分设备上卡启动页。
|
||||
*/
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const root = path.resolve(__dirname, '..')
|
||||
|
||||
const targets = [
|
||||
path.join(root, 'dist/build/app/app-config-service.js'),
|
||||
path.join(root, 'dist/build/app-plus/app-config-service.js')
|
||||
]
|
||||
|
||||
for (const file of targets) {
|
||||
if (!fs.existsSync(file)) continue
|
||||
let content = fs.readFileSync(file, 'utf8')
|
||||
const next = content
|
||||
.replace(/"renderer":"auto"/g, '"renderer":"webview"')
|
||||
.replace(/"waiting":true/g, '"waiting":false')
|
||||
if (next !== content) {
|
||||
fs.writeFileSync(file, next, 'utf8')
|
||||
console.log('[patch-app-config] patched', path.relative(root, file))
|
||||
}
|
||||
}
|
||||
40
uniapp/scripts/patch-app-manifest.js
Normal file
40
uniapp/scripts/patch-app-manifest.js
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* CLI 构建 app manifest 中 splashscreen.autoclose 恒为 false,打包后补丁修正。
|
||||
* HBuilderX 云打包会读取 dist/build/app 或 app-plus 下的 manifest.json。
|
||||
*/
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const root = path.resolve(__dirname, '..')
|
||||
|
||||
const targets = [
|
||||
path.join(root, 'dist/build/app/manifest.json'),
|
||||
path.join(root, 'dist/build/app-plus/manifest.json')
|
||||
]
|
||||
|
||||
for (const file of targets) {
|
||||
if (!fs.existsSync(file)) continue
|
||||
const manifest = JSON.parse(fs.readFileSync(file, 'utf8'))
|
||||
if (manifest.plus) {
|
||||
manifest.plus.splashscreen = {
|
||||
...(manifest.plus.splashscreen || {}),
|
||||
autoclose: true,
|
||||
waiting: false,
|
||||
delay: 0
|
||||
}
|
||||
manifest.plus.renderer = 'webview'
|
||||
manifest.plus.compatible = { ignoreVersion: true }
|
||||
manifest.plus.distribute = manifest.plus.distribute || {}
|
||||
manifest.plus.distribute.google = {
|
||||
...(manifest.plus.distribute.google || {}),
|
||||
packagename: 'com.jyuan.optical'
|
||||
}
|
||||
if (manifest.plus['uni-app']) {
|
||||
manifest.plus['uni-app'].renderer = 'webview'
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(file, JSON.stringify(manifest, null, 2), 'utf8')
|
||||
console.log('[patch-app-manifest] patched', path.relative(root, file))
|
||||
}
|
||||
33
uniapp/scripts/verify-apk.ps1
Normal file
33
uniapp/scripts/verify-apk.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
# 用法:.\scripts\verify-apk.ps1 "D:\path\to\app.apk"
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ApkPath
|
||||
)
|
||||
|
||||
if (-not (Test-Path $ApkPath)) {
|
||||
Write-Error "APK 不存在: $ApkPath"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$sdk = $env:ANDROID_HOME
|
||||
if (-not $sdk) { $sdk = "$env:LOCALAPPDATA\Android\Sdk" }
|
||||
|
||||
$aapt = Get-ChildItem -Path "$sdk\build-tools" -Recurse -Filter "aapt.exe" -ErrorAction SilentlyContinue |
|
||||
Sort-Object FullName -Descending |
|
||||
Select-Object -First 1
|
||||
|
||||
Write-Host "=== APK 文件 ==="
|
||||
Write-Host $ApkPath
|
||||
Write-Host ""
|
||||
|
||||
if ($aapt) {
|
||||
Write-Host "=== 包名(aapt dump badging)==="
|
||||
& $aapt.FullName dump badging $ApkPath | Select-String "package:|launchable-activity"
|
||||
} else {
|
||||
Write-Host "未找到 aapt.exe(Android SDK build-tools)。"
|
||||
Write-Host "请在 HBuilderX 中打开 src/manifest.json -> 基础配置 -> Android包名,确认是否为 com.jyuan.optical"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "=== 手机已安装的相关包 ==="
|
||||
adb shell pm list packages | findstr /i "uni jyuan optical"
|
||||
Reference in New Issue
Block a user