@@ -81,7 +81,13 @@ <h2 class="font-bold mb-4 ml-4">Conversations</h2>
8181 < path d ="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z "/>
8282 </ svg >
8383 </ button >
84-
84+ < button v-if ="messages.length > 0 " class ="btn mr-1 " @click ="downloadConv(viewingConvId) " :disabled ="isGenerating ">
85+ <!-- download conversation button -->
86+ < svg xmlns ="http://www.w3.org/2000/svg " width ="16 " height ="16 " fill ="currentColor " class ="bi bi-download " viewBox ="0 0 16 16 ">
87+ < path d ="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5 "/>
88+ < path d ="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z "/>
89+ </ svg >
90+ </ button >
8591 < button class ="btn " @click ="showConfigDialog = true " :disabled ="isGenerating ">
8692 <!-- edit config button -->
8793 < svg xmlns ="http://www.w3.org/2000/svg " width ="16 " height ="16 " fill ="currentColor " class ="bi bi-gear " viewBox ="0 0 16 16 ">
@@ -526,6 +532,23 @@ <h3 class="text-lg font-bold mb-6">Settings</h3>
526532 this . fetchMessages ( ) ;
527533 }
528534 } ,
535+ downloadConv ( convId ) {
536+ const conversation = StorageUtils . getOneConversation ( convId ) ;
537+ if ( ! conversation ) {
538+ alert ( 'Conversation not found.' ) ;
539+ return ;
540+ }
541+ const conversationJson = JSON . stringify ( conversation , null , 2 ) ;
542+ const blob = new Blob ( [ conversationJson ] , { type : 'application/json' } ) ;
543+ const url = URL . createObjectURL ( blob ) ;
544+ const a = document . createElement ( 'a' ) ;
545+ a . href = url ;
546+ a . download = `conversation_${ convId } .json` ;
547+ document . body . appendChild ( a ) ;
548+ a . click ( ) ;
549+ document . body . removeChild ( a ) ;
550+ URL . revokeObjectURL ( url ) ;
551+ } ,
529552 async sendMessage ( ) {
530553 if ( ! this . inputMsg ) return ;
531554 const currConvId = this . viewingConvId ;
0 commit comments