Skip to content

Commit e24329e

Browse files
committed
fix:设置添加页面切换动画
1 parent 015ea47 commit e24329e

File tree

8 files changed

+147
-26
lines changed

8 files changed

+147
-26
lines changed

Diff for: web/src/pathInfo.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"/src/view/layout/screenfull/index.vue": "Screenfull",
3333
"/src/view/layout/search/search.vue": "BtnBox",
3434
"/src/view/layout/setting/index.vue": "GvaSetting",
35+
"/src/view/layout/setting/title.vue": "layoutSettingTitle",
3536
"/src/view/layout/tabs/index.vue": "HistoryComponent",
3637
"/src/view/login/index.vue": "Login",
3738
"/src/view/person/person.vue": "Person",

Diff for: web/src/pinia/modules/app.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ export const useAppStore = defineStore('app', () => {
1717
layout_side_collapsed_width: 80,
1818
layout_side_item_height: 48,
1919
show_watermark: true,
20-
side_mode: 'normal'
20+
side_mode: 'normal',
21+
// 页面过渡动画配置
22+
transition_type: 'slide'
2123
})
2224

2325
const isDark = useDark({
2426
selector: 'html',
2527
attribute: 'class',
2628
valueDark: 'dark',
27-
valueLight: 'light',
29+
valueLight: 'light'
2830
})
2931

3032
const preferredDark = usePreferredDark()
@@ -50,10 +52,10 @@ export const useAppStore = defineStore('app', () => {
5052
}
5153

5254
const toggleDevice = (e) => {
53-
if(e === 'mobile'){
55+
if (e === 'mobile') {
5456
drawerSize.value = '100%'
5557
operateMinWith.value = '80'
56-
}else {
58+
} else {
5759
drawerSize.value = '800'
5860
operateMinWith.value = '240'
5961
}
@@ -93,7 +95,11 @@ export const useAppStore = defineStore('app', () => {
9395
config.side_mode = e
9496
}
9597

96-
// 监听色弱模式和灰色模式
98+
const toggleTransition = (e) => {
99+
config.transition_type = e
100+
}
101+
102+
// 监听色弱模式和灰色模式
97103
watchEffect(() => {
98104
document.documentElement.classList.toggle('html-weakenss', config.weakness)
99105
document.documentElement.classList.toggle('html-grey', config.grey)
@@ -121,6 +127,7 @@ export const useAppStore = defineStore('app', () => {
121127
toggleConfigSideCollapsedWidth,
122128
toggleConfigSideItemHeight,
123129
toggleConfigWatermark,
124-
toggleSideMode
130+
toggleSideMode,
131+
toggleTransition
125132
}
126133
})

Diff for: web/src/pinia/modules/user.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ export const useUserStore = defineStore('user', () => {
2828
userInfo.value = val
2929
if (val.originSetting) {
3030
Object.keys(appStore.config).forEach((key) => {
31-
appStore.config[key] = val.originSetting[key]
31+
if (val.originSetting[key]) {
32+
appStore.config[key] = val.originSetting[key]
33+
}
3234
})
3335
}
36+
console.log(appStore.config)
3437
}
3538

3639
const setToken = (val) => {
@@ -66,7 +69,7 @@ export const useUserStore = defineStore('user', () => {
6669
})
6770

6871
const res = await login(loginInfo)
69-
72+
7073
if (res.code !== 0) {
7174
ElMessage.error(res.message || '登录失败')
7275
return false

Diff for: web/src/style/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@use '@/style/iconfont.css';
2+
@use "./transition.scss";
23

34
.html-grey {
45
filter: grayscale(100%);

Diff for: web/src/style/transition.scss

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
// 淡入淡出动画
3+
.fade-enter-active,
4+
.fade-leave-active {
5+
transition: all 0.3s ease;
6+
}
7+
8+
.fade-enter-from,
9+
.fade-leave-to {
10+
opacity: 0;
11+
transform: translateY(10px);
12+
}
13+
14+
.header {
15+
border-radius: 0 0 10px 10px;
16+
}
17+
18+
.body {
19+
height: calc(100% - 6rem);
20+
}
21+
22+
@keyframes slideDown {
23+
from {
24+
transform: translateY(-20px);
25+
opacity: 0;
26+
}
27+
28+
to {
29+
transform: translateY(0);
30+
opacity: 1;
31+
}
32+
}
33+
34+
@keyframes fadeIn {
35+
from {
36+
opacity: 0;
37+
}
38+
39+
to {
40+
opacity: 1;
41+
}
42+
}
43+
// 缩放动画
44+
.zoom-enter-active,
45+
.zoom-leave-active {
46+
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
47+
}
48+
49+
.zoom-enter-from,
50+
.zoom-leave-to {
51+
opacity: 0;
52+
transform: scale(0.95);
53+
}
54+
55+
56+
/* fade-slide */
57+
.slide-leave-active,
58+
.slide-enter-active {
59+
transition: all 0.3s;
60+
}
61+
.slide-enter-from {
62+
opacity: 0;
63+
transform: translateX(-30px);
64+
}
65+
.slide-leave-to {
66+
opacity: 0;
67+
transform: translateX(30px);
68+
}

Diff for: web/src/view/layout/index.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
v-if="config.side_mode === 'combination' && device !== 'mobile'"
2424
mode="normal"
2525
/>
26-
<div class="flex-1 p-2 w-0 h-full">
26+
<div class="flex-1 px-2 w-0 h-full">
2727
<gva-tabs v-if="config.showTabs" />
2828
<div
2929
class="overflow-auto"
@@ -34,7 +34,7 @@
3434
id="gva-base-load-dom"
3535
class="gva-body-h bg-gray-50 dark:bg-slate-800"
3636
>
37-
<transition mode="out-in" name="el-fade-in-linear">
37+
<transition mode="out-in" :name="config.transition_type">
3838
<keep-alive :include="routerStore.keepAliveRouters">
3939
<component :is="Component" :key="route.fullPath" />
4040
</keep-alive>
@@ -61,6 +61,7 @@
6161
import { useUserStore } from '@/pinia/modules/user'
6262
import { useAppStore } from '@/pinia'
6363
import { storeToRefs } from 'pinia'
64+
import '@/style/transition.scss'
6465
const appStore = useAppStore()
6566
const { config, isDark, device } = storeToRefs(appStore)
6667

Diff for: web/src/view/layout/setting/index.vue

+22-16
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</template>
1515
<div class="flex flex-col">
1616
<div class="mb-8">
17-
<div class="text-gray-800 dark:text-gray-100">默认主题</div>
18-
<div class="mt-2 text-sm p-2 flex items-center gap-2">
17+
<Title title="默认主题"></Title>
18+
<div class="mt-2 text-sm p-2 flex items-center justify-center gap-2">
1919
<el-segmented
2020
v-model="config.darkMode"
2121
:options="options"
@@ -25,8 +25,8 @@
2525
</div>
2626
</div>
2727
<div class="mb-8">
28-
<div class="text-gray-800 dark:text-gray-100">主题色</div>
29-
<div class="mt-2 text-sm p-2 flex items-center gap-2">
28+
<Title title="主题色"></Title>
29+
<div class="mt-2 text-sm p-2 flex items-center gap-2 justify-center">
3030
<div
3131
v-for="item in colors"
3232
:key="item"
@@ -45,8 +45,8 @@
4545
</div>
4646
</div>
4747
<div class="mb-8">
48-
<div class="text-gray-800 dark:text-gray-100">界面显示</div>
49-
<div class="mt-2 text-sm p-2">
48+
<Title title="主题配置"></Title>
49+
<div class="mt-2 text-md p-2 flex flex-col gap-2">
5050
<div class="flex items-center justify-between">
5151
<div>展示水印</div>
5252
<el-switch
@@ -73,14 +73,6 @@
7373
size="default"
7474
@change="appStore.toggleSideMode"
7575
/>
76-
<!-- <el-select
77-
v-model="config.side_mode"
78-
@change="handleSideModelChange"
79-
>
80-
<el-option value="normal" label="标准模式" />
81-
<el-option value="head" label="顶部导航栏" />
82-
<el-option value="multilayer" disabled label="多侧边导航模式" />
83-
</el-select> -->
8476
</div>
8577

8678
<div class="flex items-center justify-between">
@@ -90,12 +82,25 @@
9082
@change="appStore.toggleTabs"
9183
/>
9284
</div>
85+
<div class="flex items-center justify-between gap-2">
86+
<div class="flex-shrink-0">页面切换动画</div>
87+
<el-select
88+
v-model="config.transition_type"
89+
@change="appStore.toggleTransition"
90+
class="w-40"
91+
>
92+
<el-option value="fade" label="淡入淡出" />
93+
<el-option value="slide" label="滑动" />
94+
<el-option value="zoom" label="缩放" />
95+
<el-option value="none" label="无动画" />
96+
</el-select>
97+
</div>
9398
</div>
9499
</div>
95100

96101
<div class="mb-8">
97-
<div class="text-gray-800 dark:text-gray-100">layout 大小配置</div>
98-
<div class="mt-2 text-sm p-2">
102+
<Title title="layout 大小配置"></Title>
103+
<div class="mt-2 text-md p-2 flex flex-col gap-2">
99104
<div class="flex items-center justify-between mb-2">
100105
<div>侧边栏展开宽度</div>
101106
<el-input-number
@@ -138,6 +143,7 @@
138143
import { ref, computed } from 'vue'
139144
import { ElMessage } from 'element-plus'
140145
import { setSelfSetting } from '@/api/user'
146+
import Title from './title.vue'
141147
const appStore = useAppStore()
142148
const { config, device } = storeToRefs(appStore)
143149
defineOptions({

Diff for: web/src/view/layout/setting/title.vue

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<div class="title relative my-2">
3+
<div class="flex-shrink-0 text-center text-xl text-gray-600">
4+
{{ title }}
5+
</div>
6+
</div>
7+
</template>
8+
9+
<script setup>
10+
defineOptions({
11+
name: 'layoutSettingTitle'
12+
})
13+
14+
defineProps({
15+
title: String
16+
})
17+
</script>
18+
19+
<style scoped>
20+
.title {
21+
display: flex;
22+
align-items: center;
23+
justify-content: center;
24+
gap: 4rem;
25+
}
26+
27+
.title::before,
28+
.title::after {
29+
content: '';
30+
height: 1px;
31+
width: 100%;
32+
background-color: #e3e3e3;
33+
}
34+
</style>

0 commit comments

Comments
 (0)