Skip to content

Commit fd5cafd

Browse files
committed
✨feat: 添加烟花动画效果和页面语言设置 [deploy]
- 在index.html中将语言设置更新为zh-CN - 在permission.js中引入烟花动画功能,并在页面刷新时触发 - 更新router.afterEach钩子以支持烟花动画效果,提升用户体验
1 parent 35ed8e9 commit fd5cafd

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="zh">
2+
<html lang="zh-CN">
33

44
<head>
55
<meta charset="UTF-8" />

src/layouts/components/FHeader.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
import { useFullscreen } from '@vueuse/core'
33
import FormDrawer from '~/components/FormDrawer.vue'
44
import { useRepassword, useLogout } from '~/composables/useManager.js'
5+
// import { useConfetti } from '~/composables/useConfetti.js'
6+
// import { onMounted } from 'vue'
57
68
/*
79
* 这里面很多逻辑都在 ~/composables/useManager.js 里面
810
* */
911
10-
// isFullscreen 是否全屏状态 toggle 切换全屏与退出全屏
12+
// isFullscreen 是否全屏状态 toggle 切换全屏与退出全屏
1113
const { isFullscreen, toggle } = useFullscreen()
1214
// 解构出来
1315
const { formDrawerRef, form, rules, formRef, onSubmit, openRePasswordForm } = useRepassword()
14-
16+
// const { playConfettiAnimation } = useConfetti()
1517
// 退出登录
1618
const { handleLogout } = useLogout()
1719
@@ -28,7 +30,21 @@
2830
}
2931
3032
// 刷新页面
31-
const handleRefresh = () => location.reload()
33+
const handleRefresh = () => {
34+
// 设置刷新标记
35+
// sessionStorage.setItem('needConfetti', 'true')
36+
location.reload()
37+
}
38+
39+
// 组件挂载时检查是否需要播放烟花
40+
// onMounted(() => {
41+
// if (sessionStorage.getItem('needConfetti') === 'true') {
42+
// // 播放烟花动画
43+
// // playConfettiAnimation()
44+
// // 清除标记
45+
// sessionStorage.removeItem('needConfetti')
46+
// }
47+
// })
3248
</script>
3349

3450
<template>

src/permission.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { router, addRoutes } from '~/router'
33
import { getToken } from '~/composables/auth.js'
44
import { showFullLoading, hideFullLoading, toast } from '~/composables/util.js'
55
import store from '~/store/index.js'
6+
import { useConfetti } from '~/composables/useConfetti.js'
7+
8+
const { playConfettiAnimation } = useConfetti()
69

710
// 全局前置守卫
811
let hasGetInfo = false // 处理点击一次菜单就会获取两次 getInfo 的问题
@@ -34,8 +37,13 @@ router.beforeEach(async (to, from, next) => {
3437
})
3538

3639
// 全局后置守卫
37-
router.afterEach((to) => {
40+
router.afterEach((to, from) => {
3841
document.title = to.meta.title + '-商城后台管理系统'
3942
// 关闭全屏 loading
4043
hideFullLoading()
44+
45+
// 只在页面刷新时触发烟花动画(页面刷新时from.name为null)
46+
if (!from.name) {
47+
playConfettiAnimation()
48+
}
4149
})

0 commit comments

Comments
 (0)