Skip to content

Commit efa3b8d

Browse files
committed
fix(stage-ui,stage-web,stage-tamagotchi): should not use useI18n in non-setup hook
1 parent c19ead9 commit efa3b8d

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

apps/stage-tamagotchi/src/renderer/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { defineInvoke, defineInvokeHandler } from '@moeru/eventa'
33
import { useDisplayModelsStore } from '@proj-airi/stage-ui/stores/display-models'
4+
import { useAiriCardStore } from '@proj-airi/stage-ui/stores/modules/airi-card'
45
import { useOnboardingStore } from '@proj-airi/stage-ui/stores/onboarding'
56
import { installChatContextBridge } from '@proj-airi/stage-ui/stores/plugins/chat-context-bridge'
67
import { useSettings } from '@proj-airi/stage-ui/stores/settings'
@@ -22,6 +23,7 @@ const { language, themeColorsHue, themeColorsHueDynamic } = storeToRefs(settings
2223
const onboardingStore = useOnboardingStore()
2324
const router = useRouter()
2425
const route = useRoute()
26+
const cardStore = useAiriCardStore()
2527
let disposeChatBridge: (() => void) | undefined
2628
2729
watch(language, () => {
@@ -35,6 +37,7 @@ onMounted(() => updateThemeColor())
3537
3638
// FIXME: store settings to file
3739
onMounted(async () => {
40+
cardStore.initialize()
3841
onboardingStore.initializeSetupCheck()
3942
4043
await displayModelsStore.loadDisplayModelsFromIndexedDB()

apps/stage-web/src/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { OnboardingDialog, ToasterRoot } from '@proj-airi/stage-ui/components'
33
import { useDisplayModelsStore } from '@proj-airi/stage-ui/stores/display-models'
4+
import { useAiriCardStore } from '@proj-airi/stage-ui/stores/modules/airi-card'
45
import { useOnboardingStore } from '@proj-airi/stage-ui/stores/onboarding'
56
import { installChatContextBridge } from '@proj-airi/stage-ui/stores/plugins/chat-context-bridge'
67
import { useSettings } from '@proj-airi/stage-ui/stores/settings'
@@ -24,6 +25,7 @@ const settings = storeToRefs(settingsStore)
2425
const onboardingStore = useOnboardingStore()
2526
const { shouldShowSetup } = storeToRefs(onboardingStore)
2627
const { isDark } = useTheme()
28+
const cardStore = useAiriCardStore()
2729
let disposeChatBridge: (() => void) | undefined
2830
2931
const primaryColor = computed(() => {
@@ -62,6 +64,8 @@ watch(settings.themeColorsHueDynamic, () => {
6264
6365
// Initialize first-time setup check when app mounts
6466
onMounted(async () => {
67+
cardStore.initialize()
68+
6569
onboardingStore.initializeSetupCheck()
6670
const bridge = installChatContextBridge()
6771
disposeChatBridge = bridge.dispose

packages/stage-ui/src/stores/modules/airi-card.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export interface AiriCard extends Card {
5454
}
5555

5656
export const useAiriCardStore = defineStore('airi-card', () => {
57+
const { t } = useI18n()
58+
5759
const [cards, resetCards] = createResettableLocalStorage<Map<string, AiriCard>>('airi-cards', new Map())
5860
const [activeCardId, resetActiveCardId] = createResettableLocalStorage('airi-card-active-id', 'default')
5961

@@ -179,24 +181,7 @@ export const useAiriCardStore = defineStore('airi-card', () => {
179181
}
180182
}
181183

182-
// onMounted(() => {
183-
// if (cards.value.has('default'))
184-
// return
185-
// const { t } = useI18n()
186-
// cards.value.set('default', newAiriCard({
187-
// name: 'ReLU',
188-
// version: '1.0.0',
189-
// // description: 'ReLU is a simple and effective activation function that is used in many neural networks.',
190-
// description: SystemPromptV2(
191-
// t('base.prompt.prefix'),
192-
// t('base.prompt.suffix'),
193-
// ).content,
194-
// }))
195-
// })
196-
197-
// Lilia: onMounted initialisation cause default card system prompt initialisation failure
198-
function ensureDefaultCard() {
199-
const { t } = useI18n()
184+
function initialize() {
200185
if (cards.value.has('default'))
201186
return
202187
cards.value.set('default', newAiriCard({
@@ -210,7 +195,6 @@ export const useAiriCardStore = defineStore('airi-card', () => {
210195
if (!activeCardId.value)
211196
activeCardId.value = 'default'
212197
}
213-
ensureDefaultCard()
214198

215199
watch(activeCard, (newCard: AiriCard | undefined) => {
216200
if (!newCard)
@@ -240,6 +224,7 @@ export const useAiriCardStore = defineStore('airi-card', () => {
240224
removeCard,
241225
getCard,
242226
resetState,
227+
initialize,
243228

244229
currentModels: computed(() => {
245230
return {

0 commit comments

Comments
 (0)