MCPcopy Create free account
hub / github.com/experdot/pointer / DataManagement

Function DataManagement

src/renderer/src/components/settings/DataManagement.tsx:46–787  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44const { Text, Paragraph } = Typography
45
46export default function DataManagement() {
47 const { importSettings, exportSettings } = useSettingsStore()
48 const { pages, folders, importPages, importFolders, clearAllPages, clearChatPages } = usePagesStore()
49 const { items: favoriteItems, folders: favoriteFolders, importFavorites, importFavoriteFolders, clearAllFavorites } = useFavoritesStore()
50 const [importing, setImporting] = useState(false)
51 const [selectiveImportModal, setSelectiveImportModal] = useState(false)
52 const [selectableChatItems, setSelectableChatItems] = useState<SelectableChatItem[]>([])
53 const [selectedChatIds, setSelectedChatIds] = useState<string[]>([])
54 const [customFolderName, setCustomFolderName] = useState('')
55 const { modal, message } = App.useApp()
56
57 // 生成精确到秒的时间戳用于文件名
58 const getTimestamp = () => {
59 const now = new Date()
60 return now.toISOString().replace(/[:.]/g, '-').slice(0, -5) // 移除毫秒和Z,替换冒号和点号
61 }
62
63 // 导出所有数据
64 const handleExportAll = () => {
65 try {
66 const settings = exportSettings()
67 const allData = {
68 type: 'all-data',
69 settings,
70 pages,
71 folders,
72 favorites: {
73 items: favoriteItems,
74 folders: favoriteFolders
75 },
76 version: '1.0.0',
77 exportTime: Date.now()
78 }
79 const blob = new Blob([JSON.stringify(allData, null, 2)], { type: 'application/json' })
80 const url = URL.createObjectURL(blob)
81 const link = document.createElement('a')
82
83 link.href = url
84 link.download = `ai-chat-all-data-${getTimestamp()}.json`
85 document.body.appendChild(link)
86 link.click()
87 document.body.removeChild(link)
88 URL.revokeObjectURL(url)
89 } catch (error) {
90 message.error('导出失败')
91 }
92 }
93
94 // 单独导出设置
95 const handleExportSettings = () => {
96 try {
97 const settings = exportSettings()
98 const settingsData = {
99 type: 'settings-only',
100 settings,
101 version: '1.0.0',
102 exportTime: Date.now()
103 }

Callers

nothing calls this directly

Calls 2

getCurrentDataSizeFunction · 0.85
handleSelectAllFunction · 0.70

Tested by

no test coverage detected