You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
Vue
69 lines
1.6 KiB
Vue
<script>
|
|
import { getToken } from '@/utils/auth'
|
|
import { initializeLocale, translateLiteral } from '@/locales'
|
|
import useUserStore from '@/store/modules/user'
|
|
|
|
let wrapped = false
|
|
|
|
function wrapUniTextApi() {
|
|
if (wrapped) return
|
|
wrapped = true
|
|
|
|
const rawShowToast = uni.showToast
|
|
const rawShowModal = uni.showModal
|
|
const rawShowLoading = uni.showLoading
|
|
|
|
uni.showToast = (options = {}) => {
|
|
const next = { ...options }
|
|
if (typeof next.title === 'string') {
|
|
next.title = translateLiteral(next.title)
|
|
}
|
|
return rawShowToast(next)
|
|
}
|
|
uni.showLoading = (options = {}) => {
|
|
const next = { ...options }
|
|
if (typeof next.title === 'string') {
|
|
next.title = translateLiteral(next.title)
|
|
}
|
|
return rawShowLoading(next)
|
|
}
|
|
uni.showModal = (options = {}) => {
|
|
const next = { ...options }
|
|
if (typeof next.title === 'string') {
|
|
next.title = translateLiteral(next.title)
|
|
}
|
|
if (typeof next.content === 'string') {
|
|
next.content = translateLiteral(next.content)
|
|
}
|
|
if (typeof next.confirmText === 'string') {
|
|
next.confirmText = translateLiteral(next.confirmText)
|
|
}
|
|
if (typeof next.cancelText === 'string') {
|
|
next.cancelText = translateLiteral(next.cancelText)
|
|
}
|
|
return rawShowModal(next)
|
|
}
|
|
}
|
|
|
|
export default {
|
|
onLaunch: function () {
|
|
initializeLocale()
|
|
wrapUniTextApi()
|
|
if (getToken()) {
|
|
useUserStore().getInfo().catch(() => {})
|
|
}
|
|
},
|
|
onShow: function () {
|
|
initializeLocale()
|
|
wrapUniTextApi()
|
|
},
|
|
onHide: function () {
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import "uview-plus/index.scss";
|
|
@import '@/static/scss/index.scss';
|
|
</style>
|