mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-12 09:57:20 +00:00
update uni-app
This commit is contained in:
parent
4281ac05f9
commit
086549723c
127
uni-app/App.vue
127
uni-app/App.vue
@ -1,74 +1,75 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||||
import manifest from '@/manifest.json'
|
import manifest from '@/manifest.json'
|
||||||
import { redirectInterceptor, launchInterceptor } from '@/utils/interceptor'
|
import { redirectInterceptor, launchInterceptor } from '@/utils/interceptor'
|
||||||
import { getToken, isWeixinBrowser,getSiteId } from '@/utils/common'
|
import { getToken, isWeixinBrowser, getSiteId } from '@/utils/common'
|
||||||
import useMemberStore from '@/stores/member'
|
import useMemberStore from '@/stores/member'
|
||||||
import useConfigStore from '@/stores/config'
|
import useConfigStore from '@/stores/config'
|
||||||
import useSystemStore from '@/stores/system'
|
import useSystemStore from '@/stores/system'
|
||||||
import { useLogin } from '@/hooks/useLogin'
|
import { useLogin } from '@/hooks/useLogin'
|
||||||
import { language } from '@/locale'
|
import { language } from '@/locale'
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (import.meta.env.VITE_APP_DEBUG) { new window.VConsole() }
|
if (import.meta.env.VITE_APP_DEBUG) { new window.VConsole() }
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
onLaunch(async (data) => {
|
|
||||||
// 添加初始化拦截器
|
|
||||||
launchInterceptor()
|
|
||||||
// 添加页面跳转拦截器
|
|
||||||
redirectInterceptor()
|
|
||||||
|
|
||||||
// #ifdef H5
|
onLaunch(async (data) => {
|
||||||
uni.getSystemInfoSync().platform == 'ios' && (uni.setStorageSync('initUrl', location.href))
|
// 添加初始化拦截器
|
||||||
// #endif
|
launchInterceptor()
|
||||||
|
// 添加页面跳转拦截器
|
||||||
// 缺少站点id,拦截
|
redirectInterceptor()
|
||||||
if (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '') return;
|
|
||||||
|
|
||||||
const configStore = useConfigStore()
|
// #ifdef H5
|
||||||
configStore.getTabbarConfig()
|
uni.getSystemInfoSync().platform == 'ios' && (uni.setStorageSync('initUrl', location.href))
|
||||||
await configStore.getLoginConfig()
|
|
||||||
|
|
||||||
useSystemStore().getSitenfo()
|
|
||||||
|
|
||||||
// 隐藏tabbar
|
// 缺少站点id,拦截
|
||||||
uni.hideTabBar()
|
if (process.env.NODE_ENV == 'development' && (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '')) return;
|
||||||
|
// #endif
|
||||||
// 判断是否已登录
|
|
||||||
if (getToken()) {
|
|
||||||
const memberStore = useMemberStore()
|
|
||||||
await memberStore.setToken(getToken())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!getToken()) {
|
|
||||||
const login = useLogin()
|
|
||||||
// 三方平台自动登录
|
|
||||||
// #ifdef MP
|
|
||||||
login.getAuthCode()
|
|
||||||
// #endif
|
|
||||||
// #ifdef H5
|
|
||||||
if (isWeixinBrowser()) {
|
|
||||||
data.query.code ? login.authLogin(data.query.code) : login.getAuthCode('snsapi_userinfo')
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听浏览器返回
|
|
||||||
// #ifdef H5
|
|
||||||
window.addEventListener("popstate", function(e) {
|
|
||||||
const path = '/' + location.pathname.replace(manifest.h5.router.base, '')
|
|
||||||
language.loadLocaleMessages(path, uni.getLocale())
|
|
||||||
}, false);
|
|
||||||
// #endif
|
|
||||||
})
|
|
||||||
|
|
||||||
onShow(() => {
|
|
||||||
|
|
||||||
})
|
const configStore = useConfigStore()
|
||||||
|
configStore.getTabbarConfig()
|
||||||
|
await configStore.getLoginConfig()
|
||||||
|
|
||||||
onHide(() => {
|
useSystemStore().getSitenfo()
|
||||||
})
|
|
||||||
|
// 隐藏tabbar
|
||||||
|
uni.hideTabBar()
|
||||||
|
|
||||||
|
// 判断是否已登录
|
||||||
|
if (getToken()) {
|
||||||
|
const memberStore = useMemberStore()
|
||||||
|
await memberStore.setToken(getToken())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getToken()) {
|
||||||
|
const login = useLogin()
|
||||||
|
// 三方平台自动登录
|
||||||
|
// #ifdef MP
|
||||||
|
login.getAuthCode()
|
||||||
|
// #endif
|
||||||
|
// #ifdef H5
|
||||||
|
if (isWeixinBrowser()) {
|
||||||
|
data.query.code ? login.authLogin(data.query.code) : login.getAuthCode('snsapi_userinfo')
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听浏览器返回
|
||||||
|
// #ifdef H5
|
||||||
|
window.addEventListener("popstate", function (e) {
|
||||||
|
const path = '/' + location.pathname.replace(manifest.h5.router.base, '')
|
||||||
|
language.loadLocaleMessages(path, uni.getLocale())
|
||||||
|
}, false);
|
||||||
|
// #endif
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
onHide(() => {
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
@ -3,7 +3,9 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
|
// #ifdef H5
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.index.index%"
|
"navigationBarTitleText": "%pages.index.index%"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -70,20 +72,24 @@
|
|||||||
"navigationBarTitleText": "%pages.index.diy%"
|
"navigationBarTitleText": "%pages.index.diy%"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/index/close",
|
"path": "pages/index/close",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
// #ifdef H5
|
||||||
"navigationBarTitleText": "%pages.index.close%"
|
"navigationStyle": "custom",
|
||||||
}
|
// #endif
|
||||||
},
|
"navigationBarTitleText": "%pages.index.close%"
|
||||||
{
|
}
|
||||||
"path": "pages/index/nonexistence",
|
},
|
||||||
"style": {
|
{
|
||||||
"navigationStyle": "custom",
|
"path": "pages/index/nosite",
|
||||||
"navigationBarTitleText": "%pages.index.nonexistence%"
|
"style": {
|
||||||
}
|
// #ifdef H5
|
||||||
},
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
|
"navigationBarTitleText": "%pages.index.nosite%"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/article/detail",
|
"path": "pages/article/detail",
|
||||||
"style": {
|
"style": {
|
||||||
@ -172,20 +178,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/member/index",
|
"path": "pages/member/index",
|
||||||
"style": {
|
|
||||||
"navigationStyle": "custom",
|
|
||||||
"navigationBarTitleText": "%pages.member.index%"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/member/info",
|
|
||||||
"style": {
|
"style": {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
// #endif
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.member.info%"
|
"navigationBarTitleText": "%pages.member.index%"
|
||||||
},
|
}
|
||||||
"needLogin": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/member/personal",
|
"path": "pages/member/personal",
|
||||||
@ -230,14 +228,18 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/pay/browser",
|
"path": "pages/pay/browser",
|
||||||
"style": {
|
"style": {
|
||||||
|
// #ifdef H5
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.pay.browser%"
|
"navigationBarTitleText": "%pages.pay.browser%"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/pay/result",
|
"path": "pages/pay/result",
|
||||||
"style": {
|
"style": {
|
||||||
|
// #ifdef H5
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.pay.result%"
|
"navigationBarTitleText": "%pages.pay.result%"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -268,7 +270,7 @@
|
|||||||
// #endif
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.index.develop%"
|
"navigationBarTitleText": "%pages.index.develop%"
|
||||||
}
|
}
|
||||||
}// {{PAGE}}
|
} // {{PAGE}}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user