Skip to content

Commit 81a9c97

Browse files
authored
fix: store circular reference (#470)
Signed-off-by: Bob Du <[email protected]>
1 parent 8052858 commit 81a9c97

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

src/store/helper.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { createPinia } from 'pinia'
2+
3+
export const store = createPinia()

src/store/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { App } from 'vue'
2-
import { createPinia } from 'pinia'
3-
4-
export const store = createPinia()
2+
import { store } from './helper'
53

64
export function setupStore(app: App) {
75
app.use(store)

src/store/modules/app/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineStore } from 'pinia'
22
import type { AppState, Language, Theme } from './helper'
33
import { getLocalSetting, setLocalSetting } from './helper'
4-
import { store } from '@/store'
4+
import { store } from '@/store/helper'
55

66
export const useAppStore = defineStore('app-store', {
77
state: (): AppState => getLocalSetting(),

src/store/modules/auth/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { defineStore } from 'pinia'
22
import jwt_decode from 'jwt-decode'
33
import type { UserInfo } from '../user/helper'
4+
import { useChatStore } from '../chat'
5+
import { useUserStore } from '../user'
46
import { getToken, removeToken, setToken } from './helper'
5-
import { store, useChatStore, useUserStore } from '@/store'
7+
import { store } from '@/store/helper'
68
import { fetchLogout, fetchSession } from '@/api'
79
import { UserConfig } from '@/components/common/Setting/model'
810

src/store/modules/chat/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineStore } from 'pinia'
2+
import { useUserStore } from '../user'
23
import { getLocalState, setLocalState } from './helper'
3-
import { useUserStore } from '@/store'
44
import { router } from '@/router'
55
import {
66
fetchClearChat,

src/store/modules/user/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineStore } from 'pinia'
2-
import { fetchResetAdvanced, fetchUpdateAdvanced, fetchUpdateUserAmt, fetchUpdateUserInfo, fetchUserAmt } from '../../../api/'
32
import type { UserInfo, UserState } from './helper'
43
import { defaultSetting, getLocalState, setLocalState } from './helper'
4+
import { fetchResetAdvanced, fetchUpdateAdvanced, fetchUpdateUserAmt, fetchUpdateUserInfo, fetchUserAmt } from '@/api'
55

66
export const useUserStore = defineStore('user-store', {
77
state: (): UserState => getLocalState(),

0 commit comments

Comments
 (0)