fix: C 端溯源页切换短码时重新加载数据

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 17:08:15 +08:00
co-authored by Cursor
parent 45c4b11938
commit a58c71495d
2 changed files with 24 additions and 8 deletions
+22 -8
View File
@@ -126,7 +126,7 @@
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { computed, onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import dayjs from 'dayjs';
@@ -182,6 +182,19 @@ async function copy(text?: string) {
setTimeout(() => (toast.value = ''), 1500);
}
async function load(code: string) {
loading.value = true;
data.value = null;
lightbox.value = '';
try {
data.value = await fetchTrace(code);
} catch {
data.value = { status: 'INVALID' };
} finally {
loading.value = false;
}
}
onMounted(async () => {
try {
const info = await fetchAppInfo();
@@ -189,14 +202,15 @@ onMounted(async () => {
} catch {
appName.value = t('app.name');
}
try {
data.value = await fetchTrace(String(route.params.code));
} catch {
data.value = { status: 'INVALID' };
} finally {
loading.value = false;
}
});
watch(
() => route.params.code,
(code) => {
if (code) load(String(code));
},
{ immediate: true },
);
</script>
<style scoped>