2022-08-26 09:52:43 +00:00
|
|
|
<script setup lang="ts">
|
2022-09-08 08:28:56 +00:00
|
|
|
import { onLaunch } from '@dcloudio/uni-app'
|
|
|
|
|
import { useAppStore } from './stores/app'
|
|
|
|
|
import { useUserStore } from './stores/user'
|
2024-10-10 06:10:49 +00:00
|
|
|
import { useThemeStore } from './stores/theme'
|
|
|
|
|
import { useRoute, useRouter } from 'uniapp-router-next'
|
2022-09-15 02:53:31 +00:00
|
|
|
const appStore = useAppStore()
|
2022-09-08 08:28:56 +00:00
|
|
|
const { getUser } = useUserStore()
|
2024-10-10 06:10:49 +00:00
|
|
|
const { getTheme } = useThemeStore()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const route = useRoute()
|
2022-09-15 07:03:12 +00:00
|
|
|
|
2024-10-10 06:10:49 +00:00
|
|
|
//#ifdef H5
|
|
|
|
|
const setH5WebIcon = () => {
|
|
|
|
|
const config = appStore.getWebsiteConfig
|
|
|
|
|
let favicon: HTMLLinkElement = document.querySelector('link[rel="icon"]')!
|
|
|
|
|
if (favicon) {
|
|
|
|
|
favicon.href = config.h5_favicon
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
favicon = document.createElement('link')
|
|
|
|
|
favicon.rel = 'icon'
|
|
|
|
|
favicon.href = config.h5_favicon
|
|
|
|
|
document.head.appendChild(favicon)
|
|
|
|
|
}
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
const getConfig = async () => {
|
2022-09-15 02:53:31 +00:00
|
|
|
await appStore.getConfig()
|
2024-10-10 06:10:49 +00:00
|
|
|
//#ifdef H5
|
|
|
|
|
setH5WebIcon()
|
|
|
|
|
//#endif
|
|
|
|
|
const { status, page_status, page_url } = appStore.getH5Config
|
|
|
|
|
if (route.meta.webview) return
|
|
|
|
|
//处理关闭h5渠道
|
|
|
|
|
//#ifdef H5
|
2022-09-15 02:53:31 +00:00
|
|
|
if (status == 0) {
|
2024-10-10 06:10:49 +00:00
|
|
|
if (page_status == 1) return (location.href = page_url)
|
|
|
|
|
router.reLaunch('/pages/empty/empty')
|
2022-09-15 02:53:31 +00:00
|
|
|
}
|
2024-10-10 06:10:49 +00:00
|
|
|
//#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onLaunch(async () => {
|
|
|
|
|
getTheme()
|
|
|
|
|
getConfig()
|
|
|
|
|
//#ifdef H5
|
|
|
|
|
setH5WebIcon()
|
|
|
|
|
//#endif
|
2022-09-13 09:41:24 +00:00
|
|
|
await getUser()
|
2022-08-26 09:52:43 +00:00
|
|
|
})
|
|
|
|
|
</script>
|
2022-09-16 10:54:32 +00:00
|
|
|
<style lang="scss">
|
|
|
|
|
//
|
|
|
|
|
</style>
|