feat: 添加 Prompt 模板和 Prompt 商店支持 (#268)

* feat: 添加Prompt模板和Prompt商店支持

* feat: well done

---------

Co-authored-by: Redon <790348264@qq.com>
This commit is contained in:
Nothing1024
2023-03-11 16:09:52 +08:00
committed by GitHub
parent 514ab7e9e4
commit 00ade41a76
8 changed files with 525 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
export * from './app'
export * from './chat'
export * from './user'
export * from './prompt'
export * from './auth'

View File

@@ -0,0 +1,18 @@
import { ss } from '@/utils/storage'
const LOCAL_NAME = 'promptStore'
export type PromptList = []
export interface PromptStore {
promptList: PromptList
}
export function getLocalPromptList(): PromptStore {
const promptStore: PromptStore | undefined = ss.get(LOCAL_NAME)
return promptStore ?? { promptList: [] }
}
export function setLocalPromptList(promptStore: PromptStore): void {
ss.set(LOCAL_NAME, promptStore)
}

View File

@@ -0,0 +1,17 @@
import { defineStore } from 'pinia'
import type { PromptStore } from './helper'
import { getLocalPromptList, setLocalPromptList } from './helper'
export const usePromptStore = defineStore('prompt-store', {
state: (): PromptStore => getLocalPromptList(),
actions: {
updatePromptList(promptList: []) {
this.$patch({ promptList })
setLocalPromptList({ promptList })
},
getPromptList() {
return this.$state
},
},
})