apk包含apk
This commit is contained in:
395
unpackage/dist/dev/app-plus/app-service.js
vendored
395
unpackage/dist/dev/app-plus/app-service.js
vendored
@@ -1,3 +1,9 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __publicField = (obj, key, value) => {
|
||||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
return value;
|
||||
};
|
||||
if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
|
||||
Promise.prototype.finally = function(callback) {
|
||||
const promise = this.constructor;
|
||||
@@ -11,19 +17,19 @@ if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
|
||||
}
|
||||
;
|
||||
if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
|
||||
const global = uni.requireGlobal();
|
||||
ArrayBuffer = global.ArrayBuffer;
|
||||
Int8Array = global.Int8Array;
|
||||
Uint8Array = global.Uint8Array;
|
||||
Uint8ClampedArray = global.Uint8ClampedArray;
|
||||
Int16Array = global.Int16Array;
|
||||
Uint16Array = global.Uint16Array;
|
||||
Int32Array = global.Int32Array;
|
||||
Uint32Array = global.Uint32Array;
|
||||
Float32Array = global.Float32Array;
|
||||
Float64Array = global.Float64Array;
|
||||
BigInt64Array = global.BigInt64Array;
|
||||
BigUint64Array = global.BigUint64Array;
|
||||
const global2 = uni.requireGlobal();
|
||||
ArrayBuffer = global2.ArrayBuffer;
|
||||
Int8Array = global2.Int8Array;
|
||||
Uint8Array = global2.Uint8Array;
|
||||
Uint8ClampedArray = global2.Uint8ClampedArray;
|
||||
Int16Array = global2.Int16Array;
|
||||
Uint16Array = global2.Uint16Array;
|
||||
Int32Array = global2.Int32Array;
|
||||
Uint32Array = global2.Uint32Array;
|
||||
Float32Array = global2.Float32Array;
|
||||
Float64Array = global2.Float64Array;
|
||||
BigInt64Array = global2.BigInt64Array;
|
||||
BigUint64Array = global2.BigUint64Array;
|
||||
}
|
||||
;
|
||||
if (uni.restoreGlobal) {
|
||||
@@ -38,6 +44,340 @@ if (uni.restoreGlobal) {
|
||||
console[type].apply(console, [...args, filename]);
|
||||
}
|
||||
}
|
||||
function isAndroid() {
|
||||
return uni.getSystemInfoSync().platform === "android";
|
||||
}
|
||||
if (typeof setTimeout === "undefined") {
|
||||
formatAppLog("log", "at utils/fileUtils.js:12", "setTimeout 未定义,添加 polyfill");
|
||||
global.setTimeout = function(callback, delay) {
|
||||
callback();
|
||||
};
|
||||
}
|
||||
async function moveChromeApkToDevice(options = {}) {
|
||||
const config = {
|
||||
sourcePath: "/static/apk/com.android.chrome.apk",
|
||||
targetDir: "yxd",
|
||||
targetFileName: "com.android.chrome.apk",
|
||||
...options
|
||||
};
|
||||
formatAppLog("log", "at utils/fileUtils.js:52", "开始移动APK文件,配置:", config);
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const srcPath = plus.io.convertLocalFileSystemURL(config.sourcePath);
|
||||
const targetDirPath = "_downloads/";
|
||||
formatAppLog("log", "at utils/fileUtils.js:60", "源文件路径:", srcPath);
|
||||
const internalStoragePath = "file:///storage/emulated/0/";
|
||||
formatAppLog("log", "at utils/fileUtils.js:64", "尝试使用内部存储目录:", internalStoragePath);
|
||||
plus.io.resolveLocalFileSystemURL(srcPath, (srcEntry) => {
|
||||
formatAppLog("log", "at utils/fileUtils.js:67", "找到源文件:", srcEntry.fullPath);
|
||||
plus.io.resolveLocalFileSystemURL(targetDirPath, (downloadDirEntry) => {
|
||||
formatAppLog("log", "at utils/fileUtils.js:110", "找到下载目录:", downloadDirEntry.fullPath);
|
||||
downloadDirEntry.getFile(config.targetFileName, {}, (existingFile) => {
|
||||
formatAppLog("log", "at utils/fileUtils.js:114", "找到已存在的 APK:", existingFile.fullPath);
|
||||
scanFile(existingFile.fullPath);
|
||||
resolve(existingFile);
|
||||
}, () => {
|
||||
srcEntry.copyTo(downloadDirEntry, config.targetFileName, (newEntry) => {
|
||||
formatAppLog("log", "at utils/fileUtils.js:121", "APK 复制成功:", newEntry.fullPath);
|
||||
scanFile(newEntry.fullPath);
|
||||
resolve(newEntry);
|
||||
}, (copyErr) => {
|
||||
formatAppLog("error", "at utils/fileUtils.js:125", "复制失败:", copyErr);
|
||||
reject(`复制失败: ${JSON.stringify(copyErr)}`);
|
||||
});
|
||||
});
|
||||
}, (dirErr) => {
|
||||
formatAppLog("error", "at utils/fileUtils.js:131", "获取公共下载目录失败,尝试应用私有目录:", dirErr);
|
||||
saveToPrivateDir(srcEntry, config, resolve, reject);
|
||||
});
|
||||
}, (srcErr) => {
|
||||
formatAppLog("error", "at utils/fileUtils.js:135", "访问源文件失败:", srcErr);
|
||||
reject(`访问源文件失败: ${JSON.stringify(srcErr)}`);
|
||||
});
|
||||
} catch (e) {
|
||||
formatAppLog("error", "at utils/fileUtils.js:139", "执行过程中发生异常:", e);
|
||||
reject(`执行过程中发生异常: ${e}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function scanFile(filePath) {
|
||||
if (!isAndroid())
|
||||
return;
|
||||
try {
|
||||
formatAppLog("log", "at utils/fileUtils.js:148", "开始扫描文件:", filePath);
|
||||
const Intent = plus.android.importClass("android.content.Intent");
|
||||
const Uri = plus.android.importClass("android.net.Uri");
|
||||
const File = plus.android.importClass("java.io.File");
|
||||
const main = plus.android.runtimeMainActivity();
|
||||
const intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(Uri.fromFile(new File(filePath)));
|
||||
main.sendBroadcast(intent);
|
||||
formatAppLog("log", "at utils/fileUtils.js:156", "文件扫描成功");
|
||||
} catch (e) {
|
||||
formatAppLog("error", "at utils/fileUtils.js:158", "文件扫描失败:", e);
|
||||
}
|
||||
}
|
||||
class ChromeBrowser {
|
||||
/**
|
||||
* 打开URL,自动处理浏览器
|
||||
* @param {string} url - 要打开的URL
|
||||
* @returns {Promise<boolean>} 是否成功处理
|
||||
*/
|
||||
static async openUrl(url) {
|
||||
if (!url) {
|
||||
formatAppLog("error", "at utils/chrome-browser.js:29", "ChromeBrowser: URL为空");
|
||||
return false;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
plus.runtime.openURL(url, async (err) => {
|
||||
if (err) {
|
||||
formatAppLog("log", "at utils/chrome-browser.js:36", "检测失败,Chrome 可能未安装:", err);
|
||||
try {
|
||||
const result = await this.installAndOpen(url);
|
||||
resolve(result);
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at utils/chrome-browser.js:42", "installAndOpen 失败:", error);
|
||||
resolve(false);
|
||||
}
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
}, "com.android.chrome");
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 使用谷歌浏览器打开URL
|
||||
* @param {string} url
|
||||
*/
|
||||
static openWithChrome(url) {
|
||||
plus.runtime.openURL(url, {
|
||||
pname: "Chrome"
|
||||
});
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 安装谷歌浏览器并打开URL
|
||||
* @param {string} url
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
static async installAndOpen(url) {
|
||||
try {
|
||||
const confirm = await this.showInstallConfirm();
|
||||
if (!confirm) {
|
||||
plus.runtime.openURL(url);
|
||||
return false;
|
||||
}
|
||||
const installed = await this.initWorkflow();
|
||||
if (installed) {
|
||||
this.hasChrome = true;
|
||||
uni.setStorageSync("has_chrome_browser", true);
|
||||
setTimeout(() => {
|
||||
this.openWithChrome(url);
|
||||
}, 1e3);
|
||||
return true;
|
||||
} else {
|
||||
plus.runtime.openURL(url);
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at utils/chrome-browser.js:102", "ChromeBrowser: 安装流程失败:", error);
|
||||
plus.runtime.openURL(url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 显示安装确认对话框
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
static showInstallConfirm() {
|
||||
return new Promise((resolve) => {
|
||||
uni.showModal({
|
||||
title: "安装谷歌浏览器",
|
||||
content: "检测到您未安装谷歌浏览器\n\n建议安装谷歌浏览器以获得最佳体验\n是否现在安装?",
|
||||
confirmText: "立即安装",
|
||||
cancelText: "使用其他浏览器",
|
||||
success: (res) => {
|
||||
resolve(res.confirm);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
static async initWorkflow() {
|
||||
return new Promise(async (resolve) => {
|
||||
try {
|
||||
const hasPermission = await this.requestAndroidPermission(
|
||||
"android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
);
|
||||
if (!hasPermission) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "请授予存储权限以保存安装包",
|
||||
showCancel: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: "正在准备资源..."
|
||||
});
|
||||
const result = await moveChromeApkToDevice();
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
title: "就绪",
|
||||
content: `安装包已保存至:Downloads/${result.name}`,
|
||||
confirmText: "去安装",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.installApk(result.fullPath, resolve);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
uni.hideLoading();
|
||||
formatAppLog("error", "at utils/chrome-browser.js:165", "流程失败:", e);
|
||||
uni.showToast({
|
||||
title: "操作失败: " + e,
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// 动态权限申请核心代码
|
||||
static requestAndroidPermission(permissionID) {
|
||||
return new Promise((resolve) => {
|
||||
plus.android.requestPermissions(
|
||||
[permissionID],
|
||||
(resultObj) => {
|
||||
if (resultObj.granted.length > 0) {
|
||||
resolve(true);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
formatAppLog("error", "at utils/chrome-browser.js:187", "权限请求错误:", error);
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 实时下载并安装
|
||||
* @param {Function} resolve
|
||||
*/
|
||||
static downloadAndInstall(resolve) {
|
||||
uni.showLoading({
|
||||
title: "正在下载...\n约十分钟",
|
||||
mask: true
|
||||
});
|
||||
const downloadUrl = "https://database.yuxindazhineng.com/user-file//690c72a6b8ffa329af2d5607/avatar/com.android.chrome.apk";
|
||||
const fileName = `_downloads/chrome_${Date.now()}.apk`;
|
||||
const dtask = plus.downloader.createDownload(
|
||||
downloadUrl,
|
||||
{
|
||||
filename: fileName
|
||||
},
|
||||
(d, status) => {
|
||||
uni.hideLoading();
|
||||
if (status === 200) {
|
||||
formatAppLog("log", "at utils/chrome-browser.js:217", "ChromeBrowser: 下载成功,开始安装");
|
||||
this.installApk(d.filename, resolve);
|
||||
} else {
|
||||
formatAppLog("error", "at utils/chrome-browser.js:220", "ChromeBrowser: 下载失败,状态码:", status);
|
||||
this.showDownloadError();
|
||||
resolve(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
dtask.start();
|
||||
}
|
||||
/**
|
||||
* 安装APK文件
|
||||
* @param {string} filePath
|
||||
* @param {Function} resolve
|
||||
*/
|
||||
static installApk(filePath, resolve) {
|
||||
uni.showLoading({
|
||||
title: "准备中...",
|
||||
mask: true
|
||||
});
|
||||
plus.runtime.install(
|
||||
filePath,
|
||||
{
|
||||
force: false
|
||||
},
|
||||
() => {
|
||||
uni.hideLoading();
|
||||
formatAppLog("log", "at utils/chrome-browser.js:247", "ChromeBrowser: 安装成功");
|
||||
uni.showToast({
|
||||
title: "准备完成",
|
||||
icon: "success",
|
||||
duration: 1500
|
||||
});
|
||||
resolve(true);
|
||||
},
|
||||
(error) => {
|
||||
uni.hideLoading();
|
||||
formatAppLog("error", "at utils/chrome-browser.js:257", "ChromeBrowser: 安装失败:", error);
|
||||
uni.removeStorageSync("chrome_apk_path");
|
||||
this.showInstallError(filePath);
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
}
|
||||
/**
|
||||
* 显示下载错误提示
|
||||
*/
|
||||
static showDownloadError() {
|
||||
uni.showModal({
|
||||
title: "下载失败",
|
||||
content: "无法下载谷歌浏览器\n请检查网络连接后重试",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 显示安装错误提示
|
||||
* @param {string} filePath
|
||||
*/
|
||||
static showInstallError(filePath) {
|
||||
uni.showModal({
|
||||
title: "安装失败",
|
||||
content: "自动安装失败\n请在文件管理中手动安装\n或退出应用后台重新进入下载",
|
||||
confirmText: "查看文件",
|
||||
success: (res) => {
|
||||
if (res.confirm && filePath) {
|
||||
plus.runtime.openFile(filePath);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 强制重新检查浏览器状态
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
static async forceCheck() {
|
||||
formatAppLog("log", "at utils/chrome-browser.js:299", "ChromeBrowser: 强制重新检查");
|
||||
this.hasChrome = null;
|
||||
return await this.init();
|
||||
}
|
||||
/**
|
||||
* 获取当前状态信息
|
||||
*/
|
||||
static getStatus() {
|
||||
return {
|
||||
hasChrome: this.hasChrome,
|
||||
apkDownloaded: this.apkDownloaded,
|
||||
apkPath: this.apkPath,
|
||||
cachedHasChrome: uni.getStorageSync("has_chrome_browser"),
|
||||
cachedApkPath: uni.getStorageSync("chrome_apk_path")
|
||||
};
|
||||
}
|
||||
}
|
||||
// 存储检查结果
|
||||
__publicField(ChromeBrowser, "hasChrome", null);
|
||||
__publicField(ChromeBrowser, "apkDownloaded", false);
|
||||
__publicField(ChromeBrowser, "apkPath", null);
|
||||
const _imports_0 = "/static/logo.png";
|
||||
const _export_sfc = (sfc, props) => {
|
||||
const target = sfc.__vccOpts || sfc;
|
||||
@@ -110,7 +450,7 @@ if (uni.restoreGlobal) {
|
||||
throw new Error(`接口请求失败,状态码:${res.statusCode}`);
|
||||
}
|
||||
const responseData = res.data;
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:175", responseData);
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:176", responseData);
|
||||
if (responseData.success) {
|
||||
if (rememberMe.value) {
|
||||
uni.setStorageSync("yxd_username", username.value);
|
||||
@@ -118,12 +458,12 @@ if (uni.restoreGlobal) {
|
||||
uni.removeStorageSync("yxd_username");
|
||||
}
|
||||
const domainData = responseData.data;
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:188", "完整域名:", domainData.full_domain);
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:189", "域名前缀:", domainData.domain_prefix);
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:189", "完整域名:", domainData.full_domain);
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:190", "域名前缀:", domainData.domain_prefix);
|
||||
redirectUrl.value = `http://${domainData.full_domain}`;
|
||||
setTimeout(() => {
|
||||
openExternalLink();
|
||||
}, 2e3);
|
||||
}, 1e3);
|
||||
} else {
|
||||
throw new Error(responseData.message || "登录失败,请检查账号密码");
|
||||
}
|
||||
@@ -133,11 +473,14 @@ if (uni.restoreGlobal) {
|
||||
isLoggingIn.value = false;
|
||||
}
|
||||
};
|
||||
function openExternalLink() {
|
||||
const openExternalLink = () => {
|
||||
if (!redirectUrl.value)
|
||||
return;
|
||||
plus.runtime.openURL(redirectUrl.value);
|
||||
}
|
||||
ChromeBrowser.openUrl(redirectUrl.value);
|
||||
setTimeout(() => {
|
||||
redirectUrl.value = null;
|
||||
}, 1e3);
|
||||
};
|
||||
const copyToClipboard = () => {
|
||||
if (!redirectUrl.value)
|
||||
return;
|
||||
@@ -157,9 +500,11 @@ if (uni.restoreGlobal) {
|
||||
username.value = savedUsername;
|
||||
rememberMe.value = true;
|
||||
}
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:268", "登录组件已挂载");
|
||||
formatAppLog("log", "at pages/light-theme/light-theme.vue:259", "登录组件已挂载");
|
||||
});
|
||||
const __returned__ = { username, password, rememberMe, showPassword, isLoggingIn, redirectUrl, copySuccess, usernameError, passwordError, loginError, toggleRememberMe, validateForm, clearError, handleLogin, openExternalLink, copyToClipboard, ref: vue.ref, onMounted: vue.onMounted };
|
||||
const __returned__ = { username, password, rememberMe, showPassword, isLoggingIn, redirectUrl, copySuccess, usernameError, passwordError, loginError, toggleRememberMe, validateForm, clearError, handleLogin, openExternalLink, copyToClipboard, ref: vue.ref, onMounted: vue.onMounted, get ChromeBrowser() {
|
||||
return ChromeBrowser;
|
||||
} };
|
||||
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
||||
return __returned__;
|
||||
}
|
||||
@@ -616,13 +961,13 @@ if (uni.restoreGlobal) {
|
||||
__definePage("pages/night-theme/night-theme", PagesNightThemeNightTheme);
|
||||
const _sfc_main = {
|
||||
onLaunch: function() {
|
||||
formatAppLog("log", "at App.vue:4", "App Launch");
|
||||
formatAppLog("log", "at App.vue:5", "App Launch");
|
||||
},
|
||||
onShow: function() {
|
||||
formatAppLog("log", "at App.vue:7", "App Show");
|
||||
formatAppLog("log", "at App.vue:8", "App Show");
|
||||
},
|
||||
onHide: function() {
|
||||
formatAppLog("log", "at App.vue:10", "App Hide");
|
||||
formatAppLog("log", "at App.vue:11", "App Hide");
|
||||
}
|
||||
};
|
||||
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/Projects/intelligentProject-phone/App.vue"]]);
|
||||
|
||||
Reference in New Issue
Block a user