重构: 应用代码移入 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:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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>>({})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Vendored
+4
-4
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user