Commit b839b373 authored by hubaoshan's avatar hubaoshan

在Aitoken.js 添加了 return

parent ce929f5a
...@@ -4,42 +4,45 @@ import store from "@/store/index.js"; ...@@ -4,42 +4,45 @@ import store from "@/store/index.js";
// 获取AI无人站的token // 获取AI无人站的token
export function handleGetAIToken() { export function handleGetAIToken() {
console.log('1111111111111111111111111111111111111111') return new Promise((resolve, reject) => {
const AIToken = localStorage.getItem('AIToken') console.log('1111111111111111111111111111111111111111');
if(AIToken) { const AIToken = localStorage.getItem('AIToken');
//有存储token判断token有没有过期 if (AIToken) {
// 检验token是否过期 // 有存储token判断token有没有过期
checkToken(AIToken).then(res => { // 检验token是否过期
if(res.data === false) { checkToken(AIToken).then(res => {
// token过期 if (res.data === false) {
getToken() localStorage.removeItem('AIToken');
} // token过期
}) getToken().then(resolve).catch(reject);
}else { } else {
// 没有token的话获取存储token resolve();
getToken() }
} }).catch(reject);
} else {
// 没有token的话获取存储token
getToken().then(resolve).catch(reject);
}
});
} }
function getToken() { function getToken() {
const userInfo = store.getters.getUserInfo(); const userInfo = store.getters.getUserInfo();
const userName = userInfo.userName const userName = userInfo.userName;
const userId = userInfo.userId const userId = userInfo.userId;
const params = { const params = { username: userName };
username: userName
}
// 通过userName获取uuid // 通过userName获取uuid
getAuthUUID(params).then(res => { return getAuthUUID(params).then(res => {
const uuid = res.data const uuid = res.data;
const params ={ const params = {
userId: userId, userId: userId,
username: userName, username: userName,
uuid: uuid, uuid: uuid,
} };
// 通过userId,username,uuid获取token // 通过userId,username,uuid获取token
createToken(params).then(res => { return createToken(params).then(res => {
const token = res.data const token = res.data;
localStorage.setItem('AIToken',token) localStorage.setItem('AIToken', token);
}) });
}) });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment