|
@@ -1,11 +1,11 @@
|
|
|
import { defineStore } from 'pinia';
|
|
|
interface RtcState {
|
|
|
- socket: Nullable<SocketIOClientStatic>,
|
|
|
+ socket: Nullable<SocketIOClient.Socket>,
|
|
|
showDaoGou: boolean,
|
|
|
sdkAppId: string,
|
|
|
userId: string,
|
|
|
roomId: string,
|
|
|
- role: string,
|
|
|
+ role: 'leader' | 'customer'
|
|
|
secretKey: string
|
|
|
userSig: string
|
|
|
audioDeviceId: string,
|
|
@@ -19,7 +19,9 @@ interface RtcState {
|
|
|
remoteStreams: any[],
|
|
|
invitedRemoteStreams: any[],
|
|
|
avatar: Nullable<string>,
|
|
|
-
|
|
|
+ nickname: Nullable<string>,
|
|
|
+ mode: string,
|
|
|
+ chatList: ChatContentType[]
|
|
|
}
|
|
|
|
|
|
interface DeviceListParams {
|
|
@@ -27,6 +29,24 @@ interface DeviceListParams {
|
|
|
microphoneItems: MediaDeviceInfo[],
|
|
|
}
|
|
|
|
|
|
+interface ChatContentType {
|
|
|
+ role: RoleType,
|
|
|
+ mode: string,
|
|
|
+ Nickname: Nullable<string>,
|
|
|
+ UserId: string,
|
|
|
+ text: string,
|
|
|
+}
|
|
|
+
|
|
|
+export type RoleType = 'leader' | 'customer'
|
|
|
+export interface SocketParams {
|
|
|
+ userId: string
|
|
|
+ roomId: string
|
|
|
+ role: RoleType
|
|
|
+ avatar: string
|
|
|
+ nickname: string
|
|
|
+ mode: string
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
export const useRtcStore = defineStore({
|
|
|
id: 'rtc',
|
|
@@ -34,9 +54,10 @@ export const useRtcStore = defineStore({
|
|
|
socket: null,
|
|
|
showDaoGou: false,
|
|
|
sdkAppId: "1400685498",
|
|
|
+ nickname: '',
|
|
|
userId: '',
|
|
|
roomId: '',
|
|
|
- role: '',
|
|
|
+ role: 'customer',
|
|
|
secretKey: '7500f8938c46c5d3c64621ae7826905eec9723bf218fbcf121242e056a4ee14f',
|
|
|
userSig: 'eJwtzcsOgjAQBdB-6RaDU2jLI3EhsrHRBdGNK2Po0IyvNAWJxvjvEmA5597c*bLj7hD26FnOohDYYrzJ4LOjhkZ*tejPd7wY9EJwnsV8brXmdnGODMu5AEggExBNSUcPHFQpnkopIJkU34784ApECjBvkB1e8MLJfWyLOAis06Wut4b0tVdL77RVTb35dGXby6o6rVfs9wdhLDRy',
|
|
|
audioDeviceId: '',
|
|
@@ -50,7 +71,8 @@ export const useRtcStore = defineStore({
|
|
|
remoteStreams: [],
|
|
|
invitedRemoteStreams: [],
|
|
|
avatar: null,
|
|
|
-
|
|
|
+ mode: '',
|
|
|
+ chatList: []
|
|
|
}),
|
|
|
getters: {
|
|
|
isLeader(): boolean {
|
|
@@ -58,11 +80,18 @@ export const useRtcStore = defineStore({
|
|
|
}
|
|
|
},
|
|
|
actions: {
|
|
|
+ setSocketParams(params: SocketParams): void {
|
|
|
+ this.avatar = params.avatar
|
|
|
+ this.roomId = params.roomId
|
|
|
+ this.userId = params.userId
|
|
|
+ this.nickname = params.nickname
|
|
|
+ this.role = params.role
|
|
|
+ },
|
|
|
setAvatar(payload: string) {
|
|
|
this.avatar = payload
|
|
|
localStorage.setItem('leaderAvatar', payload || '')
|
|
|
},
|
|
|
- setSocket(payload: SocketIOClientStatic) {
|
|
|
+ setSocket(payload: SocketIOClient.Socket) {
|
|
|
this.socket = payload
|
|
|
},
|
|
|
setShowDaoGou(payload: boolean) {
|
|
@@ -76,7 +105,7 @@ export const useRtcStore = defineStore({
|
|
|
setRoomId(payload: string) {
|
|
|
this.roomId = payload
|
|
|
},
|
|
|
- setRole(payload: string) {
|
|
|
+ setRole(payload: RoleType) {
|
|
|
this.role = payload
|
|
|
},
|
|
|
|
|
@@ -99,6 +128,10 @@ export const useRtcStore = defineStore({
|
|
|
setIsPublished(payload: boolean) {
|
|
|
this.isPublished = payload
|
|
|
},
|
|
|
+
|
|
|
+ addChat(content: ChatContentType) {
|
|
|
+ this.chatList.push(content)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
})
|