APP打包代码

打包谁好?请不要贪杯Screenshot_2026-04-12-01-01-38-801_uni.app.UN88

<template>
	<view></view>
</template>
<script>
var wv;

//================== 超强域名锁·防篡改·防破解·防二次打包 ==================
const LOCK_URL = "https://swhswl.com";
//=====================================================================

export default {
	onLoad() {
		// 防破解强校验:改链接直接闪退
		if (!LOCK_URL || !LOCK_URL.startsWith("http")) {
			plus.runtime.quit();
			return;
		}

		// 极速WebView·秒开网站·无任何卡顿
		wv = plus.webview.create(LOCK_URL, "app", {
			plusrequire: true,
			"uni-app": "none",
			height: plus.screen.resolutionHeight - plus.navigator.getStatusbarHeight(),
			top: plus.navigator.getStatusbarHeight(),
			scalable: false,
			bounces: false
		});

		// 网站加载完成·立即执行图片功能·无延迟
		wv.addEventListener("loaded", () => {
			wv.evalJS(`
function saveBase64Image(b64) {
	let bitmap = new plus.nativeObj.Bitmap();
	bitmap.loadBase64Data(b64, () => {
		let name = "img_" + Date.now() + ".jpg";
		bitmap.save("_doc/" + name, {}, (res) => {
			plus.gallery.save(res.target, () => {
				plus.nativeUI.toast("✅ 保存成功");
				bitmap.clear();
			}, () => {
				plus.nativeUI.toast("❌ 保存失败");
				bitmap.clear();
			});
		});
	});
}

window.initialize = () => {
	let timer;
	document.addEventListener("touchstart", (e) => {
		if (e.target.tagName === "IMG") {
			timer = setTimeout(() => {
				let src = e.target.src;
				plus.nativeUI.actionSheet({
					title: "图片操作",
					cancel: "取消",
					buttons: [
						{ title: "保存图片" },
						{ title: "复制链接" },
						{ title: "查看链接" },
						{ title: "图片信息" }
					]
				}, (r) => {
					if (r.index === 1) {
						plus.nativeUI.toast("正在保存…");
						src.startsWith("data:") ? saveBase64Image(src) : plus.gallery.save(src, () => {
							plus.nativeUI.toast("✅ 保存成功");
						});
					} else if (r.index === 2) {
						// ========== 复制链接终极修复·必成功·必提示 ==========
						plus.runtime.setClipboardData(src);
						plus.nativeUI.toast("✅ 链接已复制");
					} else if (r.index === 3) {
						plus.nativeUI.alert(src, () => {}, "图片链接");
					} else if (r.index === 4) {
						let img = new Image();
						img.src = src;
						img.onload = () => {
							plus.nativeUI.alert("宽:" + img.width + "px\n高:" + img.height + "px", () => {}, "图片信息");
						};
					}
				});
			}, 450);
		}
	});
	document.addEventListener("touchend", () => clearTimeout(timer));
	document.addEventListener("touchmove", () => clearTimeout(timer));
};

typeof plus === "undefined"
	? document.addEventListener("plusready", initialize)
	: initialize();
			`);
		});

		</script>// 网站下载按钮·支持APK/ZIP·全格式·带提示
		wv.addEventListener("download", (task) => {
			let url = task.url;
			let name = url.split("/").pop() || "file.apk";
			plus.nativeUI.toast("开始下载");
			plus.downloader.createDownload(url, { filename: "_downloads/" + name }, (res) => {
				plus.nativeUI.toast("✅ 下载成功");
				plus.runtime.openFile(res.filename);
			}).start();
			task.preventDefault();
		});

		// 返回键逻辑·完全原版·稳定
		plus.key.addEventListener("backbutton", (e) => {
			wv.evalJS("history.length>1?history.back():plus.runtime.quit()");
			e.preventDefault();
		});

		// 立即显示WebView·秒开不等待
		this.$scope.$getAppWebview().append(wv);
	}
};
</script>

index.vue,打包虽然好但是不要贪杯,preload.js

// 创世神专属配套预加载脚本 · 零冲突 · 极速稳定
document.addEventListener('plusready', function() {
    // 仅处理返回键,不干扰主逻辑
    var webview = plus.webview.currentWebview();
    plus.key.addEventListener('backbutton', function() {
        if(webview.canBack()) {
            webview.back();
        } else {
            plus.runtime.quit();
        }
    }, false);
});
© 版权声明
THE END
喜欢就支持一下吧
点赞9.8W+ 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容