Showing
1 changed file
with
15 additions
and
2 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 13:55:31 | 2 | * @Date: 2022-08-29 13:55:31 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-08-24 10:52:35 | 4 | + * @LastEditTime: 2024-01-20 09:25:06 |
| 5 | - * @FilePath: /front/src/views/auth.vue | 5 | + * @FilePath: /xysBooking/src/views/auth.vue |
| 6 | * @Description: 授权模块 | 6 | * @Description: 授权模块 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| ... | @@ -23,6 +23,19 @@ onMounted(() => { | ... | @@ -23,6 +23,19 @@ onMounted(() => { |
| 23 | * 其他字符(比如 :;/?:@&=+$,# 这些用于分隔 URI 组件的标点符号),都是由一个或多个十六进制的转义序列替换的。 | 23 | * 其他字符(比如 :;/?:@&=+$,# 这些用于分隔 URI 组件的标点符号),都是由一个或多个十六进制的转义序列替换的。 |
| 24 | */ | 24 | */ |
| 25 | let raw_url = encodeURIComponent(location.origin + location.pathname + $route.query.href); // 未授权的地址 | 25 | let raw_url = encodeURIComponent(location.origin + location.pathname + $route.query.href); // 未授权的地址 |
| 26 | + | ||
| 27 | + // 当用户完成授权后,使用 pushState() 方法将授权页面从浏览器历史记录中移除 | ||
| 28 | + window.history.pushState(null, '', '/'); // 将授权页面替换为根路径或其他合适的路径 | ||
| 29 | + | ||
| 30 | + // 在返回按钮被点击时,检测历史记录的变化并进行处理 | ||
| 31 | + window.addEventListener('popstate', function(event) { | ||
| 32 | + // 检查当前页面的 URL | ||
| 33 | + if (window.location.pathname === '/auth') { | ||
| 34 | + // 如果当前页面是授权页面,使用 replaceState() 方法将其替换为其他页面 | ||
| 35 | + window.history.replaceState(null, '', raw_url); // 替换为其他合适的路径 | ||
| 36 | + } | ||
| 37 | + }); | ||
| 38 | + | ||
| 26 | // TAG: 开发环境测试数据 | 39 | // TAG: 开发环境测试数据 |
| 27 | const short_url = `/srv/?a=openid&res=${raw_url}`; | 40 | const short_url = `/srv/?a=openid&res=${raw_url}`; |
| 28 | location.href = import.meta.env.DEV | 41 | location.href = import.meta.env.DEV | ... | ... |
-
Please register or login to post a comment