@@ -6,9 +6,7 @@ import { relaunch } from '@tauri-apps/api/process'
6
6
import type { Language , Theme } from ' @/store/modules/app/helper'
7
7
import { SvgIcon } from ' @/components/common'
8
8
import { useAppStore } from ' @/store'
9
- import { getCurrentDate } from ' @/utils/functions'
10
9
import { useBasicLayout } from ' @/hooks/useBasicLayout'
11
- import { t } from ' @/locales'
12
10
13
11
const appStore = useAppStore ()
14
12
@@ -51,55 +49,11 @@ const languageOptions: { label: string; key: Language; value: Language }[] = [
51
49
{ label: ' English' , key: ' en-US' , value: ' en-US' },
52
50
]
53
51
54
- function exportData(): void {
55
- const date = getCurrentDate ()
56
- const data: string = localStorage .getItem (' chatStorage' ) || ' {}'
57
- const jsonString: string = JSON .stringify (JSON .parse (data ), null , 2 )
58
- const blob: Blob = new Blob ([jsonString ], { type: ' application/json' })
59
- const url: string = URL .createObjectURL (blob )
60
- const link: HTMLAnchorElement = document .createElement (' a' )
61
- link .href = url
62
- link .download = ` chat-store_${date }.json `
63
- document .body .appendChild (link )
64
- link .click ()
65
- document .body .removeChild (link )
66
- }
67
-
68
- function importData(event : Event ): void {
69
- const target = event .target as HTMLInputElement
70
- if (! target || ! target .files )
71
- return
72
-
73
- const file: File = target .files [0 ]
74
- if (! file )
75
- return
76
-
77
- const reader: FileReader = new FileReader ()
78
- reader .onload = () => {
79
- try {
80
- const data = JSON .parse (reader .result as string )
81
- localStorage .setItem (' chatStorage' , JSON .stringify (data ))
82
- ms .success (t (' common.success' ))
83
- location .reload ()
84
- }
85
- catch (error ) {
86
- ms .error (t (' common.invalidFileFormat' ))
87
- }
88
- }
89
- reader .readAsText (file )
90
- }
91
-
92
52
function clearData(): void {
93
53
localStorage .removeItem (' chatStorage' )
94
54
location .reload ()
95
55
}
96
56
97
- function handleImportButtonClick(): void {
98
- const fileInput = document .getElementById (' fileInput' ) as HTMLElement
99
- if (fileInput )
100
- fileInput .click ()
101
- }
102
-
103
57
const updateLoading = ref <boolean >(false )
104
58
105
59
async function checkAppUpdate() {
@@ -133,21 +87,6 @@ async function checkAppUpdate() {
133
87
<span class =" flex-shrink-0 w-[100px]" >{{ $t('setting.chatHistory') }}</span >
134
88
135
89
<div class =" flex flex-wrap items-center gap-4" >
136
- <NButton size =" small" @click =" exportData" >
137
- <template #icon >
138
- <SvgIcon icon =" ri:download-2-fill" />
139
- </template >
140
- {{ $t('common.export') }}
141
- </NButton >
142
-
143
- <input id =" fileInput" type =" file" style =" display :none " @change =" importData" >
144
- <NButton size =" small" @click =" handleImportButtonClick" >
145
- <template #icon >
146
- <SvgIcon icon =" ri:upload-2-fill" />
147
- </template >
148
- {{ $t('common.import') }}
149
- </NButton >
150
-
151
90
<NPopconfirm placement =" bottom" @positive-click =" clearData" >
152
91
<template #trigger >
153
92
<NButton size =" small" >
0 commit comments