新增:文件系统导航面包屑
功能: - 新增 PathBreadcrumb 组件,支持路径快速跳转 - 新增 DropdownItem 通用下拉菜单组件 优化: - 版本升级流程优化(Pinia 状态管理、进度节流、完整下载验证) - 模块延迟初始化(数据库、文件系统按需启动) - API 数据格式统一(蛇形转驼峰) - CodeMirror 语言包按需动态加载 - Markdown 渲染增强(支持锚点跳转) 重构: - 迁移到 Pinia 状态管理(stores/config.ts、stores/theme.ts、stores/update.ts) - 简化 UpdatePanel、UpdateNotification、ThemeToggle 逻辑 - 优化表结构加载逻辑 清理: - 删除测试组件 index-simple.vue - 删除旧的 useTheme.ts
This commit is contained in:
@@ -4,6 +4,24 @@
|
||||
|
||||
import type { SystemInfo, CPU, Memory, Disk, File } from './types'
|
||||
|
||||
/**
|
||||
* 转换后端文件数据格式(蛇形 → 驼峰)
|
||||
* 后端返回 is_dir,前端使用 isDir
|
||||
*/
|
||||
function transformFile(file: any): File {
|
||||
return {
|
||||
...file,
|
||||
isDir: file.is_dir
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量转换文件列表
|
||||
*/
|
||||
function transformFileList(files: any[]): File[] {
|
||||
return files.map(transformFile)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统信息
|
||||
*/
|
||||
@@ -51,7 +69,9 @@ export async function listDir(path: string): Promise<File[]> {
|
||||
if (!window.go?.main?.App?.ListDir) {
|
||||
throw new Error('ListDir API 不可用')
|
||||
}
|
||||
return await window.go.main.App.ListDir(path)
|
||||
|
||||
const files = await window.go.main.App.ListDir(path)
|
||||
return transformFileList(files)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,14 +155,12 @@ export async function getEnvVars(): Promise<Record<string, string>> {
|
||||
* 列出 zip 文件内容
|
||||
*/
|
||||
export async function listZipContents(zipPath: string): Promise<File[]> {
|
||||
console.log('[API] listZipContents 调用:', zipPath)
|
||||
if (!window.go?.main?.App?.ListZipContents) {
|
||||
throw new Error('ListZipContents API 不可用')
|
||||
}
|
||||
try {
|
||||
const result = await window.go.main.App.ListZipContents(zipPath)
|
||||
console.log('[API] listZipContents 结果:', result?.length || 0, '个文件')
|
||||
return result
|
||||
return transformFileList(result)
|
||||
} catch (error) {
|
||||
console.error('[API] listZipContents 错误:', error)
|
||||
throw error
|
||||
@@ -153,13 +171,11 @@ export async function listZipContents(zipPath: string): Promise<File[]> {
|
||||
* 从 zip 文件中提取单个文件内容
|
||||
*/
|
||||
export async function extractFileFromZip(zipPath: string, filePath: string): Promise<string> {
|
||||
console.log('[API] extractFileFromZip 调用:', { zipPath, filePath })
|
||||
if (!window.go?.main?.App?.ExtractFileFromZip) {
|
||||
throw new Error('ExtractFileFromZip API 不可用')
|
||||
}
|
||||
try {
|
||||
const result = await window.go.main.App.ExtractFileFromZip(zipPath, filePath)
|
||||
console.log('[API] extractFileFromZip 成功, 内容长度:', result?.length || 0)
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('[API] extractFileFromZip 错误:', error)
|
||||
@@ -172,13 +188,11 @@ export async function extractFileFromZip(zipPath: string, filePath: string): Pro
|
||||
* 返回临时文件的完整路径,适用于图片等二进制文件
|
||||
*/
|
||||
export async function extractFileFromZipToTemp(zipPath: string, filePath: string): Promise<string> {
|
||||
console.log('[API] extractFileFromZipToTemp 调用:', { zipPath, filePath })
|
||||
if (!window.go?.main?.App?.ExtractFileFromZipToTemp) {
|
||||
throw new Error('ExtractFileFromZipToTemp API 不可用')
|
||||
}
|
||||
try {
|
||||
const result = await window.go.main.App.ExtractFileFromZipToTemp(zipPath, filePath)
|
||||
console.log('[API] extractFileFromZipToTemp 成功, 临时文件路径:', result)
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('[API] extractFileFromZipToTemp 错误:', error)
|
||||
@@ -190,14 +204,12 @@ export async function extractFileFromZipToTemp(zipPath: string, filePath: string
|
||||
* 获取 zip 文件中特定文件的信息
|
||||
*/
|
||||
export async function getZipFileInfo(zipPath: string, filePath: string): Promise<File> {
|
||||
console.log('[API] getZipFileInfo 调用:', { zipPath, filePath })
|
||||
if (!window.go?.main?.App?.GetZipFileInfo) {
|
||||
throw new Error('GetZipFileInfo API 不可用')
|
||||
}
|
||||
try {
|
||||
const result = await window.go.main.App.GetZipFileInfo(zipPath, filePath)
|
||||
console.log('[API] getZipFileInfo 结果:', result)
|
||||
return result
|
||||
return transformFile(result)
|
||||
} catch (error) {
|
||||
console.error('[API] getZipFileInfo 错误:', error)
|
||||
throw error
|
||||
@@ -208,13 +220,11 @@ export async function getZipFileInfo(zipPath: string, filePath: string): Promise
|
||||
* 使用系统默认程序打开文件或目录
|
||||
*/
|
||||
export async function openPath(path: string): Promise<void> {
|
||||
console.log('[API] openPath 调用:', path)
|
||||
if (!window.go?.main?.App?.OpenPath) {
|
||||
throw new Error('OpenPath API 不可用')
|
||||
}
|
||||
try {
|
||||
await window.go.main.App.OpenPath(path)
|
||||
console.log('[API] openPath 成功')
|
||||
} catch (error) {
|
||||
console.error('[API] openPath 错误:', error)
|
||||
throw error
|
||||
@@ -242,13 +252,11 @@ export async function resolveShortcut(lnkPath: string): Promise<{
|
||||
targetAccessible?: boolean
|
||||
targetInfo?: any
|
||||
}> {
|
||||
console.log('[API] resolveShortcut 调用:', lnkPath)
|
||||
if (!window.go?.main?.App?.ResolveShortcut) {
|
||||
throw new Error('ResolveShortcut API 不可用')
|
||||
}
|
||||
try {
|
||||
const result = await window.go.main.App.ResolveShortcut(lnkPath)
|
||||
console.log('[API] resolveShortcut 结果:', result)
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('[API] resolveShortcut 错误:', error)
|
||||
|
||||
Reference in New Issue
Block a user