2 lines
4.7 KiB
JavaScript
2 lines
4.7 KiB
JavaScript
if("undefined"==typeof Promise||Promise.prototype.finally||(Promise.prototype.finally=function(e){const t=this.constructor;return this.then((o=>t.resolve(e()).then((()=>o))),(o=>t.resolve(e()).then((()=>{throw o}))))}),"undefined"!=typeof uni&&uni&&uni.requireGlobal){const e=uni.requireGlobal();ArrayBuffer=e.ArrayBuffer,Int8Array=e.Int8Array,Uint8Array=e.Uint8Array,Uint8ClampedArray=e.Uint8ClampedArray,Int16Array=e.Int16Array,Uint16Array=e.Uint16Array,Int32Array=e.Int32Array,Uint32Array=e.Uint32Array,Float32Array=e.Float32Array,Float64Array=e.Float64Array,BigInt64Array=e.BigInt64Array,BigUint64Array=e.BigUint64Array}uni.restoreGlobal&&uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval),function(e){"use strict";function t(e,t,...o){uni.__log__?uni.__log__(e,t,...o):console[e].apply(console,[...o,t])}const{registerUTSInterface:o,initUTSProxyClass:n,initUTSProxyFunction:i,initUTSPackageName:a,initUTSIndexClassName:r,initUTSClassName:s}=uni,l="ykLog",u=i(!1,{moduleName:"yk-log 基于uts实现的安卓日志插件",moduleType:"",errMsg:"",main:!0,package:a(l,true),class:r(l,true),name:"writeByJs",params:[{name:"logMessage",type:"string"}],return:""});__definePage("uni_modules/yykj-tv/pages/home/home1",((e,t)=>{const o=e.__vccOpts||e;for(const[n,i]of t)o[n]=i;return o})({data:()=>({url:"http://192.168.100.201",urlAvailable:!1,logMessages:[]}),onLoad(e){this.addLog("🏠 home1页面开始加载"),t("log","at uni_modules/yykj-tv/pages/home/home1.vue:23","📄 home1 onLoad 执行",e),this.initWebView()},onReady(){this.addLog("✅ home1页面准备就绪"),t("log","at uni_modules/yykj-tv/pages/home/home1.vue:28","✅ home1 onReady 执行")},onShow(){this.addLog("👀 home1页面显示"),t("log","at uni_modules/yykj-tv/pages/home/home1.vue:32","✅ home1 onShow 执行")},onHide(){this.addLog("🔚 home1页面隐藏"),t("log","at uni_modules/yykj-tv/pages/home/home1.vue:36","🔚 home1 onHide 执行")},onUnload(){this.addLog("🗑️ home1页面卸载"),t("log","at uni_modules/yykj-tv/pages/home/home1.vue:40","🗑️ home1 onUnload 执行")},onError(e){this.addLog("💥 home1页面错误: "+e),t("error","at uni_modules/yykj-tv/pages/home/home1.vue:44","💥 home1页面错误:",e)},methods:{addLog(e){const o=(new Date).toLocaleTimeString();this.logMessages.push(`[${o}] ${e}`),t("log","at uni_modules/yykj-tv/pages/home/home1.vue:50",e),u(e)},async initWebView(){this.addLog("🌐 开始初始化WebView"),this.addLog(`🔗 检查URL可达性: ${this.url}`);await this.checkUrlReachability(this.url)?(this.urlAvailable=!0,this.addLog("✅ URL可达,加载WebView")):(this.urlAvailable=!1,this.addLog("❌ URL不可达,显示错误页面")),uni.onNetworkStatusChange((e=>{this.addLog("📶 网络状态变化: "+(e.isConnected?"已连接":"未连接")),e.isConnected&&this.retryConnection()}))},checkUrlReachability(e){return new Promise((t=>{uni.request({url:e,method:"GET",timeout:5e3,success:e=>{this.addLog(`✅ URL检查成功,状态码: ${e.statusCode}`),t(e.statusCode<400)},fail:e=>{e.errMsg&&e.errMsg.includes("request:fail")?(this.addLog("❌ 网络请求失败"),t(!1)):(this.addLog(`⚠️ URL可能可达,但有CORS限制: ${e.errMsg}`),t(!0))}})}))},async retryConnection(){this.addLog("🔄 尝试重新连接");const e=await this.checkUrlReachability(this.url);this.urlAvailable=e,e?(this.addLog("✅ 重新连接成功"),uni.showToast({title:"连接成功",icon:"success"})):(this.addLog("❌ 重新连接失败"),uni.showToast({title:"连接失败",icon:"none"}))}}},[["render",function(t,o,n,i,a,r){return e.openBlock(),e.createElementBlock("view",null,[a.urlAvailable?(e.openBlock(),e.createElementBlock("web-view",{key:0,src:a.url},null,8,["src"])):(e.openBlock(),e.createElementBlock("view",{key:1,class:"error-container"},[e.createElementVNode("text",{class:"error-text"},"无法访问目标地址,请检查网络连接"),e.createElementVNode("button",{type:"primary",onClick:o[0]||(o[0]=(...e)=>r.retryConnection&&r.retryConnection(...e))},"重试")]))])}],["__scopeId","data-v-ca20a413"]]));const c={onLaunch:function(e){u("输出 平台信息"),uni.getNetworkType({success:e=>{u("网络类型"+e.networkType)},fail:e=>{u("获取网络状态失败")}})},onShow:function(e){u("显示参数"+JSON.stringify(e))},onPageNotFound:function(e){u("页面未找到"+JSON.stringify(e))}};const{app:h,Vuex:d,Pinia:y}=function(){t("log","at main.js:23","🚀 Vue3应用开始初始化",(new Date).toISOString());const o=e.createVueApp(c);return t("log","at main.js:25","✅ Vue3应用实例创建完成",(new Date).toISOString()),{app:o}}();uni.Vuex=d,uni.Pinia=y,h.provide("__globalStyles",__uniConfig.styles),h._component.mpType="app",h._component.render=()=>{},h.mount("#app")}(Vue);
|