<script setup lang="ts">
|
import { useStore, storage } from "/@/cool";
|
import { miniAutoLogin, phoneAuthState } from "/@/cool/mini-login";
|
import { i18n } from "/@/locale";
|
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
|
let booted = false;
|
|
function boot() {
|
if (booted) {
|
return;
|
}
|
booted = true;
|
|
const { dict, user } = useStore();
|
const authState = phoneAuthState();
|
|
try {
|
const locale = uni.getLocale();
|
if (locale) {
|
i18n.global.locale = locale;
|
}
|
} catch (err) {
|
console.error(err);
|
}
|
|
dict.refresh()?.catch(() => undefined);
|
|
// #ifdef MP-WEIXIN
|
miniAutoLogin()
|
.catch(() => false)
|
.finally(() => {
|
authState.ready = true;
|
if (user.token && !storage.isExpired("token")) {
|
user.get()?.catch(() => undefined);
|
}
|
});
|
// #endif
|
|
// #ifndef MP-WEIXIN
|
authState.ready = true;
|
if (user.token) {
|
user.get()?.catch(() => undefined);
|
}
|
// #endif
|
}
|
|
onLaunch(() => {
|
console.log("App Launch");
|
});
|
|
onShow(() => {
|
console.log("App Show");
|
setTimeout(boot, 0);
|
});
|
|
onHide(() => {
|
console.log("App Hide");
|
});
|
</script>
|
|
<style lang="scss">
|
@import "/static/css/iconfont/index.scss";
|
@import "/$/cool-ui/index.scss";
|
@import "/@/static/css/index.scss";
|
</style>
|