1
1
<script setup lang="ts">
2
- const { isThinking, sessionDataList } = storeToRefs (useSessionStore ())
2
+ import { sep } from ' @tauri-apps/api/path'
3
+ import type { SessionData } from ' @/types'
4
+
5
+ const { isThinking, sessionDataList, currentSession } = storeToRefs (
6
+ useSessionStore ()
7
+ )
8
+ const { currentRole } = storeToRefs (useRoleStore ())
3
9
4
10
const disabled = computed (
5
11
() => isThinking .value || ! sessionDataList .value .length
6
12
)
7
13
8
- const handleSelect = (value : string ) => {
14
+ const getRoleName = (item : SessionData ) => {
15
+ const name = item .is_ask ? ' 你' : currentRole .value ?.name
16
+
17
+ return name + ' :'
18
+ }
19
+
20
+ const getMDContent = async (item : SessionData ) => {
21
+ let content = ' '
22
+
23
+ const { message, message_type } = item
24
+
25
+ if (currentSession .value ?.type === ' text' ) {
26
+ content = message .content
27
+ } else {
28
+ if (message_type === ' text' ) {
29
+ content = message .content .prompt
30
+ } else {
31
+ for (const image of message .content ) {
32
+ const imageName = await saveImageFromFile (image .file , true )
33
+
34
+ content += ` \n `
35
+ }
36
+ }
37
+ }
38
+
39
+ return getRoleName (item ) + content + ' \n\n '
40
+ }
41
+
42
+ const handleSelect = async (value : string ) => {
9
43
if (value === ' image' ) {
10
44
saveImage (' session-list' )
45
+ } else if (value === ' markdown' ) {
46
+ let mdResult = ' '
47
+
48
+ for await (const item of sessionDataList .value ) {
49
+ mdResult += await getMDContent (item )
50
+ }
51
+
52
+ saveMarkdown (mdResult )
11
53
}
12
54
}
13
55
</script >
@@ -25,7 +67,7 @@ const handleSelect = (value: string) => {
25
67
</a-button >
26
68
<template #content >
27
69
<a-doption value =" image" >导出图片</a-doption >
28
- <!-- < a-doption value="markdown">导出 Markdown</a-doption> -- >
70
+ <a-doption value =" markdown" > 导出 Markdown </a-doption >
29
71
</template >
30
72
</a-dropdown >
31
73
</template >
0 commit comments