diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7173f9d5..68502f36 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,7 +29,8 @@ "github.copilot", "golang.go", "vue.volar", - "ms-azuretools.vscode-docker" + "ms-azuretools.vscode-docker", + "akino.i18n-gettext" ] } }, diff --git a/.gitignore b/.gitignore index 0c38fd5e..99140d39 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ internal/**/*.gen.go .devcontainer/go-path .devcontainer/data .devcontainer/casdoor.pem +.vscode/.i18n-gettext.secret diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f01e6012 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "i18n-gettext.localesConfig": { + "type": "nested", + "basePath": "app/src/language", + "pattern": "${locale}/${domain}.po", + "defaultDomain": "app", + "sourceLanguage": "en" + }, +} \ No newline at end of file diff --git a/api/system/router.go b/api/system/router.go index a22f6644..5190c6f2 100644 --- a/api/system/router.go +++ b/api/system/router.go @@ -5,6 +5,14 @@ import ( "github.com/gin-gonic/gin" ) +func authIfInstalled(ctx *gin.Context) { + if installLockStatus() || isInstallTimeoutExceeded() { + middleware.AuthRequired()(ctx) + } else { + ctx.Next() + } +} + func InitPublicRouter(r *gin.RouterGroup) { r.GET("install", InstallLockCheck) r.POST("install", middleware.EncryptedParams(), InstallNginxUI) @@ -14,23 +22,18 @@ func InitPublicRouter(r *gin.RouterGroup) { func InitPrivateRouter(r *gin.RouterGroup) { r.GET("upgrade/release", GetRelease) r.GET("upgrade/current", GetCurrentVersion) - r.GET("self_check", SelfCheck) - r.POST("self_check/:name/fix", SelfCheckFix) - // Backup endpoint only r.GET("system/backup", CreateBackup) } +func InitSelfCheckRouter(r *gin.RouterGroup) { + r.GET("self_check", authIfInstalled, SelfCheck) + r.POST("self_check/:name/fix", authIfInstalled, SelfCheckFix) +} + func InitBackupRestoreRouter(r *gin.RouterGroup) { r.POST("system/backup/restore", - func(ctx *gin.Context) { - // If system is installed, verify user authentication - if installLockStatus() { - middleware.AuthRequired()(ctx) - } else { - ctx.Next() - } - }, + authIfInstalled, middleware.EncryptedForm(), RestoreBackup) } diff --git a/app/components.d.ts b/app/components.d.ts index 0e9412d7..6b4e936f 100644 --- a/app/components.d.ts +++ b/app/components.d.ts @@ -106,6 +106,7 @@ declare module 'vue' { ReactiveFromNowReactiveFromNow: typeof import('./src/components/ReactiveFromNow/ReactiveFromNow.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + SelfCheckSelfCheck: typeof import('./src/components/SelfCheck/SelfCheck.vue')['default'] SensitiveStringSensitiveString: typeof import('./src/components/SensitiveString/SensitiveString.vue')['default'] SetLanguageSetLanguage: typeof import('./src/components/SetLanguage/SetLanguage.vue')['default'] StdDesignStdDataDisplayStdBatchEdit: typeof import('./src/components/StdDesign/StdDataDisplay/StdBatchEdit.vue')['default'] diff --git a/app/src/views/system/SelfCheck/SelfCheck.vue b/app/src/components/SelfCheck/SelfCheck.vue similarity index 91% rename from app/src/views/system/SelfCheck/SelfCheck.vue rename to app/src/components/SelfCheck/SelfCheck.vue index 0f5e181a..843c8364 100644 --- a/app/src/views/system/SelfCheck/SelfCheck.vue +++ b/app/src/components/SelfCheck/SelfCheck.vue @@ -4,6 +4,7 @@ import { CheckCircleOutlined, CloseCircleOutlined, WarningOutlined } from '@ant- import { taskManager } from './tasks' const data = ref() +const requestError = ref(false) const loading = ref(false) async function check() { @@ -11,6 +12,9 @@ async function check() { try { data.value = await taskManager.runAllChecks() } + catch { + requestError.value = true + } finally { loading.value = false } @@ -32,6 +36,14 @@ async function fix(taskName: string) { fixing[taskName] = false } } + +const hasError = computed(() => { + return requestError.value || data.value?.some(item => item.status === 'error') +}) + +defineExpose({ + hasError, +})