Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
anyremote-miniapp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wxl
anyremote-miniapp
Commits
c33b7955
Commit
c33b7955
authored
Apr 13, 2021
by
wxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
1679c991
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
57 additions
and
49 deletions
+57
-49
any-hooks/auth/useAuthData.ts
+1
-2
any-hooks/communication/useCallCenter.ts
+10
-13
any-hooks/communication/useChannelStore.ts
+2
-3
any-hooks/communication/useMeetingCenter.ts
+3
-7
any-hooks/contacts/useContacts.ts
+11
-1
src/hooks/call/useCallerListener.ts
+10
-5
src/hooks/http/useCustomeRequest.ts
+1
-2
src/hooks/http/useHttpIntercept.ts
+9
-8
src/pages/calling/index.vue
+2
-2
src/pages/index/work-groups-list.vue
+2
-2
src/pages/meeting/invite.vue
+6
-4
No files found.
any-hooks/auth/useAuthData.ts
View file @
c33b7955
...
...
@@ -3,8 +3,7 @@ import { useState } from "vue-vulcan";
/** 当前客户端用户的基本信息(含token) */
export
function
useAuthData
()
{
const
[
authData
,
setAuth
]
=
useState
<
UserData
>
(
null
,
{
storage
:
'custome'
,
key
:
'auth'
});
const
[
authData
,
setAuth
]
=
useState
<
UserData
>
(
null
,
{
storage
:
'custome'
,
key
:
'auth'
});
return
{
authData
,
...
...
any-hooks/communication/useCallCenter.ts
View file @
c33b7955
...
...
@@ -6,7 +6,7 @@ import { useInjector, useRequest, useState } from "vue-vulcan";
import
{
useChannelStore
}
from
"./useChannelStore"
;
import
{
useNetSocketStore
}
from
"./useNetSocketStore"
;
type
CallingState
=
'net_error'
|
'calling'
|
'call_successed'
|
'
being_called
'
|
'call_accepted'
|
'connecting'
|
'free'
;
type
CallingState
=
'net_error'
|
'calling'
|
'call_successed'
|
'
callin
'
|
'call_accepted'
|
'connecting'
|
'free'
;
interface
Caller
extends
UserData
{
action
:
AnyRemoteSubFlag
|
'none'
;
...
...
@@ -72,10 +72,10 @@ export function useCallCenter() {
if
(
msg
.
msgMainFlag
!==
'CallOffer'
)
return
;
switch
(
msg
.
msgSubFlag
)
{
case
'Request'
:
// 本地呼叫状态为free时,变更为
being_called
;不为free,则发送繁忙的回应。
// 本地呼叫状态为free时,变更为
callin
;不为free,则发送繁忙的回应。
console
.
log
(
`
${
currentMsg
.
value
.
fromName
}
呼叫,我目前的状态
${
myCallState
.
value
}
`
)
if
(
myCallState
.
value
===
'free'
)
{
setCallState
(
'
being_called
'
);
setCallState
(
'
callin
'
);
setCaller
({
id
:
msg
.
fromID
,
nickname
:
msg
.
fromName
,
...
...
@@ -88,7 +88,7 @@ export function useCallCenter() {
}
//15S秒后若本地用户仍然处于被呼叫状态,则自动发出繁忙恢复,且将状态恢复为free
timer
=
setTimeout
(
()
=>
{
if
(
myCallState
.
value
===
'
being_called
'
){
if
(
myCallState
.
value
===
'
callin
'
){
answerCaller
(
'Busying'
,
{
id
:
currentMsg
.
value
.
fromID
,
nickname
:
currentMsg
.
value
.
fromName
});
setCallState
(
'free'
);
}
...
...
@@ -106,8 +106,6 @@ export function useCallCenter() {
})
break
;
}
})
// 监听呼叫目标的回应
watch
(
currentMsg
,
msg
=>
{
...
...
@@ -119,14 +117,13 @@ export function useCallCenter() {
updateMembers
([
msg
.
fromID
],
'join'
);
break
;
case
'Busying'
:
case
'Hangup'
:
setCallState
(
isEmpty
.
value
?
'free'
:
'connecting'
);
break
;
case
'Hangup'
:
setCallState
(
isEmpty
.
value
?
'free'
:
'connecting'
);
break
;
}
})
/** 呼叫挂断功能 */
/** 呼叫挂断功能 */
const
hangup
=
(
type
?:
'leave'
|
'cancel'
)
=>
{
let
flag
:
AnyRemoteMainFlag
,
toID
:
string
;
switch
(
myCallState
.
value
)
{
...
...
@@ -138,7 +135,7 @@ export function useCallCenter() {
flag
=
'CallOffer'
;
toID
=
target
.
value
?.
id
;
break
;
case
'
being_called
'
:
case
'
callin
'
:
flag
=
'CallAnswer'
;
toID
=
caller
.
value
?.
id
;
break
;
...
...
@@ -169,7 +166,7 @@ export function useCallCenter() {
})
}
changeCallingState
({
channel_id
:
currentChannel
.
value
?.
channel_id
,
userIDs
:
JSON
.
stringify
([
{
userID
:
authData
.
value
.
id
,
callState
:
state
===
'free'
?
'idle'
:
'callout
'
},
{
userID
:
authData
.
value
.
id
,
callState
:
state
===
'free'
?
'idle'
:
state
===
'calling'
?
'callout'
:
'callin
'
},
{
userID
:
target
.
value
?.
id
||
caller
.
value
?.
id
,
callState
:
state
===
'free'
?
'idle'
:
'callin'
}
])});
})
...
...
any-hooks/communication/useChannelStore.ts
View file @
c33b7955
...
...
@@ -14,7 +14,7 @@ export function useChannelStore() {
const
[
channelMembers
,
setMembers
]
=
useState
<
string
[]
>
([]);
const
[
channelInfo
,
request
]
=
useRequest
<
ChannelData
>
(
'/getAgoraToken'
,
{
auto
:
false
});
const
{
authData
}
=
useInjector
(
useAuthData
);
const
{
currentMsg
}
=
useInjector
(
useNetSocketStore
);
const
{
currentMsg
}
=
useInjector
(
useNetSocketStore
);
const
isEmpty
=
computed
(
()
=>
channelMembers
.
value
.
length
<
2
);
//频道剩余不到1人时,表示为空
...
...
@@ -30,8 +30,7 @@ export function useChannelStore() {
console
.
log
(
'根据对方呼叫人的频道获取token'
);
updateMembers
([
authData
.
value
.
id
],
'join'
);
return
request
({
channel_id
:
cid
});
}
}
const
updateMembers
=
(
ids
:
string
[],
type
:
'join'
|
'leave'
)
=>
{
const
current
=
channelMembers
.
value
;
...
...
any-hooks/communication/useMeetingCenter.ts
View file @
c33b7955
import
{
setKeepScreenOn
}
from
"@tarojs/taro
"
;
import
{
watch
}
from
"vue
"
;
import
{
useContacts
}
from
"any-hooks/contacts/useContacts"
;
import
{
UserData
}
from
"any-hooks/types/user"
;
import
{
onMounted
,
watch
}
from
"vue"
;
import
{
useInjector
,
useState
}
from
"vue-vulcan"
;
import
{
useCallCenter
}
from
"./useCallCenter"
;
import
{
useChannelStore
}
from
"./useChannelStore"
;
...
...
@@ -23,16 +22,13 @@ interface MeetingMember {
/** 会议中心功能, 该功能在呼叫功能生效后使用,此模块会将其他即时交互模块集中到一起,如:音视频通讯模块、文本聊天模块等(目前只有音视频通讯) */
export
function
useMeetingCenter
()
{
const
{
hangup
,
myCallState
}
=
useInjector
(
useCallCenter
);
const
{
streamList
,
localPushurl
,
voiceMute
,
mode
,
join
,
stopVideoConference
,
switchLocalMicState
,
switchVideoOrAudio
}
=
useInjector
(
useVideoConference
);
const
{
streamList
,
localPushurl
,
voiceMute
,
mode
,
join
,
stopVideoConference
,
switchLocalMicState
,
switchVideoOrAudio
}
=
useInjector
(
useVideoConference
);
/** 离开会议(分两步:1.挂断当前呼叫, 2.停止音视频功能) */
const
leave
=
()
=>
{
hangup
(
'leave'
);
stopVideoConference
();
}
/** 保持屏幕常亮 */
onMounted
(()
=>
setKeepScreenOn
({
keepScreenOn
:
true
}));
}
/** 监听频道成员信息 */
const
{
channelMembers
}
=
useInjector
(
useChannelStore
);
...
...
any-hooks/contacts/useContacts.ts
View file @
c33b7955
...
...
@@ -33,7 +33,17 @@ export function useContacts() {
return
contactHome
})
const
freeContacts
=
computed
(
()
=>
contacts
.
value
.
filter
(
item
=>
item
.
is_calling
===
'0'
&&
item
.
is_signin
===
'1'
))
const
freeContacts
=
computed
(
()
=>
{
const
list
=
contacts
.
value
.
filter
(
item
=>
item
.
is_calling
===
'0'
&&
item
.
is_signin
===
'1'
);
const
frees
=
{}
as
{[
props
:
string
]:
UserData
[]}
list
?.
forEach
(
item
=>
{
if
([
'3'
,
'4'
].
includes
(
item
.
permission
)
)
{
if
(
!
frees
[
item
.
group_name
])
frees
[
item
.
group_name
]
=
[];
frees
[
item
.
group_name
].
push
(
item
);
};
})
return
frees
})
const
getContactById
=
(
pid
:
string
,
type
?:
'uid'
|
'pid'
)
=>
{
...
...
src/hooks/call/useCallerListener.ts
View file @
c33b7955
import
{
navigateTo
,
redirectTo
,
showToast
}
from
"@tarojs/taro"
;
import
{
navigateTo
,
redirectTo
,
s
etKeepScreenOn
,
s
howToast
}
from
"@tarojs/taro"
;
import
{
useCallCenter
}
from
"any-hooks/communication/useCallCenter"
;
import
{
watch
}
from
"vue"
;
import
{
onMounted
,
watch
}
from
"vue"
;
import
{
useInjector
}
from
"vue-vulcan"
;
import
{
useAppInitInfo
}
from
"../common/useAppInitInfo"
;
...
...
@@ -8,12 +8,17 @@ import { useAppInitInfo } from "../common/useAppInitInfo";
/** 在小程序平台监听远程联系人的呼叫动作 */
export
function
useCallerListener
()
{
const
{
caller
,
target
,
myCallState
,
answerCaller
}
=
useInjector
(
useCallCenter
);
const
{
checkCamearSetting
}
=
useInjector
(
useAppInitInfo
)
const
{
checkCamearSetting
}
=
useInjector
(
useAppInitInfo
);
onMounted
(()
=>
{
/** 保持屏幕常亮 */
onMounted
(()
=>
setKeepScreenOn
({
keepScreenOn
:
true
}));
})
watch
(
caller
,
current
=>
{
if
(
!
current
)
return
;
switch
(
current
.
action
)
{
case
'Request'
:
case
'Request'
:
break
;
case
'Hangup'
:
showToast
({
title
:
'对方取消了呼叫'
,
icon
:
'none'
});
...
...
@@ -42,7 +47,7 @@ export function useCallerListener() {
navigateTo
({
url
:
'/pages/calling/index'
});
}
break
;
case
'
being_called
'
:
case
'
callin
'
:
checkCamearSetting
().
then
(
r
=>
{
r
?
navigateTo
({
url
:
'/pages/calling/index'
})
:
answerCaller
(
'NoDevice'
)
})
...
...
src/hooks/http/useCustomeRequest.ts
View file @
c33b7955
...
...
@@ -2,8 +2,7 @@ import { CUSTOME_REQUESTER, RequesterFunc, RequestOptions } from 'vue-vulcan';
import
{
request
,
showToast
}
from
'@tarojs/taro'
;
export
function
useCustomeRequest
():
RequesterFunc
{
return
function
(
url
:
string
,
reqs
:
RequestOptions
)
{
console
.
log
(
'my url'
,
url
)
return
function
(
url
:
string
,
reqs
:
RequestOptions
)
{
return
request
({
...
reqs
,
url
,
...
...
src/hooks/http/useHttpIntercept.ts
View file @
c33b7955
import
{
useAuthData
}
from
"
../../../
any-hooks/auth/useAuthData"
;
import
{
useAuthData
}
from
"any-hooks/auth/useAuthData"
;
import
{
HttpIntercept
,
HttpResponse
,
HTTP_INTERCEPT
,
RequestOptions
,
useInjector
}
from
"vue-vulcan"
;
import
{
showToast
}
from
"@tarojs/taro"
;
...
...
@@ -20,13 +20,7 @@ export function useHttpIntercept(): HttpIntercept {
}
})
}
const
checkResData
=
(
data
:
any
)
=>
{
if
(
data
.
success
)
return
true
;
showToast
({
title
:
data
.
msg
,
icon
:
'none'
});
return
false
;
}
const
responseIntercept
=
(
res
:
HttpResponse
)
=>
{
switch
(
res
.
status
)
{
case
404
:
...
...
@@ -42,6 +36,13 @@ export function useHttpIntercept(): HttpIntercept {
}
})
}
const
checkResData
=
(
data
:
any
)
=>
{
if
(
data
.
success
)
return
true
;
showToast
({
title
:
data
.
msg
,
icon
:
'none'
});
return
false
;
}
return
{
requestIntercept
,
...
...
src/pages/calling/index.vue
View file @
c33b7955
...
...
@@ -24,7 +24,7 @@
<
template
>
<view
class=
"page call-container"
>
<view
class=
"call-box caller"
v-if=
"myCallState==='
being_called
'"
>
<view
class=
"call-box caller"
v-if=
"myCallState==='
callin
'"
>
<image
class=
"avatar"
:src=
"caller?.avatar"
></image>
<text
class=
"tips"
>
{{
caller
?.
nickname
}}
向您发起呼叫
</text>
</view>
...
...
@@ -35,7 +35,7 @@
</view>
<view
class=
"operators"
v-if=
"myCallState!=='free'"
>
<image
v-if=
"myCallState==='
being_called
'"
@
tap=
"answerCaller('Connect')"
class=
"op-icon"
src=
"../../assets/answer3x.png"
></image>
<image
v-if=
"myCallState==='
callin
'"
@
tap=
"answerCaller('Connect')"
class=
"op-icon"
src=
"../../assets/answer3x.png"
></image>
<image
@
tap=
"onTapHangup()"
class=
"op-icon"
src=
"../../assets/hangup.png"
></image>
</view>
</view>
...
...
src/pages/index/work-groups-list.vue
View file @
c33b7955
<
script
lang=
"ts"
setup
>
import
{
navigateTo
}
from
'@tarojs/taro'
;
import
{
useContacts
}
from
'any-hooks/contacts/useContacts'
;
import
{
useContacts
}
from
'any-hooks/contacts/useContacts'
;
import
{
useInjector
}
from
'vue-vulcan'
;
const
{
filterGroups
}
=
useInjector
(
useContacts
);
const
gotoGroupContacts
=
(
id
:
string
)
=>
{
navigateTo
({
url
:
`/pages/group-contacts/index?id=
${
id
}
`
})
navigateTo
({
url
:
`/pages/group-contacts/index?id=
${
id
}
`
})
;
}
</
script
>
...
...
src/pages/meeting/invite.vue
View file @
c33b7955
...
...
@@ -27,7 +27,7 @@
<
template
>
<scroll-view
:scrollY=
"true"
class=
"invite-container page"
:style=
"
{top: topDistance+'px'}" >
<view
class=
"contact-role-group"
v-for=
"(group, key, index) in
rol
eContacts"
:key=
"index"
>
<view
class=
"contact-role-group"
v-for=
"(group, key, index) in
fre
eContacts"
:key=
"index"
>
<view
class=
"role-name pd-2"
:class=
"
{hide: hideConfig[index]}" @tap="toggleHideByIndex(index)">
{{
key
}}
</view>
<view
class=
"white-box"
:style=
"
{display: hideConfig[index] ? 'none' : 'block'}">
<view
class=
"contact-item"
v-for=
"(item, i) in group"
:key=
"i"
>
...
...
@@ -47,13 +47,15 @@
<
style
lang=
"less"
>
.invite-container
{
position
:
absolute
;
border-top-left-radius
:
20px
;
border-top-right-radius
:
20px
;
z-index
:
1000
;
top
:
0
;
left
:
0
;
bottom
:
0
;
width
:
100%
;
height
:
100%
;
background-color
:
rgba
(
0
,
0
,
0
,
0.65
)
;
background-color
:
#fff
;
z-index
:
10000
;
.contact-role-group{
background-color
:
#fff
;
...
...
@@ -66,7 +68,7 @@
}
&
::before
{
content
:
''
;
width
:
0
;
width
:
0
;
height
:
0
;
position
:
absolute
;
border-left
:
10px
solid
transparent
;
...
...
@@ -100,7 +102,7 @@
display
:
inline-block
;
background
:
#2b91e2
;
color
:
#fff
;
padding
:
6px
12
px
;
padding
:
2px
15
px
;
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment