|
@@ -7,11 +7,12 @@ import { getRandomKey, setBehaviorId, setToken } from "../utils";
|
|
|
import { getQuery } from "../utils/queryString";
|
|
|
import Notfind from "../view/notfind";
|
|
|
import { employeeQueryUserInfo, studentQueryUserInfo, teacherQueryUserInfo } from "./api";
|
|
|
+import { promisefiyPostMessage } from "../utils/native-message";
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: "App",
|
|
|
setup() {
|
|
|
- const query: any = getQuery()
|
|
|
+ const query: any = getQuery();
|
|
|
/** 获取用户信息 */
|
|
|
const getUserInfo = async () => {
|
|
|
// const a = await request.get(`/student/queryUserInfo`)
|
|
@@ -29,17 +30,25 @@ export default defineComponent({
|
|
|
setUserInfo(student);
|
|
|
// console.log("🚀 ~ res:", student);
|
|
|
};
|
|
|
- onBeforeMount(() => {
|
|
|
+ onBeforeMount(async () => {
|
|
|
if (query.Authorization) {
|
|
|
setToken(query.Authorization);
|
|
|
+ } else {
|
|
|
+ // 获取token
|
|
|
+ const res = await promisefiyPostMessage({ api: "getToken" });
|
|
|
+ const content = res?.content;
|
|
|
+ if (content?.accessToken) {
|
|
|
+ setToken(content.tokenType + " " + content.accessToken);
|
|
|
+ }
|
|
|
+ console.log(content.tokenType + " " + content.accessToken)
|
|
|
}
|
|
|
setUser();
|
|
|
- setBehaviorId(getRandomKey())
|
|
|
+ setBehaviorId(getRandomKey());
|
|
|
});
|
|
|
onMounted(() => {
|
|
|
- const _loading = document.getElementById("loading")
|
|
|
- _loading && (document.body.removeChild(_loading))
|
|
|
- })
|
|
|
+ const _loading = document.getElementById("loading");
|
|
|
+ _loading && document.body.removeChild(_loading);
|
|
|
+ });
|
|
|
|
|
|
const inited = computed(() => {
|
|
|
return storeData.status === "login";
|