chore: 导入清理前的完整工程状态(含 Capacitor 原生壳,作为回滚备份点)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { captureCookAcquisition } from '~/utils/acquisition'
|
||||
|
||||
export default defineNuxtPlugin({
|
||||
name: 'cook-acquisition',
|
||||
enforce: 'pre',
|
||||
setup() {
|
||||
captureCookAcquisition()
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
import { isPrivateAnalyticsUrl, resolveClarityConfig, setCookEventTracker } from '~/utils/analytics'
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
const config = useRuntimeConfig().public
|
||||
const clarity = resolveClarityConfig({
|
||||
projectId: config.clarityProjectId,
|
||||
domains: config.clarityDomains,
|
||||
}, window.location.href, import.meta.dev)
|
||||
if (!clarity || navigator.doNotTrack === '1'
|
||||
|| (navigator as Navigator & { globalPrivacyControl?: boolean }).globalPrivacyControl
|
||||
|| (document.referrer && isPrivateAnalyticsUrl(document.referrer))) {
|
||||
return
|
||||
}
|
||||
|
||||
let stopped = false
|
||||
const script = useScriptClarity({
|
||||
id: clarity.projectId,
|
||||
scriptOptions: { bundle: false, proxy: false, trigger: 'manual' },
|
||||
scriptInput: { src: `https://www.clarity.ms/tag/${clarity.projectId}`, referrerpolicy: 'no-referrer' },
|
||||
})
|
||||
|
||||
function stop() {
|
||||
stopped = true
|
||||
try {
|
||||
window.clarity?.('stop')
|
||||
}
|
||||
catch {
|
||||
// A recorder error must not prevent login navigation.
|
||||
}
|
||||
}
|
||||
|
||||
// Stop before a SPA navigation can expose a callback URL to the recorder.
|
||||
useRouter().beforeEach((to) => {
|
||||
if (isPrivateAnalyticsUrl(new URL(to.fullPath, window.location.origin).href)) {
|
||||
stop()
|
||||
}
|
||||
})
|
||||
|
||||
setCookEventTracker((name) => {
|
||||
if (!stopped && !isPrivateAnalyticsUrl(window.location.href))
|
||||
return script.proxy.clarity('event', name)
|
||||
})
|
||||
|
||||
onNuxtReady(() => {
|
||||
if (stopped || isPrivateAnalyticsUrl(window.location.href))
|
||||
return
|
||||
void script.load().then(() => {
|
||||
if (stopped)
|
||||
stop()
|
||||
}).catch(() => undefined)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
export default defineNuxtPlugin({
|
||||
name: 'cook-user-data-sync',
|
||||
dependsOn: ['cook-auth'],
|
||||
setup() {
|
||||
useUserDataSync().install()
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
import { useDebounceFn } from '@vueuse/core'
|
||||
import { applyYunleHostLayout, waitForYunleHost } from '~/utils/yunleHost'
|
||||
|
||||
/**
|
||||
* 在云乐坊 App 容器内打开时,按宿主的展示形态、安全区与胶囊位置调整布局
|
||||
*/
|
||||
export default defineNuxtPlugin({
|
||||
name: 'cook-yunle-host',
|
||||
setup() {
|
||||
void waitForYunleHost().then(async (host) => {
|
||||
if (!host)
|
||||
return
|
||||
|
||||
const root = document.documentElement
|
||||
const sync = async () => {
|
||||
try {
|
||||
applyYunleHostLayout(root, await host.getEnv(), window.innerWidth)
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
await sync()
|
||||
// 旋转屏幕或页面收起 / 恢复标题栏后,安全区与胶囊位置都会变化
|
||||
window.addEventListener('resize', useDebounceFn(sync, 150))
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
export default defineNuxtPlugin({
|
||||
name: 'cook-auth',
|
||||
dependsOn: ['cook-acquisition'],
|
||||
setup() {
|
||||
void useYunlefunAuth().initialize()
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user