Skip to content

Commit 0a70c8b

Browse files
authored
feat(settings): add settings page (#117)
1 parent a4bfddd commit 0a70c8b

File tree

6 files changed

+323
-6
lines changed

6 files changed

+323
-6
lines changed

.changes/pre.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"tag": "beta",
2+
"tag": "rc",
33
"changes": [
44
".changes/add-icon.md",
55
".changes/birthday.md",

.changes/settings.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"algohub": patch:feat
3+
---
4+
5+
Add settings page to edit user profile and education info.

src/components/MonacoEditor.vue

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const disposeEditor = () => {
7171
if (editor.value) {
7272
toRaw(editor.value).dispose();
7373
}
74+
self.MonacoEnvironment = undefined;
7475
}
7576
7677
onUnmounted(disposeEditor)

src/components/UniversalFooter.vue

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
<script setup lang="ts">
22
import { useThemeStore } from '@/scripts/store';
3+
import { useRouter } from 'vue-router';
34
45
const themeStore = useThemeStore();
6+
const router = useRouter();
57
</script>
68

79
<template>
810
<footer class="w-full bg-gray-3 dark:bg-gray-9 text-center my-6">
9-
<div class="container mx-auto">
10-
<div class="inline-flex gap-4 justify-center items-center">
11-
<Avatar :image="themeStore.logo"></Avatar>
11+
<div class="flex flex-col mx-auto">
12+
<div class="inline-flex gap-2 justify-center items-center">
13+
<Avatar @click="router.push('/')" class="cursor-pointer hover:grayscale-[50%] hover:shadow-md"
14+
:image="themeStore.logo"></Avatar>
1215
<span class="text-sm">© 2024 SWPU-ACM, org. All rights reserved.</span>
1316
</div>
17+
<div class="my-2 inline-flex flex-wrap gap-2 justify-center items-center">
18+
<Button link as="a" href="https://github.com/swpu-acm/algohub" target="_blank" icon="pi pi-github" text
19+
plain></Button>
20+
<Button link as="a" href="https://qm.qq.com/q/NRSl1be2se" target="_blank" class="text-white" text plain>
21+
<template #icon>
22+
<svg t="1734574470382" class="icon" viewBox="0 0 1024 1024" version="1.1"
23+
xmlns="http://www.w3.org/2000/svg" p-id="1451" width="20">
24+
<path
25+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m210.5 612.4c-11.5 1.4-44.9-52.7-44.9-52.7 0 31.3-16.2 72.2-51.1 101.8 16.9 5.2 54.9 19.2 45.9 34.4-7.3 12.3-125.6 7.9-159.8 4-34.2 3.8-152.5 8.3-159.8-4-9.1-15.2 28.9-29.2 45.8-34.4-35-29.5-51.1-70.4-51.1-101.8 0 0-33.4 54.1-44.9 52.7-5.4-0.7-12.4-29.6 9.4-99.7 10.3-33 22-60.5 40.2-105.8-3.1-116.9 45.3-215 160.4-215 113.9 0 163.3 96.1 160.4 215 18.1 45.2 29.9 72.8 40.2 105.8 21.7 70.1 14.6 99.1 9.3 99.7z"
26+
p-id="1452" :fill="themeStore.dark ? '#fff' : '#000'"></path>
27+
</svg>
28+
</template>
29+
</Button>
30+
</div>
1431
</div>
1532
</footer>
1633
</template>

src/views/account/[id].vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useAccountStore, useThemeStore } from "@/scripts/store";
44
import { timeAgo } from "@/scripts/time";
55
import { UserProblem, type Profile } from "@/scripts/types";
66
import { expandAssetUrl } from "@/scripts/utils";
7-
import { Avatar, useToast } from "primevue";
7+
import { useToast } from "primevue";
88
import { onMounted, reactive, Ref, ref, watch } from "vue";
99
import { useRoute, useRouter } from "vue-router";
1010
@@ -116,6 +116,7 @@ const onSaveProfile = async ({ states }: { states: Form<Profile> }) => {
116116
return toast.add({ severity: "error", summary: "Error", detail: res.message });
117117
}
118118
Object.assign(profile.value!, data);
119+
Object.assign(accountStore.account, profile.value);
119120
editingProfile.value = false;
120121
inProgress.value = false;
121122
toast.add({ severity: "success", summary: "Profile updated", detail: "Your profile has been updated." });
@@ -140,12 +141,15 @@ const onSaveProfile = async ({ states }: { states: Form<Profile> }) => {
140141
<div class="w-full max-w-[1200px] flex flex-col md:flex-row my-[2em] gap-6 mx-8">
141142
<div v-if="!loading && profile" class="flex flex-col h-full md:w-[18em]">
142143
<div class="flex w-full flex-row md:flex-col gap-4">
143-
<div class="flex-shrink-0 w-[8em] md:w-[18em]">
144+
<div class="flex-shrink-0 w-[8em] md:w-[18em]"
145+
@click="accountStore.account?.username === profile.username && router.push('/settings/profile')">
144146
<img v-if="profile?.avatar"
145147
class="rounded-full border-[2px] border-zinc-300 dark:border-zinc-700"
148+
:class="{ 'cursor-pointer': accountStore.account?.username === profile.username }"
146149
:src="expandAssetUrl(profile.avatar!)"></img>
147150
<Avatar v-else pt:root:class="!w-[8em] md:!w-[18em] !h-[8em] md:!h-[18em]"
148151
pt:label:class="text-4xl md:text-9xl" :label="(profile?.nickname ?? '?')[0]"
152+
:class="{ 'cursor-pointer': accountStore.account?.username === profile.username }"
149153
shape="circle" class="border-[2px] border-zinc-300 dark:border-zinc-700">
150154
</Avatar>
151155
</div>

0 commit comments

Comments
 (0)