feat: AI assistant panel, editor improvements, vite and package config
This commit is contained in:
@@ -8,6 +8,10 @@ export const useEditorStore = defineStore('editor', () => {
|
||||
const startSceneId = ref('')
|
||||
const dirty = ref(false)
|
||||
const sourcePath = ref('/scenes/demo.json')
|
||||
const deepseekKey = ref(localStorage.getItem('deepseek_key') || '')
|
||||
const showAIPanel = ref(false)
|
||||
const aiResult = ref('')
|
||||
const aiSessionId = ref(localStorage.getItem('editor_ai_session') || '')
|
||||
|
||||
const selectedScene = computed(() => {
|
||||
if (!selectedNodeId.value) return null
|
||||
@@ -132,6 +136,22 @@ export const useEditorStore = defineStore('editor', () => {
|
||||
|
||||
function setSourcePath(p: string) { sourcePath.value = p; localStorage.setItem('editor_last_source', p) }
|
||||
|
||||
function setDeepseekKey(k: string) { deepseekKey.value = k; localStorage.setItem('deepseek_key', k) }
|
||||
|
||||
function ensureAISession() {
|
||||
if (!aiSessionId.value) {
|
||||
aiSessionId.value = crypto.randomUUID()
|
||||
localStorage.setItem('editor_ai_session', aiSessionId.value)
|
||||
}
|
||||
}
|
||||
|
||||
function newAISession() {
|
||||
aiSessionId.value = crypto.randomUUID()
|
||||
localStorage.setItem('editor_ai_session', aiSessionId.value)
|
||||
}
|
||||
|
||||
function setAIResult(r: string) { aiResult.value = r }
|
||||
|
||||
async function autoSave() {
|
||||
try {
|
||||
await fetch('/api/save', {
|
||||
@@ -144,8 +164,9 @@ export const useEditorStore = defineStore('editor', () => {
|
||||
|
||||
return {
|
||||
gameData, selectedNodeId, selectedScene, startSceneId, dirty, sourcePath,
|
||||
deepseekKey, showAIPanel, aiResult, aiSessionId,
|
||||
markDirty, loadJSON, exportJSON, addScene, deleteScene,
|
||||
updateScene, addChoice, updateChoice, deleteChoice, generateId,
|
||||
setSourcePath, autoSave,
|
||||
setSourcePath, setDeepseekKey, ensureAISession, newAISession, setAIResult, autoSave,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user