重构: 应用代码移入 internal/app 包,根目录只留入口

根目录原 7 个 app*.go 平铺,现收进 internal/app/ 子包:
- package main → package app
- NewApp → New(导出)
- startup/shutdown → Startup/Shutdown(导出,供 main.go 引用)
- main.go 改为薄入口,仅导入 internal/app 并装配 Wails

前端同步更新(Wails 绑定路径 go/main → go/app):
- window.go.main.App → window.go.app.App(10 处)
- env.d.ts 类型声明路径 wailsjs/go/main/App → wailsjs/go/app/App

根目录 Go 文件从 7 个减至 1 个(main.go),元文件更清晰
This commit is contained in:
yml2213
2026-07-29 13:27:08 +08:00
parent 5631f579ea
commit 2c88edb741
16 changed files with 31 additions and 29 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ let timeTimer: number | null = null
let logTimer: number | null = null
let resultTimer: number | null = null
const App = window.go.main.App
const App = window.go.app.App
const updateTime = async () => {
try {
+1 -1
View File
@@ -6,7 +6,7 @@ import { useToast } from '@/composables/useToast'
const { selectedProductId, selectedProductName, selectedProduct } = useProducts()
const { showToast } = useToast()
const App = window.go.main.App
const App = window.go.app.App
// 状态
const loading = ref(false)
+1 -1
View File
@@ -13,7 +13,7 @@ export interface AccountStatus {
message?: string
}
const App = window.go.main.App
const App = window.go.app.App
const accounts = ref<Account[]>([])
const selectedIndices = ref<Set<number>>(new Set())
+2 -2
View File
@@ -12,8 +12,8 @@ const activities = ref<ActivityItem[]>([])
const currentActivity = ref<ActivityItem | null>(null)
const switching = ref(false)
// 与项目其他 composable 一致,直接走 Wails 运行时注入的 window.go.main.App
const App = window.go.main.App
// 与项目其他 composable 一致,直接走 Wails 运行时注入的 window.go.app.App
const App = window.go.app.App
export function useActivity() {
const { showToast } = useToast()
+1 -1
View File
@@ -20,7 +20,7 @@ export interface LogMessage {
source: 'local' | 'server'
}
const App = window.go.main.App
const App = window.go.app.App
const logs = ref<LogMessage[]>([])
const results = ref<Record<string, string>>({})
+1 -1
View File
@@ -25,7 +25,7 @@ export interface ProductPayload {
stale: boolean
}
const App = window.go.main.App
const App = window.go.app.App
const products = ref<Product[]>([])
const productInfo = ref<ProductPayload | null>(null)
+1 -1
View File
@@ -4,7 +4,7 @@ import { useAccounts } from './useAccounts'
import { useProducts } from './useProducts'
import { useLogs } from './useLogs'
const App = window.go.main.App
const App = window.go.app.App
const scheduleActive = ref(false)
const countdownSeconds = ref(0)
+1 -1
View File
@@ -17,7 +17,7 @@ export interface Settings {
seckillMode: number // 0=标准, 1=激进
}
const App = window.go.main.App
const App = window.go.app.App
const defaultRetryStages: RetryStage[] = [
{ maxElapsed: 4, interval: 120 },
+4 -4
View File
@@ -6,16 +6,16 @@ declare module '*.vue' {
export default component
}
// 统一从 Wails 自动生成的强类型绑定派生 window.go.main.App 的类型声明,
// 统一从 Wails 自动生成的强类型绑定派生 window.go.app.App 的类型声明,
// 避免手写声明与后端契约漂移。后端方法签名变更后重新运行 `wails generate`
// 会更新 wailsjs/go/main/App.d.ts,此处类型随之更新;若前端引用了已删除或
// 会更新 wailsjs/go/app/App.d.ts,此处类型随之更新;若前端引用了已删除或
// 已重命名的方法,TypeScript 编译(vue-tsc)会直接报错。
import type * as GoApp from './wailsjs/go/main/App'
import type * as GoApp from './wailsjs/go/app/App'
declare global {
interface Window {
go: {
main: {
app: {
App: typeof GoApp
}
}