Skip to content

Commit 426a27d

Browse files
author
jianghonglu.neo
committed
feat: remove import and export
1 parent 708d821 commit 426a27d

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

src/components/common/Setting/General.vue

-61
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import { relaunch } from '@tauri-apps/api/process'
66
import type { Language, Theme } from '@/store/modules/app/helper'
77
import { SvgIcon } from '@/components/common'
88
import { useAppStore } from '@/store'
9-
import { getCurrentDate } from '@/utils/functions'
109
import { useBasicLayout } from '@/hooks/useBasicLayout'
11-
import { t } from '@/locales'
1210
1311
const appStore = useAppStore()
1412
@@ -51,55 +49,11 @@ const languageOptions: { label: string; key: Language; value: Language }[] = [
5149
{ label: 'English', key: 'en-US', value: 'en-US' },
5250
]
5351
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-
9252
function clearData(): void {
9353
localStorage.removeItem('chatStorage')
9454
location.reload()
9555
}
9656
97-
function handleImportButtonClick(): void {
98-
const fileInput = document.getElementById('fileInput') as HTMLElement
99-
if (fileInput)
100-
fileInput.click()
101-
}
102-
10357
const updateLoading = ref<boolean>(false)
10458
10559
async function checkAppUpdate() {
@@ -133,21 +87,6 @@ async function checkAppUpdate() {
13387
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.chatHistory') }}</span>
13488

13589
<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-
15190
<NPopconfirm placement="bottom" @positive-click="clearData">
15291
<template #trigger>
15392
<NButton size="small">

0 commit comments

Comments
 (0)