mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-15 05:33:44 +08:00
optimize the vue component communication, replace event listening with share data
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
// 导入mitt包
|
||||
import mitt from 'mitt'
|
||||
// 创建EventBus实例对象
|
||||
const bus = mitt()
|
||||
// 共享出eventbus的实例对象
|
||||
export default bus
|
||||
@@ -8,6 +8,8 @@ export const useSharedStore = defineStore('shared', {
|
||||
chatStream: Storage.get("chat_stream",true),
|
||||
socket: WebSocket,
|
||||
messageHandlers:{},
|
||||
mobileTheme: Storage.get("mobile_theme", "light"),
|
||||
adminTheme: Storage.get("admin_theme", "light"),
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
@@ -51,6 +53,17 @@ export const useSharedStore = defineStore('shared', {
|
||||
this.setMessageHandler(callback)
|
||||
}, 1000)
|
||||
}
|
||||
},
|
||||
removeMessageHandler(key) {
|
||||
delete this.messageHandlers[key]
|
||||
},
|
||||
setMobileTheme(theme) {
|
||||
this.mobileTheme = theme
|
||||
Storage.set("mobile_theme", theme)
|
||||
},
|
||||
setAdminTheme(theme) {
|
||||
this.adminTheme = theme
|
||||
Storage.set("admin_theme", theme)
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,25 +7,6 @@
|
||||
|
||||
import Storage from "good-storage";
|
||||
|
||||
const MOBILE_THEME = process.env.VUE_APP_KEY_PREFIX + "MOBILE_THEME"
|
||||
const ADMIN_THEME = process.env.VUE_APP_KEY_PREFIX + "ADMIN_THEME"
|
||||
|
||||
export function getMobileTheme() {
|
||||
return Storage.get(MOBILE_THEME) ? Storage.get(MOBILE_THEME) : 'light'
|
||||
}
|
||||
|
||||
export function setMobileTheme(theme) {
|
||||
Storage.set(MOBILE_THEME, theme)
|
||||
}
|
||||
|
||||
export function getAdminTheme() {
|
||||
return Storage.get(ADMIN_THEME) ? Storage.get(ADMIN_THEME) : 'light'
|
||||
}
|
||||
|
||||
export function setAdminTheme(theme) {
|
||||
Storage.set(ADMIN_THEME, theme)
|
||||
}
|
||||
|
||||
export function GetFileIcon(ext) {
|
||||
const files = {
|
||||
".docx": "doc.png",
|
||||
|
||||
Reference in New Issue
Block a user