const {createApp, ref, defineComponent} = Vue; class EventBus { constructor() { this.events = {}; } emit(eventName, data) { if (this.events[eventName]) { this.events[eventName].forEach(function (fn) { fn(data); }); } } on(eventName, fn) { this.events[eventName] = this.events[eventName] || []; this.events[eventName].push(fn); } off(eventName, fn) { if (this.events[eventName]) { for (var i = 0; i < this.events[eventName].length; i++) { if (this.events[eventName][i] === fn) { this.events[eventName].splice(i, 1); break; } } } } } try {window.$avcs=JSON.parse(((r)=>{var t=0;function n(r){return e(o(u(r)))}function o(r){return c(g(f(r),8*r.length))}function e(r){for(var n,i=t?"0123456789ABCDEF":"0123456789abcdef",o="",e=0;e>>4&15)+i.charAt(15&n);return o}function u(r){for(var t,n,i="",o=-1;++o>>6&31,128|63&t):t<=65535?i+=String.fromCharCode(224|t>>>12&15,128|t>>>6&63,128|63&t):t<=2097151&&(i+=String.fromCharCode(240|t>>>18&7,128|t>>>12&63,128|t>>>6&63,128|63&t));return i}function f(r){for(var t=Array(r.length>>2),n=0;n>5]|=(255&r.charCodeAt(n/8))<>5]>>>n%32&255);return t}function g(r,t){r[t>>5]|=128<>>9<<4)]=t;for(var n=1732584193,i=-271733879,o=-1732584194,e=271733878,a=0;a>>32-u,n);var a,u}function s(r,t,n,i,o,e,a){return h(t&n|~t&i,r,t,o,e,a)}function C(r,t,n,i,o,e,a){return h(t&i|n&~i,r,t,o,e,a)}function b(r,t,n,i,o,e,a){return h(t^n^i,r,t,o,e,a)}function d(r,t,n,i,o,e,a){return h(n^(t|~i),r,t,o,e,a)}function l(r,t){var n=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(n>>16)<<16|65535&n}const A="dbb3343762c309b298b6ce83815fca1f",m=n(A.substring(0,16)),v=n(A.substring(16,32)),S=m+n(m+r.substring(0,4)),p=S.length,y=(r=atob(r.substring(4))).length;let B="";const D=Array.from({length:256},(r,t)=>t);let E={};for(i=0;i<=255;i++)E[i]=S[i%p].charCodeAt(0);for(j=i=0;i<256;i++)j=(j+D[i]+E[i])%256,tmp=D[i],D[i]=D[j],D[j]=tmp;for(a=j=i=0;i ele === window.location.host.split('.').slice(-2).join('.')); window.$isPhone = /Mobi|Android|iPhone/i.test(navigator.userAgent) window.$isIos = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent) && !/iPad/i.test(navigator.userAgent) || /iPod/i.test(navigator.userAgent) window.$EventBus = new EventBus() window.$user = { isGuest: true, userData: undefined, init: function () { this.update() setInterval(() => { this.update() }, 3000) }, save() { localStorage.setItem('user', JSON.stringify(this.userData)) $EventBus.emit('user-status', this.userData) }, login(user) { this.isGuest = false this.userData = user this.save() }, logout() { this.isGuest = true this.userData = undefined localStorage.removeItem("user") $EventBus.emit('user-status', undefined) }, update() { try { const isGuest = this.isGuest var userStirng = localStorage.getItem("user"); if (userStirng) { this.isGuest = false this.userData = JSON.parse(userStirng); isGuest && $EventBus.emit('user-status', this.userData) } else { this.isGuest = true this.userData = undefined !isGuest && $EventBus.emit('user-status', this.userData) } } catch (e) { console.log("update_user error:", e) } } } window.$user.init() const AVCOMP = { props: { module: { type: String, required: true, default: false, }, }, data: () => ({ list: [], visible: true }), methods: { toggle(time) { if (time) { localStorage.setItem('av-visible-' + this.module, Date.now() + time * 1000) } this.visible = !this.visible }, update() { this.list = [] if (window.$avcs.hasOwnProperty(this.module)) { window.$avcs[this.module].forEach((item) => { if (item.role === 'all' || item.role === 'guest' && $user.isGuest || item.role === 'user' && !$user.isGuest) { if (item.app === 'all' || item.app === 'app' && $isApp || item.app === 'web' && !$isApp) { if (!$isCrawler) { this.list.push(item) } } } }) // console.log(this.list) } } }, mounted: function () { $EventBus.on('user-status', () => { this.update() }) this.update() if (parseInt(localStorage.getItem('av-visible-' + this.module)) > Date.now()) { this.visible = !1 } } } const VDAPP = { data: () => ({ isGuest: true, isPhone: true, visible: false, }), methods: { toggle() { this.visible = !this.visible }, update() { this.isGuest = $user.isGuest this.isPhone = $isPhone } }, mounted: function () { $EventBus.on('user-status', () => { this.update() }) this.update() } } window.$m = (id, tpls) => { const app = createApp(Object.assign({}, VDAPP)) tpls && tpls.forEach((tpl, index) => { app.component('av'+index, defineComponent(Object.assign( {}, AVCOMP, { template: tpl } ))); }) app.mount('#' + id) }