diff --git a/app/components.d.ts b/app/components.d.ts index 6b4e936f..80656f4a 100644 --- a/app/components.d.ts +++ b/app/components.d.ts @@ -107,6 +107,7 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] SelfCheckSelfCheck: typeof import('./src/components/SelfCheck/SelfCheck.vue')['default'] + SelfCheckSelfCheckHeaderBanner: typeof import('./src/components/SelfCheck/SelfCheckHeaderBanner.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/components/SelfCheck/SelfCheck.vue b/app/src/components/SelfCheck/SelfCheck.vue index 843c8364..234dee58 100644 --- a/app/src/components/SelfCheck/SelfCheck.vue +++ b/app/src/components/SelfCheck/SelfCheck.vue @@ -1,48 +1,14 @@ @@ -50,7 +16,10 @@ defineExpose({ {{ $gettext('Recheck') }} @@ -58,7 +27,7 @@ defineExpose({ - + {{ $gettext('Attempt to fix') }} diff --git a/app/src/components/SelfCheck/SelfCheckHeaderBanner.vue b/app/src/components/SelfCheck/SelfCheckHeaderBanner.vue new file mode 100644 index 00000000..e1663b3a --- /dev/null +++ b/app/src/components/SelfCheck/SelfCheckHeaderBanner.vue @@ -0,0 +1,88 @@ + + + + + + + + + {{ $gettext('Check') }} + + + + + + + + + + + + {{ $gettext('Self check failed, Nginx UI may not work properly') }} + + + + {{ $gettext('Check') }} + + + + + + + + + diff --git a/app/src/components/SelfCheck/index.ts b/app/src/components/SelfCheck/index.ts index 959857bf..169c5b2f 100644 --- a/app/src/components/SelfCheck/index.ts +++ b/app/src/components/SelfCheck/index.ts @@ -1,3 +1,10 @@ import SelfCheck from './SelfCheck.vue' +import SelfCheckHeaderBanner from './SelfCheckHeaderBanner.vue' +import { useSelfCheckStore } from './store' + +export { + SelfCheckHeaderBanner, + useSelfCheckStore, +} export default SelfCheck diff --git a/app/src/components/SelfCheck/store.ts b/app/src/components/SelfCheck/store.ts new file mode 100644 index 00000000..a67076e9 --- /dev/null +++ b/app/src/components/SelfCheck/store.ts @@ -0,0 +1,54 @@ +import type { TaskReport } from './tasks' +import { debounce } from 'lodash' +import { taskManager } from './tasks' + +export const useSelfCheckStore = defineStore('selfCheck', () => { + const data = ref([]) + + const requestError = ref(false) + const loading = ref(false) + + async function __check() { + if (loading.value) + return + + loading.value = true + try { + data.value = await taskManager.runAllChecks() + } + catch (error) { + console.error(error) + requestError.value = true + } + finally { + loading.value = false + } + } + + const check = debounce(__check, 1000, { + leading: true, + trailing: false, + }) + + const fixing = reactive({}) + + async function fix(taskName: string) { + if (fixing[taskName]) + return + + fixing[taskName] = true + try { + await taskManager.fixTask(taskName) + check() + } + finally { + fixing[taskName] = false + } + } + + const hasError = computed(() => { + return requestError.value || data.value?.some(item => item.status === 'error') + }) + + return { data, loading, fixing, hasError, check, fix } +}) diff --git a/app/src/layouts/HeaderLayout.vue b/app/src/layouts/HeaderLayout.vue index b287c99a..363a9cb7 100644 --- a/app/src/layouts/HeaderLayout.vue +++ b/app/src/layouts/HeaderLayout.vue @@ -1,11 +1,12 @@ @@ -36,7 +42,13 @@ const isWorkspace = computed(() => { + + @@ -74,7 +86,7 @@ const isWorkspace = computed(() => { background: transparent; box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.05); width: 100%; - + position: relative; a { color: #000000; } diff --git a/app/src/views/install/components/InstallView.vue b/app/src/views/install/components/InstallView.vue index c24d0469..57fc62c6 100644 --- a/app/src/views/install/components/InstallView.vue +++ b/app/src/views/install/components/InstallView.vue @@ -1,6 +1,6 @@