From 939f92da38e2b4e6089b73905515be135fbbe926 Mon Sep 17 00:00:00 2001 From: zyronon Date: Wed, 1 May 2024 22:53:47 +0800 Subject: [PATCH] refactor: save --- src/App.vue | 183 +-------------------------------------------------- src/App2.vue | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.ts | 55 ---------------- src/main2.ts | 60 +++++++++++++++++ 4 files changed, 245 insertions(+), 236 deletions(-) create mode 100644 src/App2.vue create mode 100644 src/main2.ts diff --git a/src/App.vue b/src/App.vue index 99e0e98..b4f7095 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,183 +1,4 @@ - - - + diff --git a/src/App2.vue b/src/App2.vue new file mode 100644 index 0000000..99e0e98 --- /dev/null +++ b/src/App2.vue @@ -0,0 +1,183 @@ + + + + diff --git a/src/main.ts b/src/main.ts index 30fba91..43d27f6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,60 +1,5 @@ import { createApp } from 'vue' import App from './App.vue' -import './assets/less/index.less' -import { startMock } from '@/mock' -import router from './router' -import mixin from './utils/mixin' -import VueLazyload from '@jambonn/vue-lazyload' -import { createPinia } from 'pinia' -import { useClick } from '@/utils/hooks/useClick' -import bus, { EVENT_KEY } from '@/utils/bus' -window.isMoved = false -window.isMuted = true -window.showMutedNotice = true -HTMLElement.prototype.addEventListener = new Proxy(HTMLElement.prototype.addEventListener, { - apply(target, ctx, args) { - const eventName = args[0] - const listener = args[1] - if (listener instanceof Function && eventName === 'click') { - args[1] = new Proxy(listener, { - apply(target1, ctx1, args1) { - // console.log('e', args1) - // console.log('click点击', window.isMoved) - if (window.isMoved) return - try { - return target1.apply(ctx1, args1) - } catch (e) { - console.error(`[proxyPlayerEvent][${eventName}]`, listener, e) - } - } - }) - } - return target.apply(ctx, args) - } -}) - -const vClick = useClick() -const pinia = createPinia() const app = createApp(App) -app.mixin(mixin) -const loadImage = new URL('./assets/img/icon/img-loading.png', import.meta.url).href -app.use(VueLazyload, { - preLoad: 1.3, - loading: loadImage, - attempt: 1 -}) -app.use(pinia) -app.use(router) app.mount('#app') -app.directive('click', vClick) - -//放到最后才可以使用pinia -startMock() -setTimeout(() => { - bus.emit(EVENT_KEY.HIDE_MUTED_NOTICE) - window.showMutedNotice = false -}, 2000) -bus.on(EVENT_KEY.REMOVE_MUTED, () => { - window.isMuted = false -}) diff --git a/src/main2.ts b/src/main2.ts new file mode 100644 index 0000000..30fba91 --- /dev/null +++ b/src/main2.ts @@ -0,0 +1,60 @@ +import { createApp } from 'vue' +import App from './App.vue' +import './assets/less/index.less' +import { startMock } from '@/mock' +import router from './router' +import mixin from './utils/mixin' +import VueLazyload from '@jambonn/vue-lazyload' +import { createPinia } from 'pinia' +import { useClick } from '@/utils/hooks/useClick' +import bus, { EVENT_KEY } from '@/utils/bus' + +window.isMoved = false +window.isMuted = true +window.showMutedNotice = true +HTMLElement.prototype.addEventListener = new Proxy(HTMLElement.prototype.addEventListener, { + apply(target, ctx, args) { + const eventName = args[0] + const listener = args[1] + if (listener instanceof Function && eventName === 'click') { + args[1] = new Proxy(listener, { + apply(target1, ctx1, args1) { + // console.log('e', args1) + // console.log('click点击', window.isMoved) + if (window.isMoved) return + try { + return target1.apply(ctx1, args1) + } catch (e) { + console.error(`[proxyPlayerEvent][${eventName}]`, listener, e) + } + } + }) + } + return target.apply(ctx, args) + } +}) + +const vClick = useClick() +const pinia = createPinia() +const app = createApp(App) +app.mixin(mixin) +const loadImage = new URL('./assets/img/icon/img-loading.png', import.meta.url).href +app.use(VueLazyload, { + preLoad: 1.3, + loading: loadImage, + attempt: 1 +}) +app.use(pinia) +app.use(router) +app.mount('#app') +app.directive('click', vClick) + +//放到最后才可以使用pinia +startMock() +setTimeout(() => { + bus.emit(EVENT_KEY.HIDE_MUTED_NOTICE) + window.showMutedNotice = false +}, 2000) +bus.on(EVENT_KEY.REMOVE_MUTED, () => { + window.isMuted = false +})