refactor(steps): 优化初始化页面的布局。让IDE能够正确识别@

This commit is contained in:
2025-09-02 13:26:06 +08:00
parent a40fa37bfd
commit 11e3c2281e
12 changed files with 87 additions and 210 deletions

View File

@@ -31,7 +31,7 @@
</div>
</div>
<div class="mirror-description">{{ mirror.description }}</div>
<div class="mirror-url">{{ mirror.url }}</div>
<!-- <div class="mirror-url">{{ mirror.url }}</div>-->
</div>
</div>
</div>
@@ -62,14 +62,14 @@
</div>
</div>
<div class="mirror-description">{{ mirror.description }}</div>
<div class="mirror-url">{{ mirror.url }}</div>
<!-- <div class="mirror-url">{{ mirror.url }}</div>-->
</div>
</div>
</div>
<div class="test-actions">
<a-button @click="testGitMirrorSpeed" :loading="testingGitSpeed" type="primary">
{{ testingGitSpeed ? '测速中...' : '开始测速' }}
{{ testingGitSpeed ? '测速中...' : '重新测速' }}
</a-button>
<span class="test-note">3秒无响应视为超时</span>
</div>
@@ -206,7 +206,7 @@ onMounted(async () => {
font-size: 20px;
font-weight: 600;
color: var(--ant-color-text);
margin-bottom: 20px;
}
.install-section {
@@ -224,7 +224,7 @@ onMounted(async () => {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 16px;
margin-bottom: 20px;
}
.mirror-card {
@@ -308,9 +308,6 @@ onMounted(async () => {
word-break: break-all;
}
.mirror-section {
margin-bottom: 24px;
}
.section-header {
display: flex;

View File

@@ -201,7 +201,6 @@ onMounted(async () => {
font-size: 20px;
font-weight: 600;
color: var(--ant-color-text);
margin-bottom: 20px;
}
.install-section {
@@ -219,7 +218,6 @@ onMounted(async () => {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 16px;
margin-bottom: 20px;
}
.mirror-card {
@@ -303,9 +301,6 @@ onMounted(async () => {
word-break: break-all;
}
.mirror-section {
margin-bottom: 24px;
}
.section-header {
display: flex;

View File

@@ -6,7 +6,7 @@
<div class="git-info">
<a-alert
message="Git 工具信息"
description="将安装便携版 Git 工具,包含完整的版本控制功能,无需系统安装。"
description="将安装便携版 Git 工具,以实现后端代码更新。"
type="info"
show-icon
/>

View File

@@ -6,19 +6,19 @@
>欢迎使用 AUTO_MAA让我们来配置您的运行环境</a-typography-title
>
<!-- <div class="header-actions">-->
<!-- <a-button size="large" type="primary" @click="handleSkipToHome">-->
<!-- 跳转至首页仅开发用-->
<!-- </a-button>-->
<!-- <a-button-->
<!-- size="large"-->
<!-- type="default"-->
<!-- @click="handleJumpToStep(5)"-->
<!-- style="margin-left: 16px"-->
<!-- >-->
<!-- 跳到启动服务第六步-->
<!-- </a-button>-->
<!-- </div>-->
<div class="header-actions">
<a-button size="large" type="primary" @click="handleSkipToHome">
跳转至首页仅开发用
</a-button>
<a-button
size="large"
type="default"
@click="handleJumpToStep(3)"
style="margin-left: 16px"
>
跳到启动服务第六步
</a-button>
</div>
</div>
<a-steps :current="currentStep" :status="stepStatus" class="init-steps">

View File

@@ -1,122 +0,0 @@
<template>
<div class="step-panel">
<h3>安装 pip 包管理器</h3>
<div v-if="!pipInstalled" class="install-section">
<p>pip Python 的包管理工具用于安装和管理 Python </p>
<div class="pip-info">
<a-alert
message="pip 安装信息"
description="将自动下载并安装 pip 包管理器,这是安装 Python 依赖包的必要工具。"
type="info"
show-icon
/>
</div>
</div>
<div v-else class="already-installed">
<a-result status="success" title="pip已成功安装无需继续安装" />
<!-- <div class="reinstall-section">-->
<!-- <a-button type="primary" danger @click="handleForceReinstall" :loading="reinstalling">-->
<!-- {{ reinstalling ? '正在重新安装...' : '强制重新安装' }}-->
<!-- </a-button>-->
<!-- <p class="reinstall-note">点击此按钮将删除现有pip环境并重新安装</p>-->
<!-- </div>-->
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{
pipInstalled: boolean
}>()
const reinstalling = ref(false)
// 强制重新安装pip
async function handleForceReinstall() {
reinstalling.value = true
try {
console.log('开始强制重新安装pip')
// 先删除现有pip
const deleteResult = await window.electronAPI.deletePip()
if (!deleteResult.success) {
throw new Error(`删除pip失败: ${deleteResult.error}`)
}
// 重新安装pip
const installResult = await window.electronAPI.installPip()
if (!installResult.success) {
throw new Error(`重新安装pip失败: ${installResult.error}`)
}
console.log('pip强制重新安装成功')
// 通知父组件更新状态
window.location.reload() // 简单的页面刷新来更新状态
} catch (error) {
console.error('pip强制重新安装失败:', error)
// 这里可以添加错误提示
} finally {
reinstalling.value = false
}
}
defineExpose({
handleForceReinstall,
})
</script>
<style scoped>
.step-panel {
padding: 20px;
background: var(--ant-color-bg-elevated);
border-radius: 8px;
border: 1px solid var(--ant-color-border);
}
.step-panel h3 {
font-size: 20px;
font-weight: 600;
color: var(--ant-color-text);
margin-bottom: 20px;
}
.install-section {
display: flex;
flex-direction: column;
gap: 20px;
}
.install-section p {
color: var(--ant-color-text-secondary);
margin: 0;
}
.pip-info {
margin-top: 16px;
}
.already-installed {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 200px;
gap: 20px;
}
.reinstall-section {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.reinstall-note {
font-size: 12px;
color: var(--ant-color-text-tertiary);
text-align: center;
margin: 0;
}
</style>

View File

@@ -2,7 +2,7 @@
<div class="step-panel">
<h3>Python 运行环境</h3>
<div v-if="!pythonInstalled" class="install-section">
<p>需要安装 Python 3.13.0 运行环境64位嵌入式版本</p>
<p>需要安装 Python 3.13.0 运行环境</p>
<!-- 镜像源 -->
<div class="mirror-section">
@@ -31,7 +31,7 @@
</div>
</div>
<div class="mirror-description">{{ mirror.description }}</div>
<div class="mirror-url">{{ mirror.url }}</div>
<!-- <div class="mirror-url">{{ mirror.url }}</div>-->
</div>
</div>
</div>
@@ -62,7 +62,7 @@
</div>
</div>
<div class="mirror-description">{{ mirror.description }}</div>
<div class="mirror-url">{{ mirror.url }}</div>
<!-- <div class="mirror-url">{{ mirror.url }}</div>-->
</div>
</div>
</div>
@@ -264,7 +264,7 @@ onMounted(async () => {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 16px;
margin-bottom: 20px;
}
.mirror-card {
@@ -353,9 +353,7 @@ onMounted(async () => {
word-break: break-all;
}
.mirror-section {
margin-bottom: 24px;
}
.section-header {
display: flex;

View File

@@ -89,40 +89,40 @@ const router = createRouter({
routes,
})
// 添加路由守卫,确保在生产环境中也能正确进入初始化页面
router.beforeEach(async (to, from, next) => {
console.log('路由守卫:', { to: to.path, from: from.path })
// 如果目标就是初始化页,放行并清除一次性标记,避免反复跳转
if (to.path === '/initialization') {
needInitLanding = false
next()
return
}
// (可选)开发环境跳过检查,可按需恢复
const isDev = import.meta.env.VITE_APP_ENV === 'dev'
if (isDev) return next()
// 先按原逻辑:未初始化 => 强制进入初始化
const initialized = await isAppInitialized()
console.log('检查初始化状态:', initialized)
if (!initialized) {
needInitLanding = false // 以免重复重定向
next('/initialization')
return
}
// 已初始化:如果是“本次启动的第一次进入”,也先去初始化页一次
if (needInitLanding) {
needInitLanding = false
next({ path: '/initialization', query: { redirect: to.fullPath } })
return
}
// 其他情况正常放行
next()
})
// // 添加路由守卫,确保在生产环境中也能正确进入初始化页面
// router.beforeEach(async (to, from, next) => {
// console.log('路由守卫:', { to: to.path, from: from.path })
//
// // 如果目标就是初始化页,放行并清除一次性标记,避免反复跳转
// if (to.path === '/initialization') {
// needInitLanding = false
// next()
// return
// }
//
// // (可选)开发环境跳过检查,可按需恢复
// const isDev = import.meta.env.VITE_APP_ENV === 'dev'
// if (isDev) return next()
//
// // 先按原逻辑:未初始化 => 强制进入初始化
// const initialized = await isAppInitialized()
// console.log('检查初始化状态:', initialized)
// if (!initialized) {
// needInitLanding = false // 以免重复重定向
// next('/initialization')
// return
// }
//
// // 已初始化:如果是“本次启动的第一次进入”,也先去初始化页一次
// if (needInitLanding) {
// needInitLanding = false
// next({ path: '/initialization', query: { redirect: to.fullPath } })
// return
// }
//
// // 其他情况正常放行
// next()
// })
export default router

View File

@@ -1,14 +1,10 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
/* Module Resolution */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,

View File

@@ -0,0 +1,9 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}

View File

@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"strict": true,
"outDir": "dist-electron",
"rootDir": "electron",
"esModuleInterop": true,
"types": ["node", "electron"]
},
"include": ["electron"]
}

View File

@@ -1,16 +1,7 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"strict": true,
"outDir": "dist-electron",
"rootDir": "electron",
"esModuleInterop": true,
"types": ["node", "electron"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["electron"]
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.electron.json" }
]
}

View File

@@ -9,7 +9,7 @@ export default defineConfig({
resolve: {
extensions: ['.js', '.ts', '.vue', '.json'],
alias: {
'@': path.resolve(__dirname, 'src'),
'@': path.resolve(__dirname, './src'),
},
},
})