refactor: 重构环境检查逻辑,添加环境不完整提示页面
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<!-- 强行进入应用弹窗 -->
|
||||
<a-modal
|
||||
v-model:open="forceEnterVisible"
|
||||
title="警告"
|
||||
@@ -47,6 +47,8 @@
|
||||
show-icon
|
||||
/>
|
||||
</a-modal>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -83,11 +85,6 @@ const aborted = ref(false)
|
||||
// 状态:控制弹窗显隐
|
||||
const forceEnterVisible = ref(false)
|
||||
|
||||
// 镜像源重试相关状态
|
||||
const currentMirrorIndex = ref(0)
|
||||
const availableMirrors = ref<any[]>([])
|
||||
const maxRetries = ref(3)
|
||||
|
||||
// 点击“强行进入应用”按钮,显示弹窗
|
||||
function handleForceEnter() {
|
||||
forceEnterVisible.value = true
|
||||
@@ -197,11 +194,6 @@ async function checkGitUpdate(): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
// 根据镜像源key获取对应的URL
|
||||
function getGitMirrorUrl(mirrorKey: string): string {
|
||||
return getMirrorUrl('git', mirrorKey)
|
||||
}
|
||||
|
||||
// 尝试更新后端代码,支持镜像源重试
|
||||
async function tryUpdateBackendWithRetry(config: any): Promise<boolean> {
|
||||
// 获取所有Git镜像源
|
||||
|
||||
185
frontend/src/components/initialization/EnvironmentIncomplete.vue
Normal file
185
frontend/src/components/initialization/EnvironmentIncomplete.vue
Normal file
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div class="environment-incomplete">
|
||||
<div class="header">
|
||||
<img src="/src/assets/AUTO-MAS.ico" alt="logo" class="logo" />
|
||||
<a-typography-title :level="1">AUTO-MAS</a-typography-title>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<a-result
|
||||
status="warning"
|
||||
title="环境不完整"
|
||||
sub-title="检测到运行环境中缺少必要的组件,需要重新配置环境"
|
||||
>
|
||||
<template #extra>
|
||||
<div class="missing-components">
|
||||
<a-typography-title :level="4">缺失的组件:</a-typography-title>
|
||||
<a-list :data-source="missingComponents" size="small">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-typography-text type="danger">
|
||||
<ExclamationCircleOutlined /> {{ item }}
|
||||
</a-typography-text>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
<a-typography-paragraph>
|
||||
这种情况通常由以下原因导致:
|
||||
</a-typography-paragraph>
|
||||
<ul>
|
||||
<li>杀毒软件误删了相关文件</li>
|
||||
<li>手动删除了环境文件</li>
|
||||
<li>系统更新或清理工具清理了相关文件</li>
|
||||
</ul>
|
||||
<a-typography-paragraph>
|
||||
建议重新配置环境以确保程序正常运行。
|
||||
</a-typography-paragraph>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<a-button
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="handleReconfigure"
|
||||
>
|
||||
重新配置环境
|
||||
</a-button>
|
||||
<a-button
|
||||
size="large"
|
||||
@click="handleForceEnter"
|
||||
style="margin-left: 16px"
|
||||
>
|
||||
强行进入应用
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</a-result>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
||||
import router from '@/router'
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
missingComponents: string[]
|
||||
onSwitchToManual: () => void
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// 重新配置环境
|
||||
function handleReconfigure() {
|
||||
props.onSwitchToManual()
|
||||
}
|
||||
|
||||
// 强行进入应用
|
||||
function handleForceEnter() {
|
||||
router.push('/home')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.environment-incomplete {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: calc(100vh - 120px);
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 38px;
|
||||
font-weight: 600;
|
||||
color: var(--ant-color-text);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.missing-components {
|
||||
margin-bottom: 24px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.missing-components h4 {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.description {
|
||||
text-align: left;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.description ul {
|
||||
margin: 12px 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.description li {
|
||||
margin: 4px 0;
|
||||
color: var(--ant-color-text-secondary);
|
||||
}
|
||||
|
||||
.actions {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 响应式优化 */
|
||||
@media (max-height: 700px) {
|
||||
.environment-incomplete {
|
||||
min-height: auto;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.header {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.actions .ant-btn {
|
||||
width: 200px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -48,7 +48,7 @@
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
|
||||
<a-steps :current="currentStep" :status="stepStatus" class="init-steps">
|
||||
<a-steps :current="displayCurrentStep" :status="stepStatus" class="init-steps">
|
||||
<a-step title="设置主题" />
|
||||
<a-step title="配置环境" />
|
||||
<a-step title="Git 工具" />
|
||||
@@ -136,7 +136,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { notification } from 'ant-design-vue'
|
||||
import { saveConfig } from '@/utils/config'
|
||||
import { useUpdateChecker } from '@/composables/useUpdateChecker'
|
||||
@@ -177,6 +177,11 @@ const stepStatus = ref<'wait' | 'process' | 'finish' | 'error'>('process')
|
||||
const errorMessage = ref('')
|
||||
const isProcessing = ref(false)
|
||||
|
||||
// 显示的当前步骤就是实际步骤
|
||||
const displayCurrentStep = computed(() => {
|
||||
return currentStep.value
|
||||
})
|
||||
|
||||
// 全局进度条状态
|
||||
const globalProgress = ref(0)
|
||||
const globalProgressStatus = ref<'normal' | 'exception' | 'success'>('normal')
|
||||
@@ -239,9 +244,8 @@ async function handleNextStep() {
|
||||
break
|
||||
case 4: // 依赖安装
|
||||
console.log('执行依赖安装')
|
||||
if (!props.dependenciesInstalled) {
|
||||
await installDependencies()
|
||||
}
|
||||
// 总是执行依赖安装,确保环境完整
|
||||
await installDependencies()
|
||||
break
|
||||
case 5: // 启动服务
|
||||
console.log('执行启动服务')
|
||||
@@ -274,7 +278,7 @@ function getNextButtonText() {
|
||||
case 3:
|
||||
return props.backendExists ? '更新代码' : '获取代码'
|
||||
case 4:
|
||||
return '安装依赖'
|
||||
return props.dependenciesInstalled ? '重新安装依赖' : '安装依赖'
|
||||
case 5:
|
||||
return '启动服务'
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user