Skip to content

Commit

Permalink
1.应用启动后,记忆对话列表
Browse files Browse the repository at this point in the history
  • Loading branch information
pwh-pwh committed Jul 31, 2024
1 parent e4d7fed commit 6ba7fb1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
11 changes: 9 additions & 2 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
import Chat from "./components/Chat.vue";
import Toast from "primevue/toast";
import {useToast} from "primevue/usetoast";
import {onMounted, provide, ref} from "vue";
import {onMounted, provide, reactive, ref} from "vue";
import {GetStatus} from "../wailsjs/go/main/App";
import {WindowGetPosition, WindowSetPosition, WindowSetSize} from "../wailsjs/runtime";
import {types} from "../wailsjs/go/models";
import Message = types.Message;
const toast = useToast()
const isShrink = ref(false)
const helpMsg = ref('/help: 显示帮助信息\n/clear: 清除历史信息\n/loadconf: 重新加载配置文件\n/opconf: 打开配置文件夹\n' +
'/quit: 退出应用')
const msgList = reactive<Message[]>([{content: '欢迎使用Ai-Gui,用法介绍如下', userType: 'user', id: 'tool'},
{content: helpMsg.value, userType: 'assistant', id: 'tool'}])
const showInfoToast = (msg:string,summary:string = 'info',duration:number = 3000) => {
toast.add({ severity: 'info', summary: summary, detail: msg, life: duration });
}
Expand Down Expand Up @@ -40,7 +47,7 @@ onMounted(() => {
<template>
<div v-if="!isShrink" class="border-round-3xl p-3 h-full">
<Toast />
<Chat />
<Chat :msgList="msgList" :helpMsg="helpMsg"/>
</div>
<div v-else class="absolute top-0 left-0 pointer-events-auto overflow-hidden" @click="enlarge"
style="--wails-draggable:drag">
Expand Down
14 changes: 8 additions & 6 deletions frontend/src/components/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import {DoChat, GetStatus, OpenConfigFolder, ReloadConf} from "../../wailsjs/go/
import {types} from "../../wailsjs/go/models";
import Message = types.Message;
const {
msgList,helpMsg
} = defineProps<{
msgList: Message[],
helpMsg: string
}>()
const inputMsg = ref('')
const helpMsg = ref('/help: 显示帮助信息\n/clear: 清除历史信息\n/loadconf: 重新加载配置文件\n/opconf: 打开配置文件夹\n' +
'/quit: 退出应用')
const msgList = reactive<Message[]>([{content: '欢迎使用Ai-Gui,用法介绍如下', userType: 'user', id: 'tool'},
{content: helpMsg.value, userType: 'assistant', id: 'tool'}])
const doChat = () => {
if (!dispatchMsg(inputMsg.value)) {
inputMsg.value = ''
Expand All @@ -38,7 +40,7 @@ const dispatchMsg = (msg: string): boolean => {
return false
case '/help':
msgList.push({content: inputMsg.value, userType: 'user', id: 'tool'})
msgList.push({content: helpMsg.value, userType: 'assistant', id: 'tool'})
msgList.push({content: helpMsg, userType: 'assistant', id: 'tool'})
return false
case '/loadconf':
msgList.push({content: inputMsg.value, userType: 'user', id: 'tool'})
Expand Down
Binary file added images/winicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### bug

1. 应用启动后,记忆对话列表 ☑️

### features

Expand Down

0 comments on commit 6ba7fb1

Please sign in to comment.