init commit

This commit is contained in:
wizardchen
2025-08-05 15:08:07 +08:00
commit 56eb2bce33
282 changed files with 49077 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
import { ref, computed, reactive } from "vue";
import { defineStore } from "pinia";
export const knowledgeStore = defineStore("knowledge", {
state: () => ({
cardList: ref([]),
total: ref(0),
}),
actions: {},
});
+46
View File
@@ -0,0 +1,46 @@
import { ref, computed, reactive } from 'vue'
import { defineStore } from 'pinia';
export const useMenuStore = defineStore('menuStore', {
state: () => ({
menuArr: reactive([
{ title: '知识库', icon: 'zhishiku', path: 'knowledgeBase' },
{
title: '对话',
icon: 'prefixIcon',
path: 'creatChat',
childrenPath: 'chat',
children: reactive<object[]>([]),
},
{ title: '系统设置', icon: 'setting', path: 'settings' }
]),
isFirstSession: false,
firstQuery: ''
}
),
actions: {
updatemenuArr(obj: any) {
this.menuArr[1].children?.push(obj);
},
updataMenuChildren(item: object) {
this.menuArr[1].children?.unshift(item)
},
updatasessionTitle(session_id: string, title: string) {
this.menuArr[1].children?.forEach(item => {
if (item.id == session_id) {
item.title = title;
item.isNoTitle = false;
}
});
},
changeIsFirstSession(payload: boolean) {
this.isFirstSession = payload;
},
changeFirstQuery(payload: string) {
this.firstQuery = payload;
}
}
});
+51
View File
@@ -0,0 +1,51 @@
import { defineStore } from "pinia";
// 定义设置接口
interface Settings {
endpoint: string;
apiKey: string;
knowledgeBaseId: string;
}
// 默认设置
const defaultSettings: Settings = {
endpoint: import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080",
apiKey: "",
knowledgeBaseId: "",
};
export const useSettingsStore = defineStore("settings", {
state: () => ({
// 从本地存储加载设置,如果没有则使用默认设置
settings: JSON.parse(localStorage.getItem("WeKnora_settings") || JSON.stringify(defaultSettings)),
}),
actions: {
// 保存设置
saveSettings(settings: Settings) {
this.settings = { ...settings };
// 保存到localStorage
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
},
// 获取设置
getSettings(): Settings {
return this.settings;
},
// 获取API端点
getEndpoint(): string {
return this.settings.endpoint || defaultSettings.endpoint;
},
// 获取API Key
getApiKey(): string {
return this.settings.apiKey;
},
// 获取知识库ID
getKnowledgeBaseId(): string {
return this.settings.knowledgeBaseId;
},
},
});