Skip to content

Commit 6d30f0b

Browse files
committed
feat: 启动错误收集与前端弹窗提示
1 parent b1583b6 commit 6d30f0b

7 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace ChuChartManager.Controllers;
4+
5+
[ApiController]
6+
[Route("api/[controller]/[action]")]
7+
public class AppStatusController : ControllerBase
8+
{
9+
[HttpGet]
10+
public ActionResult<IEnumerable<string>> GetStartupErrors()
11+
{
12+
return Ok(StaticSettings.Scanner?.Errors ?? []);
13+
}
14+
}

ChuChartManager/Front/src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ref, onMounted } from 'vue'
33
import { modalShowing, GlobalElementsContainer } from '@munet/ui'
44
import Sidebar from '@/components/Sidebar.vue'
55
import StatusBar from '@/components/StatusBar.vue'
6+
import StartupErrorDialog from '@/components/StartupErrorDialog'
67
import MusicList from '@/views/MusicList.vue'
78
import Course from '@/views/Course/index'
89
import ResourceManager from '@/views/ResourceManager/index'
@@ -44,6 +45,7 @@ const handleRefresh = () => {
4445
<Oobe v-if="isOobeWindow" :initStep="oobeInitStep" />
4546
<div v-else class="content-root" :class="{ 'modal-open': modalShowing }">
4647
<GlobalElementsContainer />
48+
<StartupErrorDialog />
4749
<div class="main-layout">
4850
<Sidebar v-model:active="sidebarActive" @refresh="handleRefresh" />
4951
<div class="main-content">

ChuChartManager/Front/src/api/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export async function getMusicList(source?: string): Promise<MusicListItem[]> {
6060
return data
6161
}
6262

63+
export async function getStartupErrors(): Promise<string[]> {
64+
const { data } = await apiClient.get('/api/AppStatus/GetStartupErrors')
65+
return data
66+
}
67+
6368
export async function getSources(): Promise<string[]> {
6469
const { data } = await apiClient.get('/api/Music/GetSources')
6570
return data
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { defineComponent, onMounted, ref } from 'vue'
2+
import { Modal } from '@munet/ui'
3+
import { useI18n } from 'vue-i18n'
4+
import { getStartupErrors } from '@/api'
5+
6+
export default defineComponent({
7+
setup() {
8+
const { t } = useI18n()
9+
const show = ref(false)
10+
const errors = ref<string[]>([])
11+
12+
onMounted(async () => {
13+
errors.value = await getStartupErrors()
14+
if (errors.value.length) show.value = true
15+
})
16+
17+
return () => (
18+
<Modal
19+
width="min(85vw,40em)"
20+
title={t('startup.errorTitle')}
21+
v-model:show={show.value}
22+
>
23+
<div class="flex flex-col gap-2 max-h-60vh overflow-y-auto">
24+
<div class="flex flex-col gap-1">
25+
{errors.value.map(error => (
26+
<div class="text-0.9em break-all">{error}</div>
27+
))}
28+
</div>
29+
<div class="op-60 mt-2">{t('startup.fixPrompt')}</div>
30+
</div>
31+
</Modal>
32+
)
33+
},
34+
})

ChuChartManager/Front/src/locales/en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ about:
5858
title: About
5959
version: App Version
6060
gameVersion: Game Version
61+
startup:
62+
errorTitle: Errors occurred during startup
63+
fixPrompt: Please review and fix the issues above. Edit or remove the affected files manually if necessary.
6164
oobe:
6265
welcomeMessage: Welcome to ChuChartManager
6366
selectGameDir: Select Game Directory

ChuChartManager/Front/src/locales/ja.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ about:
5858
title: について
5959
version: アプリバージョン
6060
gameVersion: ゲームバージョン
61+
startup:
62+
errorTitle: 起動時にエラーが発生しました
63+
fixPrompt: 上記の問題を確認して修正してください。必要に応じて該当ファイルを手動で編集または削除してください。
6164
oobe:
6265
welcomeMessage: ChuChartManager へようこそ
6366
selectGameDir: ゲームディレクトリを選択

ChuChartManager/Front/src/locales/zh.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ about:
5858
title: 关于
5959
version: 应用版本
6060
gameVersion: 游戏版本
61+
startup:
62+
errorTitle: 启动时发生错误
63+
fixPrompt: 请检查并修复以上问题,必要时手动修改或删除对应文件。
6164
oobe:
6265
welcomeMessage: 欢迎使用 ChuChartManager
6366
selectGameDir: 选择游戏目录

0 commit comments

Comments
 (0)