websocket消息支持 (#188)
* Release (#162) * feat: ✨ websocket server demo * feat: ✨ ws server demo dev * feat: ✨ ws server and mobile page * feat: ✨ 手机端发送消息 * feat: ✨ 手机网页发送消息 * 添加了抽奖中和抽奖完成时的音效 * feat: ✨ 自定义设置弹幕服务器地址 * feat: ✨ ws not done * fix: 🐛 fix pr-185 #185 为播放音效添加控制 * feat: ✨ server worker demo not done * feat: ✨ websocket server * feat: ✨ 全局接收websocket消息并存储到indexdb中 --------- Co-authored-by: Silence@2024 <707261624@qq.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { IPersonConfig, IPrizeConfig } from '@/types/storeType'
|
||||
import { id } from 'zod/v4/locales'
|
||||
|
||||
const originUrl = 'https://to2026.xyz'
|
||||
type IPersonConfigWithoutUuid = Omit<IPersonConfig, 'uuid'>
|
||||
@@ -279,3 +280,24 @@ export const defaultImageList = [
|
||||
},
|
||||
]
|
||||
export const defaultPatternList = [21, 38, 55, 54, 53, 70, 87, 88, 89, 23, 40, 57, 74, 91, 92, 76, 59, 42, 25, 24, 27, 28, 29, 46, 63, 62, 61, 78, 95, 96, 97, 20, 19, 31, 48, 66, 67, 84, 101, 100, 32, 33, 93, 65, 82, 99]
|
||||
|
||||
export const defaultServerHostList = [
|
||||
{
|
||||
id: 'default',
|
||||
name: '默认服务器',
|
||||
value: 'default',
|
||||
host: 'https://to2026.xyz:8080',
|
||||
},
|
||||
{
|
||||
id: 'local',
|
||||
name: '本地服务器',
|
||||
value: 'local',
|
||||
host: 'http://127.0.0.1:8080',
|
||||
},
|
||||
{
|
||||
id: 'custom',
|
||||
name: '自定义服务器',
|
||||
value: 'custom',
|
||||
host: '',
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useGlobalConfig } from './globalConfig'
|
||||
import { usePersonConfig } from './personConfig'
|
||||
import { usePrizeConfig } from './prizeConfig'
|
||||
import { useServerConfig } from './serverConfig'
|
||||
import { useSystem } from './system'
|
||||
|
||||
export default function useStore() {
|
||||
@@ -9,5 +10,6 @@ export default function useStore() {
|
||||
prizeConfig: usePrizeConfig(),
|
||||
globalConfig: useGlobalConfig(),
|
||||
system: useSystem(),
|
||||
serverConfig: useServerConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
57
src/store/serverConfig.ts
Normal file
57
src/store/serverConfig.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { ServerType } from '@/types/storeType'
|
||||
import { defineStore } from 'pinia'
|
||||
import { defaultServerHostList } from './data'
|
||||
|
||||
export const useServerConfig = defineStore('server', {
|
||||
state() {
|
||||
return {
|
||||
serverConfig: {
|
||||
serverList: defaultServerHostList,
|
||||
currentServer: defaultServerHostList[0],
|
||||
},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
// 获取服务器列表
|
||||
getServerList(state) {
|
||||
return state.serverConfig.serverList
|
||||
},
|
||||
// 获取当前服务器
|
||||
getCurrentServer(state) {
|
||||
return state.serverConfig.currentServer
|
||||
},
|
||||
|
||||
},
|
||||
actions: {
|
||||
// 设置服务器列表地址
|
||||
updateServerList(userServer: ServerType) {
|
||||
this.serverConfig.serverList.map((item) => {
|
||||
if (item.id === userServer.id) {
|
||||
item.host = userServer.host
|
||||
}
|
||||
return item
|
||||
})
|
||||
},
|
||||
// 设置当前服务器
|
||||
setCurrentServer(userServer: ServerType) {
|
||||
this.serverConfig.currentServer = userServer
|
||||
},
|
||||
// 重置所有配置
|
||||
resetDefault() {
|
||||
this.serverConfig = {
|
||||
serverList: defaultServerHostList,
|
||||
currentServer: defaultServerHostList[0],
|
||||
}
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'serverConfig',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user