Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit 4f0e38d

Browse files
committed
feat: redesign setup view
1 parent f7b3668 commit 4f0e38d

15 files changed

Lines changed: 761 additions & 817 deletions

File tree

src/api/backup.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ export const backupApi = {
2626

2727
// 删除备份
2828
delete: (filename: string) =>
29-
request.delete<void>('/backups', { params: { filename } }),
29+
request.delete<void>(`/backups/${encodeURIComponent(filename)}`),
3030

3131
// 从备份恢复
3232
rollback: (filename: string) =>
3333
request.patch<void>(`/backups/rollback/${filename}`),
34+
35+
// 上传备份文件并恢复
36+
uploadAndRestore: (file: File) => {
37+
const formData = new FormData()
38+
formData.append('file', file)
39+
return request.post<void, FormData>('/backups/rollback', {
40+
data: formData,
41+
})
42+
},
3443
}

src/components/avatar/Avatar.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { defineComponent, onMounted, ref, watch } from 'vue'
2+
3+
import styles from './avatar.module.css'
4+
5+
export const Avatar = defineComponent({
6+
name: 'Avatar',
7+
props: {
8+
size: {
9+
type: Number,
10+
default: 50,
11+
},
12+
src: {
13+
type: String,
14+
required: true,
15+
},
16+
},
17+
setup(props) {
18+
const loaded = ref(false)
19+
20+
const preloadImage = () => {
21+
if (!props.src) {
22+
return
23+
}
24+
const img = new Image()
25+
img.src = props.src
26+
27+
img.addEventListener('load', () => {
28+
loaded.value = true
29+
})
30+
}
31+
32+
onMounted(() => {
33+
preloadImage()
34+
})
35+
36+
watch(
37+
() => props.src,
38+
() => {
39+
preloadImage()
40+
},
41+
)
42+
43+
return () => (
44+
<div
45+
class={styles.avatar}
46+
style={{ height: `${props.size}px`, width: `${props.size}px` }}
47+
>
48+
<img
49+
src={props.src}
50+
alt=""
51+
style={{ display: loaded.value ? '' : 'none' }}
52+
/>
53+
<div class="sr-only">一个头像</div>
54+
</div>
55+
)
56+
},
57+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.avatar {
2+
@apply relative inline-block select-none overflow-hidden rounded-full;
3+
background-color: #ddd;
4+
}
5+
6+
.avatar img {
7+
@apply h-full max-w-full rounded-full;
8+
animation: scale 0.5s ease-out;
9+
}
10+
11+
@keyframes scale {
12+
0% {
13+
transform: scale(0);
14+
}
15+
to {
16+
transform: scale(1);
17+
}
18+
}

src/components/avatar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Avatar from './index.vue'
1+
import { Avatar } from './Avatar'
22

33
// eslint-disable-next-line import/no-default-export
44
export { Avatar, Avatar as default }

src/components/avatar/index.vue

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/components/button/parallax-button.vue

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)