优化:CSV编辑模式/PDF导出重构/收藏夹bug修复/移除useLocalStorage
- FileEditorPanel: CSV新增预览/编辑切换、PDF导出;提取openPrintWindow公共函数 - useFavorites: 修复find回调中fav变量遮蔽bug(f.path)、sort改为副本排序 - useFavoriteFiles/DeviceTest: 移除useLocalStorage抽象层,直接管理localStorage - system.ts: createDir/createFile签名改为(parent, name)两参数拼接 - useFileOperations: createNewFile移除无用content参数 - 清理OpenClaw相关Wails绑定
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useLocalStorage } from './useLocalStorage'
|
||||
|
||||
/**
|
||||
* 收藏夹 composable
|
||||
@@ -40,11 +39,27 @@ export function useFavoriteFiles(storageKey, options = {}) {
|
||||
onRemove = () => {},
|
||||
} = options
|
||||
|
||||
// 使用 localStorage composable 管理收藏列表
|
||||
const { storedValue: favoriteFiles, load, save } = useLocalStorage(
|
||||
storageKey,
|
||||
[]
|
||||
)
|
||||
// 收藏列表
|
||||
const favoriteFiles = ref([])
|
||||
|
||||
const load = () => {
|
||||
try {
|
||||
const stored = localStorage.getItem(storageKey)
|
||||
if (stored) {
|
||||
favoriteFiles.value = JSON.parse(stored)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载收藏列表失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const save = (data) => {
|
||||
try {
|
||||
localStorage.setItem(storageKey, JSON.stringify(data || favoriteFiles.value))
|
||||
} catch (e) {
|
||||
console.error('保存收藏列表失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件/目录是否已收藏
|
||||
@@ -70,6 +85,7 @@ export function useFavoriteFiles(storageKey, options = {}) {
|
||||
const timeB = b.addedAt || 0
|
||||
return timeB - timeA // 倒序:最新的在上面
|
||||
})
|
||||
save()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user