feat: AI assistant panel, editor improvements, vite and package config

This commit is contained in:
2026-06-15 10:24:27 +08:00
parent 80b361813e
commit 33357650c7
10 changed files with 721 additions and 5 deletions

View File

@@ -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,
}
})