You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
import $ from 'jquery'; |
|
|
|
export const init = (store) => { |
|
const AcWingOS = store.state.AcWingOS; |
|
|
|
if (AcWingOS === "AcWingOS") return false; |
|
|
|
const vw = window.innerWidth; |
|
const vh = window.innerHeight; |
|
AcWingOS.api.window.resize(59.5 * vh / vw, 64.5); |
|
|
|
$.ajax({ |
|
url: "https://app3359.acapp.acwing.com.cn/apply_code/", |
|
type: "get", |
|
success: resp => { |
|
AcWingOS.api.oauth2.authorize(resp.appid, resp.redirect_uri, resp.scope, resp.state, resp => { |
|
if (resp.result === "success") { |
|
store.commit('updateAccess', resp.access); |
|
store.commit('updateRefresh', resp.refresh); |
|
|
|
setInterval(() => { |
|
$.ajax({ |
|
url: "https://app3359.acapp.acwing.com.cn/api/token/refresh/", |
|
type: "post", |
|
data: { |
|
refresh: resp.refresh, |
|
}, |
|
success: resp => { |
|
store.commit('updateAccess', resp.access); |
|
} |
|
}); |
|
}, 4.5 * 60 * 1000); |
|
} |
|
else { |
|
store.state.AcWingOS.api.window.close(); // 关闭acwing窗口 |
|
} |
|
}); |
|
} |
|
}) |
|
} |