feat: 添加 Prompt 模板和 Prompt 商店支持 (#268)
* feat: 添加Prompt模板和Prompt商店支持 * feat: well done --------- Co-authored-by: Redon <790348264@qq.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export * from './app'
|
||||
export * from './chat'
|
||||
export * from './user'
|
||||
export * from './prompt'
|
||||
export * from './auth'
|
||||
|
||||
18
src/store/modules/prompt/helper.ts
Normal file
18
src/store/modules/prompt/helper.ts
Normal 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)
|
||||
}
|
||||
17
src/store/modules/prompt/index.ts
Normal file
17
src/store/modules/prompt/index.ts
Normal 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
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user