更换banner组件,添加用户隐私协议链接

This commit is contained in:
zhouyanli
2026-06-26 10:07:44 +08:00
parent d0e80824d8
commit f19fb0d9d9
591 changed files with 79931 additions and 83 deletions

View File

@@ -0,0 +1,44 @@
import { MagicString } from 'vue/compiler-sfc'
import { parseSFC } from './utils.js'
export async function registerUpApp(
code,
fileName = 'App.up',
rootToastHostPath = './uni_modules/uview-plus/libs/root/root-toast-host.vue'
) {
const ms = new MagicString(code)
const importCode = `import GlobalUpRoot from "./${fileName}.vue";
import UpRootToastHost from "${rootToastHostPath}";`
const vueUseComponentCode = 'app.component("global-up-root", GlobalUpRoot);\napp.component("ku-root-toast-host", UpRootToastHost);'
ms.prepend(`${importCode}\n`).replace(
/(createApp[\s\S]*?)(return\s\{\s*app)/,
`$1${vueUseComponentCode}\n$2`,
)
return ms
}
export async function rebuildUpApp(code, enabledVirtualHost = false) {
const ms = new MagicString(code)
const rootTagNameRE = /<(UpRootView|up-root-view)(?:\s*\/>|><\/\1>)/
ms.replace(rootTagNameRE, '<slot />\n <ku-root-toast-host />')
if (enabledVirtualHost) {
const sfc = await parseSFC(code)
if (sfc.script) {
return ms
}
const langType = sfc.scriptSetup?.lang
ms.append(`<script ${langType ? `lang="${langType}"` : ''}>
export default {
options: {
virtualHost: true,
}
}\n</script>`)
}
return ms
}