Skip to content

Commit 539b9a0

Browse files
committed
feat: export conversations (#228)
1 parent bc31496 commit 539b9a0

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/_locales/en/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@
102102
"Keep Conversation Window in Background": "Keep conversation window in background, so that you can use shortcut keys to call it up in any program",
103103
"Max Response Token Length": "Max Response Token Length",
104104
"Max Conversation Length": "Max Conversation Length",
105-
"Always pin the floating window": "Always pin the floating window"
105+
"Always pin the floating window": "Always pin the floating window",
106+
"Export": "Export"
106107
}

src/_locales/zh-hans/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@
102102
"Keep Conversation Window in Background": "保持对话窗口在后台, 以便在任何程序中使用快捷键呼出",
103103
"Max Response Token Length": "响应的最大token长度",
104104
"Max Conversation Length": "对话处理的最大长度",
105-
"Always pin the floating window": "总是固定浮动窗口"
105+
"Always pin the floating window": "总是固定浮动窗口",
106+
"Export": "导出"
106107
}

src/_locales/zh-hant/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@
102102
"Keep Conversation Window in Background": "保持對話窗口在後臺, 以便在任何程序中使用快捷鍵呼出",
103103
"Max Response Token Length": "響應的最大token長度",
104104
"Max Conversation Length": "對話處理的最大長度",
105-
"Always pin the floating window": "總是固定浮動視窗"
105+
"Always pin the floating window": "總是固定浮動視窗",
106+
"Export": "導出"
106107
}

src/pages/IndependentPanel/App.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import ConversationCard from '../../components/ConversationCard'
1515
import DeleteButton from '../../components/DeleteButton'
1616
import { openUrl } from '../../utils/index.mjs'
1717
import Browser from 'webextension-polyfill'
18+
import FileSaver from 'file-saver'
1819

1920
function App() {
2021
const { t } = useTranslation()
@@ -81,6 +82,12 @@ function App() {
8182
await setSessionIdSafe(session.sessionId)
8283
}
8384

85+
const exportConversations = async () => {
86+
const sessions = await getSessions()
87+
const blob = new Blob([JSON.stringify(sessions, null, 2)], { type: 'text/json;charset=utf-8' })
88+
FileSaver.saveAs(blob, 'conversations.json')
89+
}
90+
8491
const clearConversations = async () => {
8592
const sessions = await resetSessions()
8693
setSessions(sessions)
@@ -98,6 +105,9 @@ function App() {
98105
<button className="normal-button" onClick={createNewChat}>
99106
{t('New Chat')}
100107
</button>
108+
<button className="normal-button" onClick={exportConversations}>
109+
{t('Export')}
110+
</button>
101111
</div>
102112
<hr />
103113
<div className="chat-list">

0 commit comments

Comments
 (0)