feat: 微信自动关闭功能
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
<div class="loading">Loading...</div>
|
||||
<script type="module">
|
||||
import { config } from './config.js'
|
||||
import { closePage } from './is-wechat.js'
|
||||
const demo = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect`
|
||||
const appid = config.appid
|
||||
const redirect_uri = encodeURIComponent(config.redirect_uri)
|
||||
@@ -40,9 +41,7 @@
|
||||
const state = url.searchParams.get('state')
|
||||
if (!state) {
|
||||
alert('Invalid state. Please try again later.');
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
}, 2000);
|
||||
closePage();
|
||||
}
|
||||
const link = demo.replace('APPID', appid).replace('REDIRECT_URI', redirect_uri).replace('SCOPE', scope).replace('STATE', state);
|
||||
window.location.href = link
|
||||
@@ -50,9 +49,7 @@
|
||||
// Add a timeout for loading
|
||||
setTimeout(() => {
|
||||
alert('Loading timeout. Please try again later.');
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
}, 2000);
|
||||
closePage()
|
||||
}, 60000); // 60 seconds timeout
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user