Browse Source

change db

master
godo 7 months ago
parent
commit
e3b2b67812
  1. 4
      frontend/src/components/window/IframeFile.vue
  2. 5
      frontend/src/hook/useAi.ts
  3. 5
      frontend/src/stores/db.ts

4
frontend/src/components/window/IframeFile.vue

@ -199,9 +199,9 @@ const eventHandler = async (e: MessageEvent) => {
if(eventData.category){ if(eventData.category){
postData.category = eventData.category postData.category = eventData.category
} }
//console.log(postData,eventData.action)
// AI // AI
const res = await askAi(postData, eventData.action); const res:any = await askAi(postData, eventData.action);
storeRef.value?.contentWindow?.postMessage( storeRef.value?.contentWindow?.postMessage(
{ {
type: 'aiReciver', type: 'aiReciver',

5
frontend/src/hook/useAi.ts

@ -2,6 +2,7 @@ import { getSystemConfig, fetchPost } from "@/system/config";
import { useAssistantStore } from '@/stores/assistant'; import { useAssistantStore } from '@/stores/assistant';
import { useModelStore } from "@/stores/model"; import { useModelStore } from "@/stores/model";
export async function askAi(question: any, action: string) { export async function askAi(question: any, action: string) {
try {
const assistantStore = useAssistantStore(); const assistantStore = useAssistantStore();
const modelStore = useModelStore(); const modelStore = useModelStore();
const config = getSystemConfig(); const config = getSystemConfig();
@ -41,5 +42,9 @@ export async function askAi(question: any, action: string) {
} }
const data = await complain.json() const data = await complain.json()
return data.choices[0].message.content return data.choices[0].message.content
} catch (error) {
return '请求失败'+error
}
} }

5
frontend/src/stores/db.ts

@ -110,9 +110,14 @@ export const db = {
}, },
async get(tableName: ChatTable, whereObj: any) { async get(tableName: ChatTable, whereObj: any) {
//console.log(whereObj) //console.log(whereObj)
try {
const data = await dbInit[tableName].where(whereObj).first() const data = await dbInit[tableName].where(whereObj).first()
//console.log(data) //console.log(data)
return data ? data : false return data ? data : false
} catch (error) {
return false
}
}, },
async rows(tableName: ChatTable, whereObj: any) { async rows(tableName: ChatTable, whereObj: any) {
return dbInit[tableName].where(whereObj).toArray() return dbInit[tableName].where(whereObj).toArray()

Loading…
Cancel
Save