Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cea8ee6f
authored
Nov 22, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
u
parent
a638c12f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
51 deletions
store/index.ts
utils/jwt/index.ts
store/index.ts
View file @
cea8ee6f
...
@@ -11,11 +11,11 @@ import {
...
@@ -11,11 +11,11 @@ import {
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
unique
}
from
"../utils"
;
import
{
unique
}
from
"../utils"
;
import
{
getChatModelInfo
}
from
"../utils/chat-info"
;
import
{
getChatModelInfo
}
from
"../utils/chat-info"
;
import
{
decode
}
from
"../utils/jwt"
;
import
{
getUserInfo
}
from
"../utils/user-info"
;
import
{
getUserInfo
}
from
"../utils/user-info"
;
import
Chat
from
"../xim"
;
import
Chat
from
"../xim"
;
import
{
Chat
as
ChatType
,
Message
}
from
"../xim/models/chat"
;
import
{
Chat
as
ChatType
,
Message
}
from
"../xim/models/chat"
;
import
xim
,
{
ChatNotifyListener
}
from
"../xim/xim"
;
import
xim
,
{
ChatNotifyListener
}
from
"../xim/xim"
;
import
{
decodeJwt
}
from
"uniplat-sdk"
;
import
{
ChatStatus
,
ChatStore
,
ChatStoreState
}
from
"./model"
;
import
{
ChatStatus
,
ChatStore
,
ChatStoreState
}
from
"./model"
;
...
@@ -31,7 +31,7 @@ function uniqueMessages(
...
@@ -31,7 +31,7 @@ function uniqueMessages(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
)
{
)
{
const
arr
=
[...
messages
];
const
arr
=
[...
messages
];
return
unique
(
arr
,
function
(
item
,
all
)
{
return
unique
(
arr
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
});
});
}
}
...
@@ -100,7 +100,7 @@ function buildChatItem(chat: RawChatItem) {
...
@@ -100,7 +100,7 @@ function buildChatItem(chat: RawChatItem) {
const
chatType
=
"group"
;
const
chatType
=
"group"
;
const
allowedChatTypes
=
[
chatType
,
"notify"
]
const
allowedChatTypes
=
[
chatType
,
"notify"
]
;
export
const
filterActiveChats
=
(
items
:
RawChatItem
[])
=>
{
export
const
filterActiveChats
=
(
items
:
RawChatItem
[])
=>
{
return
items
.
filter
(
return
items
.
filter
(
...
@@ -213,7 +213,7 @@ export default {
...
@@ -213,7 +213,7 @@ export default {
},
},
[
ChatStore
.
MUTATION_SAVE_MYSELF_ID
](
state
)
{
[
ChatStore
.
MUTATION_SAVE_MYSELF_ID
](
state
)
{
Chat
.
getToken
().
then
((
token
)
=>
{
Chat
.
getToken
().
then
((
token
)
=>
{
const
eid
=
decode
(
token
);
const
eid
=
decode
Jwt
<
{
user_id
:
string
;
sub
:
string
}
>
(
token
);
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
String
(
eid
.
user_id
);
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
String
(
eid
.
user_id
);
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
eid
.
sub
;
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
eid
.
sub
;
});
});
...
@@ -339,7 +339,7 @@ export default {
...
@@ -339,7 +339,7 @@ export default {
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
}
}
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
return
(
return
(
state
:
ChatStoreState
,
state
:
ChatStoreState
,
...
@@ -843,7 +843,7 @@ export default {
...
@@ -843,7 +843,7 @@ export default {
}
}
commit
(
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
unique
(
newChatMembers
,
function
(
item
,
all
)
{
unique
(
newChatMembers
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
})
})
);
);
...
@@ -1063,14 +1063,16 @@ export default {
...
@@ -1063,14 +1063,16 @@ export default {
}
}
return
new
Promise
<
{
id
:
string
;
name
:
string
}
>
(
return
new
Promise
<
{
id
:
string
;
name
:
string
}
>
(
(
resolve
,
reject
)
=>
(
resolve
,
reject
)
=>
getUserInfo
(
id
).
then
(
d
=>
{
getUserInfo
(
id
)
Vue
.
set
(
.
then
((
d
)
=>
{
state
[
ChatStore
.
STATE_CHAT_USERNAME
],
Vue
.
set
(
id
,
state
[
ChatStore
.
STATE_CHAT_USERNAME
],
d
.
name
id
,
);
d
.
name
resolve
({
id
,
name
:
d
.
name
});
);
}).
catch
(
reject
)
resolve
({
id
,
name
:
d
.
name
});
})
.
catch
(
reject
)
);
);
},
},
},
},
...
...
utils/jwt/index.ts
deleted
100644 → 0
View file @
a638c12f
function
b64DecodeUnicode
(
str
:
string
)
{
return
decodeURIComponent
(
atob
(
str
).
replace
(
/
(
.
)
/g
,
function
(
m
,
p
)
{
let
code
=
p
.
charCodeAt
(
0
).
toString
(
16
).
toUpperCase
();
if
(
code
.
length
<
2
)
{
code
=
"0"
+
code
;
}
return
"%"
+
code
;
})
);
}
function
base64_url_decode
(
str
:
string
)
{
let
output
=
str
.
replace
(
/-/g
,
"+"
).
replace
(
/_/g
,
"/"
);
switch
(
output
.
length
%
4
)
{
case
0
:
break
;
case
2
:
output
+=
"=="
;
break
;
case
3
:
output
+=
"="
;
break
;
default
:
throw
new
Error
(
"Illegal base64url string!"
);
}
try
{
return
b64DecodeUnicode
(
output
);
}
catch
{
return
atob
(
output
);
}
}
export
function
decode
(
token
:
string
)
{
return
JSON
.
parse
(
base64_url_decode
(
token
.
split
(
"."
)[
1
]));
}
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