fix: align legacy general access call boundaries

This commit is contained in:
2026-07-31 07:33:26 +00:00
parent 821da19731
commit 98a3cf514f
34 changed files with 909 additions and 177 deletions
-18
View File
@@ -41,32 +41,14 @@ import { useSessionStore } from '../stores/session';
import { trpc } from '../utils/trpc';
const accessPageByRouteName = {
home: 'front-info',
'nation-info': 'nation-info',
'nation-cities': 'nation-cities',
'global-info': 'global-info',
'nation-list': 'nation-list',
'general-list': 'general-list',
'current-city': 'current-city',
diplomacy: 'diplomacy',
'nation-generals': 'nation-generals',
'nation-personnel': 'nation-personnel',
'nation-finance': 'nation-finance',
'battle-center': 'battle-center',
board: 'board',
'board-secret': 'board',
'best-general': 'best-general',
'hall-of-fame': 'hall-of-fame',
'dynasty-list': 'dynasty',
'dynasty-detail': 'dynasty',
yearbook: 'yearbook',
'nation-betting': 'nation-betting',
traffic: 'traffic',
'npc-list': 'npc-list',
'my-page': 'my-page',
'npc-control': 'npc-control',
tournament: 'tournament',
betting: 'betting',
} as const;
const routes = [
+2 -1
View File
@@ -86,9 +86,10 @@ const placeBet = async (targetId: number) => {
try {
await trpc.tournament.placeBet.mutate({ targetId, amount });
message.value = '베팅이 등록되었습니다.';
await load();
} catch (value) {
message.value = errorText(value);
} finally {
await load();
}
};
</script>
@@ -106,10 +106,7 @@ watch([selectedSeason, selectedScenario], () => {
void loadHall();
});
onMounted(async () => {
await loadOptions();
await loadHall();
});
onMounted(loadOptions);
</script>
<template>
+24 -12
View File
@@ -187,7 +187,7 @@ const loadLog = async (type: LogType, beforeId?: number) => {
}
};
const loadPage = async () => {
const loadPage = async (resetImmediateActionIds = true) => {
if (loading.value) return;
loading.value = true;
error.value = null;
@@ -206,7 +206,9 @@ const loadPage = async () => {
Object.assign(form, general.settings);
}
await Promise.all(logTypes.map((type) => loadLog(type)));
resetImmediateActionRequestIds();
if (resetImmediateActionIds) {
resetImmediateActionRequestIds();
}
} catch (cause) {
error.value = errorText(cause);
} finally {
@@ -224,13 +226,17 @@ const saveSettings = async () => {
}
};
const confirmMutation = async (message: string, mutation: () => Promise<unknown>) => {
const confirmMutation = async (message: string, mutation: () => Promise<unknown>, reloadAfterFailure = false) => {
if (!confirm(message)) return;
try {
await mutation();
await loadPage();
} catch (cause) {
alert(`실패했습니다: ${errorText(cause)}`);
if (reloadAfterFailure) {
const code = asRecord(asRecord(cause).data).code;
await loadPage(code !== 'TIMEOUT');
}
}
};
@@ -288,7 +294,7 @@ onMounted(() => {
<span> </span>
<RouterLink class="legacy-button" to="/past-plays">지난 플레이</RouterLink>
<RouterLink class="legacy-button" to="/">돌아가기</RouterLink>
<button class="legacy-button" type="button" @click="loadPage">새로고침</button>
<button class="legacy-button" type="button" @click="() => loadPage()">새로고침</button>
</div>
<div v-if="error" class="error-row">{{ error }}</div>
@@ -430,10 +436,13 @@ onMounted(() => {
<button
class="action-button"
@click="
confirmMutation('거병 이후 장수를 삭제할 수 없게됩니다. 거병하시겠습니까?', () =>
trpc.general.buildNationCandidate.mutate({
clientRequestId: immediateActionRequestIds.buildNationCandidate,
})
confirmMutation(
'거병 이후 장수를 삭제할 수 없게됩니다. 거병하시겠습니까?',
() =>
trpc.general.buildNationCandidate.mutate({
clientRequestId: immediateActionRequestIds.buildNationCandidate,
}),
true
)
"
>
@@ -445,10 +454,13 @@ onMounted(() => {
<button
class="action-button"
@click="
confirmMutation('아군 접경으로 이동할까요?', () =>
trpc.general.instantRetreat.mutate({
clientRequestId: immediateActionRequestIds.instantRetreat,
})
confirmMutation(
'아군 접경으로 이동할까요?',
() =>
trpc.general.instantRetreat.mutate({
clientRequestId: immediateActionRequestIds.instantRetreat,
}),
true
)
"
>
@@ -102,9 +102,10 @@ const join = async () => {
try {
await trpc.tournament.join.mutate();
actionMessage.value = '참가 신청이 반영되었습니다.';
await load();
} catch (value) {
actionMessage.value = errorText(value);
} finally {
await load();
}
};