fix: 個人資料修改後滾動至上方

This commit is contained in:
skytek_xinliang
2026-08-31 14:37:27 +08:00
parent 403d6eaa0e
commit 7abe650757
+9 -1
View File
@@ -200,7 +200,7 @@
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from "vue";
import { computed, nextTick, onMounted, reactive, ref } from "vue";
import Layout from "@/components/layout/DefaultLayout.vue";
import type { UserProfile } from "@/stores/app";
import { useAppStore } from "@/stores/app";
@@ -305,6 +305,11 @@ function validateForm() {
return "";
}
async function scrollToPageTop() {
await nextTick();
window.scrollTo({ top: 0 });
}
async function handleSubmit() {
errorMessage.value = "";
successMessage.value = "";
@@ -312,6 +317,7 @@ async function handleSubmit() {
const validationError = validateForm();
if (validationError) {
errorMessage.value = validationError;
await scrollToPageTop();
return;
}
@@ -338,6 +344,8 @@ async function handleSubmit() {
} finally {
saving.value = false;
}
await scrollToPageTop();
}
onMounted(async () => {