|
@ -137,7 +137,7 @@ export const useModelStore = defineStore('modelStore', () => { |
|
|
const res = await fetchGet(`${aiUrl}/ai/tags`) |
|
|
const res = await fetchGet(`${aiUrl}/ai/tags`) |
|
|
//console.log(res)
|
|
|
//console.log(res)
|
|
|
if (res.ok) { |
|
|
if (res.ok) { |
|
|
resetData(res) |
|
|
await resetData(res) |
|
|
} |
|
|
} |
|
|
return modelList.value |
|
|
return modelList.value |
|
|
} |
|
|
} |
|
@ -147,7 +147,10 @@ export const useModelStore = defineStore('modelStore', () => { |
|
|
if (data && data.length > 0) { |
|
|
if (data && data.length > 0) { |
|
|
await db.clear("modelslist") |
|
|
await db.clear("modelslist") |
|
|
await db.addAll("modelslist", data) |
|
|
await db.addAll("modelslist", data) |
|
|
|
|
|
nextTick(() => { |
|
|
modelList.value = data |
|
|
modelList.value = data |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
async function refreshOllama() { |
|
|
async function refreshOllama() { |
|
@ -177,6 +180,7 @@ export const useModelStore = defineStore('modelStore', () => { |
|
|
} |
|
|
} |
|
|
async function setCurrentModel(action: string, model?: string) { |
|
|
async function setCurrentModel(action: string, model?: string) { |
|
|
await db.modify("modelslist", "action", action, { isdef: 0 }) |
|
|
await db.modify("modelslist", "action", action, { isdef: 0 }) |
|
|
|
|
|
//console.log(model)
|
|
|
if (model !== "") { |
|
|
if (model !== "") { |
|
|
return await db.modify("modelslist", "model", model, { isdef: 1 }) |
|
|
return await db.modify("modelslist", "model", model, { isdef: 1 }) |
|
|
} else { |
|
|
} else { |
|
@ -204,6 +208,16 @@ export const useModelStore = defineStore('modelStore', () => { |
|
|
async function deleteModelList(data: any) { |
|
|
async function deleteModelList(data: any) { |
|
|
//console.log(data)
|
|
|
//console.log(data)
|
|
|
if (!data || !data.model) return |
|
|
if (!data || !data.model) return |
|
|
|
|
|
const postData = { |
|
|
|
|
|
method: "POST", |
|
|
|
|
|
body: JSON.stringify(data), |
|
|
|
|
|
}; |
|
|
|
|
|
const delUrl = aiUrl + "/ai/delete"; |
|
|
|
|
|
const completion = await fetch(delUrl, postData); |
|
|
|
|
|
if (completion.status === 404) { |
|
|
|
|
|
return completion.statusText; |
|
|
|
|
|
} |
|
|
|
|
|
if (completion.status === 200) { |
|
|
modelList.value.forEach((d: any, index: number) => { |
|
|
modelList.value.forEach((d: any, index: number) => { |
|
|
if (d.model == data.model) { |
|
|
if (d.model == data.model) { |
|
|
modelList.value.splice(index, 1); |
|
|
modelList.value.splice(index, 1); |
|
@ -213,6 +227,8 @@ export const useModelStore = defineStore('modelStore', () => { |
|
|
if (data.isdef * 1 == 1) { |
|
|
if (data.isdef * 1 == 1) { |
|
|
await setCurrentModel(data.action, "") |
|
|
await setCurrentModel(data.action, "") |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//await db.delete("modelslist", data.id)
|
|
|
//await db.delete("modelslist", data.id)
|
|
|
//await getModelList()
|
|
|
//await getModelList()
|
|
|