Skip to content

Commit e64a34e

Browse files
committed
feat: 提供系统初始化页面
- 添加默认头像和横幅SVG文件 - 移除Base64Utils工具 - 优化文件路径导入
1 parent cf17aef commit e64a34e

File tree

12 files changed

+504
-62
lines changed

12 files changed

+504
-62
lines changed

src/assets/default-avatar.svg

Lines changed: 5 additions & 0 deletions
Loading

src/assets/default-banner.svg

Lines changed: 5 additions & 0 deletions
Loading

src/assets/utils/Base64Utils.ts

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

src/components/ConfigCard/ConfigCardSystem.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import LabelAndCheckbox from '@/components/LabelAndCheckbox.vue'
66
import { onMounted, ref } from 'vue'
77
import { useToast } from 'primevue/usetoast'
88
import { api } from '@/ApiInstance'
9+
import { unwrapApiError } from '@/utils/errorHandling'
910
import type { SystemConfigDto } from '@/__generated/model/dto'
1011
import type { ApiErrors } from '@/__generated/ApiErrors'
1112
const toast = useToast()
@@ -97,13 +98,7 @@ async function updatePassword() {
9798
life: 3000
9899
})
99100
} catch (error: any) {
100-
let err: ApiErrors['profileController']['updatePassword']
101-
if (error instanceof Promise) {
102-
err = (await error) as ApiErrors['profileController']['updatePassword']
103-
} else {
104-
err = error as ApiErrors['profileController']['updatePassword']
105-
}
106-
console.log(err)
101+
const err = await unwrapApiError<ApiErrors['profileController']['updatePassword']>(error)
107102
let detail = ''
108103
switch (err.code) {
109104
case 'EMPTY_LOGIN_NAME':

src/components/FileCard.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import FileUpload, { type FileUploadSelectEvent } from 'primevue/fileupload'
1212
import { useConfirm } from 'primevue/useconfirm'
1313
import LabelAndInput from './LabelAndInput.vue'
1414
import { api } from '@/ApiInstance'
15-
import { FileRecordVisibility_CONSTANTS } from '@/__generated/model/enums'
1615
import type { FileRecordDto } from '@/__generated/model/dto'
17-
import cloneWithFallback from '@/assets/utils/CloneWithCallback'
16+
import { cloneWithFallback } from '@/utils/CloneWithCallback'
1817
const dialogRef: any = inject('dialogRef')
1918
const confirm = useConfirm()
2019
const closeDialog = () => {

src/components/NoteCard.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { TreeNode } from 'primevue/treenode'
1010
import { useConfirm } from 'primevue/useconfirm'
1111
import { api } from '@/ApiInstance'
1212
import type { NoteDto } from '@/__generated/model/dto'
13-
import { BeautyLocalTime } from '@/assets/utils/BeautyDate'
13+
import { BeautyLocalTime } from '@/utils/BeautyDate'
1414
const confirm = useConfirm()
1515
const editNote = ref<NoteDto['NoteController/DEFAULT_NOTE']>({
1616
id: -1,
@@ -204,18 +204,18 @@ async function newNote() {
204204
</script>
205205
<template>
206206
<ConfirmPopup></ConfirmPopup>
207-
<div class="min-w-[80vw] min-h-[74vh] flex items-start justify-start">
208-
<div class="w-80 h-4/5 flex flex-col">
207+
<div class="flex min-h-[74vh] min-w-[80vw] items-start justify-start">
208+
<div class="flex h-4/5 w-80 flex-col">
209209
<Tree
210210
:value="treeNode"
211211
v-model:selectionKeys="selectedKey"
212212
selectionMode="single"
213213
></Tree>
214214
</div>
215215
<div class="w-full">
216-
<div class="flex justify-between items-center">
216+
<div class="flex items-center justify-between">
217217
<input
218-
class="font-bold outline-hidden text-xl border-b-[1px] ml-1 w-4/5 focus:border-black focus:outline-hidden"
218+
class="ml-1 w-4/5 border-b-[1px] text-xl font-bold outline-hidden focus:border-black focus:outline-hidden"
219219
v-model="editNote.title"
220220
/>
221221
<div>
@@ -239,10 +239,10 @@ async function newNote() {
239239
text
240240
@click="confirmDelete($event, editNote.id)"
241241
/>
242-
<Button :icon="'pi pi-plus'" text class="ml-auto mr-4" @click="newNote" />
242+
<Button :icon="'pi pi-plus'" text class="mr-4 ml-auto" @click="newNote" />
243243
</div>
244244
</div>
245-
<div v-show="vditorLoading" class="flex flex-col justify-center items-center pt-8">
245+
<div v-show="vditorLoading" class="flex flex-col items-center justify-center pt-8">
246246
<ProgressSpinner />
247247
<p class="mt-8">等待编辑器组件加载……</p>
248248
</div>

src/router/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { createRouter, createWebHistory } from 'vue-router'
44
const Landing = () => import('@/views/landing/LandingView.vue')
55
const UniBoard = () => import('@/views/DashBoardView.vue')
66
const FileShare = () => import('@/views/FileShareView.vue')
7+
const Setup = () => import('@/views/landing/SetupView.vue')
8+
79
const routes = [
810
{
911
path: '/',
@@ -19,6 +21,11 @@ const routes = [
1921
path: '/f/:fileShareCode',
2022
name: 'FileShare',
2123
component: FileShare
24+
},
25+
{
26+
path: '/setup',
27+
name: 'Setup',
28+
component: Setup
2229
}
2330
]
2431

src/assets/utils/BeautyDate.ts renamed to src/utils/BeautyDate.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function BeautyLocalTime(): string {
1+
export function BeautyLocalTime(): string {
22
const date = new Date()
33
const options: Intl.DateTimeFormatOptions = {
44
weekday: 'long',
@@ -13,5 +13,3 @@ function BeautyLocalTime(): string {
1313

1414
return date.toLocaleString(undefined, options)
1515
}
16-
17-
export { BeautyLocalTime }
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
function cloneWithFallback<T>(obj: T): T {
1+
export function cloneWithFallback<T>(obj: T): T {
22
if (typeof structuredClone === 'function') {
33
return structuredClone(obj)
44
} else {
55
return JSON.parse(JSON.stringify(obj))
66
}
77
}
8-
9-
export default cloneWithFallback

src/utils/errorHandling.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 从直接的错误对象或Promise拒绝中解析API错误
3+
* 该函数用于统一处理API错误,将各种形式的错误转换为可预期的类型化错误对象
4+
* @param error 需要解析的错误,可以是直接错误对象或Promise拒绝的结果
5+
* @returns 返回解析后的错误对象,类型为泛型T(通常是预定义的API错误类型)
6+
* @example
7+
* try {
8+
* // 尝试获取用户资料
9+
* } catch (error) {
10+
* // 解析错误为特定API控制器的错误类型
11+
* const err = await unwrapApiError<ApiErrors['profileController']['getProfile']>(error);
12+
* // 根据错误代码执行相应操作
13+
* if (err.code === 'SYSTEM_UNINITIALIZED') router.push('/setup');
14+
* }
15+
*/
16+
export async function unwrapApiError<T>(error: any): Promise<T> {
17+
if (error instanceof Promise) {
18+
return (await error) as T
19+
} else {
20+
return error as T
21+
}
22+
}

0 commit comments

Comments
 (0)