From 3e7b2beca1136a42700a7e1aebfe4c0fb2861a00 Mon Sep 17 00:00:00 2001 From: soryu Date: Sat, 15 Nov 2025 18:00:09 +0000 Subject: Initial commit --- frontend/src/stores/index.ts | 94 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 frontend/src/stores/index.ts (limited to 'frontend/src/stores/index.ts') diff --git a/frontend/src/stores/index.ts b/frontend/src/stores/index.ts new file mode 100644 index 0000000..58f461c --- /dev/null +++ b/frontend/src/stores/index.ts @@ -0,0 +1,94 @@ +import { atom } from 'nanostores' +import { ChatMessage, Choice } from '../types' + +// Authentication state +export const isLoggedInStore = atom(false) + +// VN Interface state +export const isStandbyStore = atom(false) +export const currentTimeStore = atom(new Date()) +export const weatherStore = atom('Tokyo - Sunny 22°C') +export const showChoicesStore = atom(false) +export const showSettingsModalStore = atom(false) +export const isVisibleStore = atom(false) +export const yenBalanceStore = atom(15000) + +// VN Page state +export const loadingStore = atom(true) +export const loadingCompleteStore = atom(false) +export const messagesStore = atom([ + { id: 'm1', role: 'assistant', content: 'A warm CRT glow fills the room. A figure turns towards you...' }, +]) +export const choicesStore = atom([ + { id: 'greet', label: '"Hello?"' }, + { id: 'who', label: '"Who are you?"' }, + { id: 'silence', label: '(Stay silent)' }, +]) +export const statusStore = atom('OFFLINE') +export const nameStore = atom('???') +export const backgroundStore = atom('/__gaogao__56242cbde8f18ac64522e410bad04e68_waifu2x_art_noise2.png') +export const locationStore = atom('Tokyo') +export const configModalOpenStore = atom(false) +export const skipIntroStore = atom( + (() => { + const saved = localStorage.getItem('skipIntro') + return saved === 'true' + })() +) + +// Actions +export const login = () => { + isLoggedInStore.set(true) +} + +export const logout = () => { + isLoggedInStore.set(false) +} + +export const toggleStandby = () => { + isStandbyStore.set(!isStandbyStore.get()) +} + +export const toggleShowChoices = () => { + showChoicesStore.set(!showChoicesStore.get()) +} + +export const updateTime = () => { + currentTimeStore.set(new Date()) +} + +export const addMessage = (message: ChatMessage) => { + messagesStore.set([...messagesStore.get(), message]) +} + +export const setChoices = (choices: Choice[]) => { + choicesStore.set(choices) +} + +export const clearChoices = () => { + choicesStore.set([]) +} + +export const setBackground = (src: string) => { + backgroundStore.set(src) +} + +export const setName = (name: string) => { + nameStore.set(name) +} + +export const setStatus = (status: string) => { + statusStore.set(status) +} + +export const setSkipIntro = (skip: boolean) => { + skipIntroStore.set(skip) + localStorage.setItem('skipIntro', skip.toString()) +} + +export const setLoadingComplete = (complete: boolean) => { + loadingCompleteStore.set(complete) + if (complete) { + loadingStore.set(false) + } +} \ No newline at end of file -- cgit v1.2.3