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
84b48c2e
authored
Jul 13, 2021
by
panjiangyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
format file
parent
31d2e1e4
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1055 additions
and
1038 deletions
components/file-controller.ts
model/index.ts
service/emoji.ts
service/request.ts
service/tools.ts
service/upload.ts
store/index.ts
store/model.ts
third-party/image/index.ts
third-party/pc-mobile-transformer/index.ts
third-party/seo/index.ts
third-party/user-agent/index.ts
utils/jwt/index.ts
utils/time/index.ts
xim/chat-type.ts
xim/index.ts
xim/logger.ts
xim/models/chat.ts
xim/models/user.ts
xim/token.ts
xim/xim.ts
components/file-controller.ts
View file @
84b48c2e
const
SVG_AUDIO
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484227561" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6614" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#E54C94" p-id="6615"></path><path d="M607.744 434.39c-31.488 19.86-73.472-1.43-73.472-1.43s40.47 178.795 37.483 193.003c0 0 0-1.43 0 0 0 42.56-37.483 78.037-83.968 78.037-46.464 0-82.454-35.477-82.454-78.037 0-42.582 37.483-78.059 82.454-78.059 16.49 0 34.496 5.675 43.477 15.616l-38.976-143.317s-16.49-65.28 41.984-56.768c41.984 7.082 29.995 34.048 104.96 11.349 1.493-1.408 4.48 36.907-31.488 59.605zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6616"></path></svg>`
const
SVG_AUDIO
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484227561" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6614" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#E54C94" p-id="6615"></path><path d="M607.744 434.39c-31.488 19.86-73.472-1.43-73.472-1.43s40.47 178.795 37.483 193.003c0 0 0-1.43 0 0 0 42.56-37.483 78.037-83.968 78.037-46.464 0-82.454-35.477-82.454-78.037 0-42.582 37.483-78.059 82.454-78.059 16.49 0 34.496 5.675 43.477 15.616l-38.976-143.317s-16.49-65.28 41.984-56.768c41.984 7.082 29.995 34.048 104.96 11.349 1.493-1.408 4.48 36.907-31.488 59.605zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6616"></path></svg>`
;
const
SVG_EXCEL
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484180583" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5396" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#3AC877" p-id="5397"></path><path d="M369.707 704L474.09 544.64l-94.592-146.048h72.085l61.248 98.133 60.01-98.133h71.467l-95.018 148.33L653.675 704h-74.39l-67.712-105.621L443.67 704zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5398"></path></svg>`
const
SVG_EXCEL
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484180583" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5396" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#3AC877" p-id="5397"></path><path d="M369.707 704L474.09 544.64l-94.592-146.048h72.085l61.248 98.133 60.01-98.133h71.467l-95.018 148.33L653.675 704h-74.39l-67.712-105.621L443.67 704zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5398"></path></svg>`
;
const
SVG_IMAGE
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484188280" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5531" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F6AD00" p-id="5532"></path><path d="M294.485 684.95l78.379-115.2a12.181 12.181 0 0 1 18.624-1.835l51.797 50.752 113.643-178.134a12.181 12.181 0 0 1 20.843 0.47l141.205 244.714A12.181 12.181 0 0 1 708.416 704h-403.84a12.181 12.181 0 0 1-10.09-19.05z" fill="#FFF7F7" p-id="5533"></path><path d="M443.307 423.616c0 32.512-29.014 60.95-62.187 60.95-33.152 0-62.165-28.438-62.165-60.95-2.07-32.512 26.944-60.95 62.165-60.95 33.152 0 62.165 28.438 62.165 60.95zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5534"></path></svg>`
const
SVG_IMAGE
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484188280" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5531" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F6AD00" p-id="5532"></path><path d="M294.485 684.95l78.379-115.2a12.181 12.181 0 0 1 18.624-1.835l51.797 50.752 113.643-178.134a12.181 12.181 0 0 1 20.843 0.47l141.205 244.714A12.181 12.181 0 0 1 708.416 704h-403.84a12.181 12.181 0 0 1-10.09-19.05z" fill="#FFF7F7" p-id="5533"></path><path d="M443.307 423.616c0 32.512-29.014 60.95-62.187 60.95-33.152 0-62.165-28.438-62.165-60.95-2.07-32.512 26.944-60.95 62.165-60.95 33.152 0 62.165 28.438 62.165 60.95zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5534"></path></svg>`
;
const
SVG_OTHERS
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484218091" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6343" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F2F2F2" p-id="6344"></path><path d="M512 693.333c-11.243-0.085-20.267-9.685-20.203-21.461 0-11.883 9.046-21.483 20.203-21.483 11.136 0 20.203 9.6 20.203 21.483 0 11.819-9.067 21.461-20.203 21.461z m86.89-195.712c-6.058 11.648-18.005 25.728-35.69 42.411-11.904 11.285-19.67 19.499-23.317 24.768-3.67 5.397-6.4 11.456-8.107 18.325a132.267 132.267 0 0 0-2.773 25.195 19.84 19.84 0 0 1-3.264 16.363 17.43 17.43 0 0 1-14.187 7.21c-8.533 0.043-15.872-6.293-17.621-15.146h-0.32a380.757 380.757 0 0 1-0.214-11.606c0-15.274 2.006-28.33 6.08-39.36 3.435-9.216 8.299-17.749 14.379-25.237 4.907-6.187 13.653-15.275 26.261-27.093 12.63-11.798 20.907-21.27 24.683-28.267 3.797-7.083 5.675-14.763 5.675-23.125 0-15.04-5.59-28.288-16.64-39.68a54.272 54.272 0 0 0-40.747-17.152c-15.573 0-28.544 5.12-38.912 15.53-9.984 9.878-16.619 25.067-20.053 45.59-0.299 10.944-8.768 19.626-19.072 19.562a18.603 18.603 0 0 1-15.232-8.021 21.163 21.163 0 0 1-3.051-17.77c3.776-27.35 13.653-48.427 29.525-63.297 16.704-15.637 38.784-23.488 66.176-23.488 29.142 0 52.288 8.406 69.59 25.238C599.38 415.317 608 435.69 608 459.477c0 13.782-3.03 26.454-9.11 38.102v0.042z" fill="#AAAAAA" p-id="6345"></path><path d="M650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill-opacity=".1" p-id="6346"></path></svg>`
const
SVG_OTHERS
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484218091" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6343" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F2F2F2" p-id="6344"></path><path d="M512 693.333c-11.243-0.085-20.267-9.685-20.203-21.461 0-11.883 9.046-21.483 20.203-21.483 11.136 0 20.203 9.6 20.203 21.483 0 11.819-9.067 21.461-20.203 21.461z m86.89-195.712c-6.058 11.648-18.005 25.728-35.69 42.411-11.904 11.285-19.67 19.499-23.317 24.768-3.67 5.397-6.4 11.456-8.107 18.325a132.267 132.267 0 0 0-2.773 25.195 19.84 19.84 0 0 1-3.264 16.363 17.43 17.43 0 0 1-14.187 7.21c-8.533 0.043-15.872-6.293-17.621-15.146h-0.32a380.757 380.757 0 0 1-0.214-11.606c0-15.274 2.006-28.33 6.08-39.36 3.435-9.216 8.299-17.749 14.379-25.237 4.907-6.187 13.653-15.275 26.261-27.093 12.63-11.798 20.907-21.27 24.683-28.267 3.797-7.083 5.675-14.763 5.675-23.125 0-15.04-5.59-28.288-16.64-39.68a54.272 54.272 0 0 0-40.747-17.152c-15.573 0-28.544 5.12-38.912 15.53-9.984 9.878-16.619 25.067-20.053 45.59-0.299 10.944-8.768 19.626-19.072 19.562a18.603 18.603 0 0 1-15.232-8.021 21.163 21.163 0 0 1-3.051-17.77c3.776-27.35 13.653-48.427 29.525-63.297 16.704-15.637 38.784-23.488 66.176-23.488 29.142 0 52.288 8.406 69.59 25.238C599.38 415.317 608 435.69 608 459.477c0 13.782-3.03 26.454-9.11 38.102v0.042z" fill="#AAAAAA" p-id="6345"></path><path d="M650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill-opacity=".1" p-id="6346"></path></svg>`
;
const
SVG_PDF
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484212640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6208" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#EF5E5E" p-id="6209"></path><path d="M274.624 640V456.747h59.37c22.507 0 37.163 0.917 44.011 2.773 10.496 2.73 19.286 8.704 26.368 17.92 7.083 9.216 10.624 21.12 10.624 35.69 0 11.243-2.048 20.694-6.122 28.374-4.075 7.68-9.28 13.675-15.574 18.048-6.272 4.395-12.672 7.275-19.178 8.704-8.832 1.75-21.632 2.624-38.379 2.624h-24.107V640h-37.034z m36.992-152.256v52.01h20.267c14.57 0 24.32-0.96 29.226-2.88 4.928-1.92 8.79-4.906 11.584-9.002 2.774-4.075 4.182-8.832 4.182-14.25 0-6.657-1.963-12.16-5.867-16.491a25.6 25.6 0 0 0-14.89-8.128c-4.417-0.854-13.291-1.259-26.625-1.259h-17.877z m133.632-30.997h67.627c15.253 0 26.88 1.173 34.88 3.498 10.752 3.179 19.946 8.79 27.626 16.875 7.68 8.107 13.504 17.984 17.494 29.696 4.01 11.712 5.994 26.133 5.994 43.307 0 15.082-1.877 28.096-5.61 38.997-4.587 13.333-11.136 24.128-19.627 32.384-6.421 6.25-15.083 11.115-26.027 14.613C539.456 638.7 528.533 640 514.88 640h-69.653V456.747z m36.992 30.997v121.387h27.627c10.346 0 17.792-0.598 22.4-1.75a34.133 34.133 0 0 0 14.933-7.637c3.947-3.584 7.168-9.472 9.685-17.685 2.496-8.214 3.734-19.392 3.734-33.558 0-14.165-1.238-25.045-3.734-32.64-2.517-7.573-6.016-13.482-10.517-17.728a35.2 35.2 0 0 0-17.11-8.64c-5.183-1.152-15.295-1.749-30.378-1.749h-16.64zM630.507 640V456.747h125.61v30.997H667.52v43.37h76.501v31.02H667.52V640h-36.992zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6210"></path></svg>`
const
SVG_PDF
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484212640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6208" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#EF5E5E" p-id="6209"></path><path d="M274.624 640V456.747h59.37c22.507 0 37.163 0.917 44.011 2.773 10.496 2.73 19.286 8.704 26.368 17.92 7.083 9.216 10.624 21.12 10.624 35.69 0 11.243-2.048 20.694-6.122 28.374-4.075 7.68-9.28 13.675-15.574 18.048-6.272 4.395-12.672 7.275-19.178 8.704-8.832 1.75-21.632 2.624-38.379 2.624h-24.107V640h-37.034z m36.992-152.256v52.01h20.267c14.57 0 24.32-0.96 29.226-2.88 4.928-1.92 8.79-4.906 11.584-9.002 2.774-4.075 4.182-8.832 4.182-14.25 0-6.657-1.963-12.16-5.867-16.491a25.6 25.6 0 0 0-14.89-8.128c-4.417-0.854-13.291-1.259-26.625-1.259h-17.877z m133.632-30.997h67.627c15.253 0 26.88 1.173 34.88 3.498 10.752 3.179 19.946 8.79 27.626 16.875 7.68 8.107 13.504 17.984 17.494 29.696 4.01 11.712 5.994 26.133 5.994 43.307 0 15.082-1.877 28.096-5.61 38.997-4.587 13.333-11.136 24.128-19.627 32.384-6.421 6.25-15.083 11.115-26.027 14.613C539.456 638.7 528.533 640 514.88 640h-69.653V456.747z m36.992 30.997v121.387h27.627c10.346 0 17.792-0.598 22.4-1.75a34.133 34.133 0 0 0 14.933-7.637c3.947-3.584 7.168-9.472 9.685-17.685 2.496-8.214 3.734-19.392 3.734-33.558 0-14.165-1.238-25.045-3.734-32.64-2.517-7.573-6.016-13.482-10.517-17.728a35.2 35.2 0 0 0-17.11-8.64c-5.183-1.152-15.295-1.749-30.378-1.749h-16.64zM630.507 640V456.747h125.61v30.997H667.52v43.37h76.501v31.02H667.52V640h-36.992zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6210"></path></svg>`
;
const
SVG_PPT
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484168359" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5125" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F57B47" p-id="5126"></path><path d="M400.747 704V398.592h98.965c37.504 0 61.93 1.515 73.323 4.565 17.493 4.587 32.149 14.55 43.946 29.91 11.819 15.36 17.728 35.178 17.728 59.477 0 18.752-3.413 34.517-10.218 47.296-6.806 12.779-15.446 22.805-25.92 30.08a89.387 89.387 0 0 1-32 14.507c-14.72 2.901-36.032 4.373-63.936 4.373H462.42V704h-61.653zM462.4 450.24v86.677h33.77c24.32 0 40.534-1.6 48.747-4.8 8.192-3.2 14.614-8.192 19.264-14.997 4.651-6.805 6.976-14.72 6.976-23.744 0-11.093-3.264-20.267-9.792-27.52a42.645 42.645 0 0 0-24.789-13.525c-7.36-1.387-22.144-2.091-44.373-2.091H462.42zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5127"></path></svg>`
const
SVG_PPT
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484168359" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5125" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F57B47" p-id="5126"></path><path d="M400.747 704V398.592h98.965c37.504 0 61.93 1.515 73.323 4.565 17.493 4.587 32.149 14.55 43.946 29.91 11.819 15.36 17.728 35.178 17.728 59.477 0 18.752-3.413 34.517-10.218 47.296-6.806 12.779-15.446 22.805-25.92 30.08a89.387 89.387 0 0 1-32 14.507c-14.72 2.901-36.032 4.373-63.936 4.373H462.42V704h-61.653zM462.4 450.24v86.677h33.77c24.32 0 40.534-1.6 48.747-4.8 8.192-3.2 14.614-8.192 19.264-14.997 4.651-6.805 6.976-14.72 6.976-23.744 0-11.093-3.264-20.267-9.792-27.52a42.645 42.645 0 0 0-24.789-13.525c-7.36-1.387-22.144-2.091-44.373-2.091H462.42zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5127"></path></svg>`
;
const
SVG_RP
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484207818" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6072" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M640 32l277.333 277.333H682.667A42.667 42.667 0 0 1 640 266.667V32z" fill="#FFFFFF" p-id="6073"></path><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#BC6CD5" p-id="6074"></path><path d="M299.925 661.333v-244.33h103.83c26.112 0 45.077 2.197 56.917 6.57 11.819 4.395 21.29 12.203 28.416 23.424 7.104 11.222 10.667 24.064 10.667 38.507 0 18.347-5.398 33.472-16.171 45.419s-26.88 19.456-48.341 22.57c10.666 6.23 19.477 13.056 26.432 20.502 6.933 7.466 16.298 20.672 28.074 39.68l29.824 47.658h-58.986l-35.67-53.162c-12.672-18.987-21.333-30.976-26.005-35.926a37.867 37.867 0 0 0-14.827-10.154c-5.226-1.835-13.504-2.774-24.832-2.774h-10.005v102.016h-49.301z m49.323-141.013h36.501c23.68 0 38.443-0.981 44.331-2.987 5.888-2.005 10.496-5.44 13.845-10.325 3.328-4.907 4.992-11.008 4.992-18.347 0-8.213-2.197-14.848-6.592-19.904-4.373-5.056-10.581-8.256-18.56-9.6-4.01-0.554-16-0.832-36.01-0.832h-38.528v62.016zM546.24 661.333v-244.33h79.168c30.016 0 49.557 1.216 58.667 3.669 14.016 3.67 25.728 11.627 35.178 23.893 9.451 12.288 14.166 28.16 14.166 47.595 0 14.997-2.731 27.627-8.171 37.845a66.987 66.987 0 0 1-20.757 24.086 71.51 71.51 0 0 1-25.579 11.584c-11.776 2.325-28.821 3.498-51.157 3.498h-32.171v92.16H546.24z m49.344-203.008v69.334h27.008c19.435 0 32.427-1.28 38.997-3.84 6.55-2.56 11.691-6.55 15.403-11.99a32.853 32.853 0 0 0 5.59-18.986c0-8.896-2.603-16.214-7.83-22.016a34.133 34.133 0 0 0-19.84-10.838c-5.888-1.109-17.707-1.664-35.499-1.664h-23.829zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6075"></path></svg>`
const
SVG_RP
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484207818" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6072" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M640 32l277.333 277.333H682.667A42.667 42.667 0 0 1 640 266.667V32z" fill="#FFFFFF" p-id="6073"></path><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#BC6CD5" p-id="6074"></path><path d="M299.925 661.333v-244.33h103.83c26.112 0 45.077 2.197 56.917 6.57 11.819 4.395 21.29 12.203 28.416 23.424 7.104 11.222 10.667 24.064 10.667 38.507 0 18.347-5.398 33.472-16.171 45.419s-26.88 19.456-48.341 22.57c10.666 6.23 19.477 13.056 26.432 20.502 6.933 7.466 16.298 20.672 28.074 39.68l29.824 47.658h-58.986l-35.67-53.162c-12.672-18.987-21.333-30.976-26.005-35.926a37.867 37.867 0 0 0-14.827-10.154c-5.226-1.835-13.504-2.774-24.832-2.774h-10.005v102.016h-49.301z m49.323-141.013h36.501c23.68 0 38.443-0.981 44.331-2.987 5.888-2.005 10.496-5.44 13.845-10.325 3.328-4.907 4.992-11.008 4.992-18.347 0-8.213-2.197-14.848-6.592-19.904-4.373-5.056-10.581-8.256-18.56-9.6-4.01-0.554-16-0.832-36.01-0.832h-38.528v62.016zM546.24 661.333v-244.33h79.168c30.016 0 49.557 1.216 58.667 3.669 14.016 3.67 25.728 11.627 35.178 23.893 9.451 12.288 14.166 28.16 14.166 47.595 0 14.997-2.731 27.627-8.171 37.845a66.987 66.987 0 0 1-20.757 24.086 71.51 71.51 0 0 1-25.579 11.584c-11.776 2.325-28.821 3.498-51.157 3.498h-32.171v92.16H546.24z m49.344-203.008v69.334h27.008c19.435 0 32.427-1.28 38.997-3.84 6.55-2.56 11.691-6.55 15.403-11.99a32.853 32.853 0 0 0 5.59-18.986c0-8.896-2.603-16.214-7.83-22.016a34.133 34.133 0 0 0-19.84-10.838c-5.888-1.109-17.707-1.664-35.499-1.664h-23.829zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6075"></path></svg>`
;
const
SVG_TEXT
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484222751" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6479" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#5098F1" p-id="6480"></path><path d="M481.493 704V450.24h-90.666v-51.648h242.709v51.648h-90.39V704zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6481"></path></svg>`
const
SVG_TEXT
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484222751" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6479" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#5098F1" p-id="6480"></path><path d="M481.493 704V450.24h-90.666v-51.648h242.709v51.648h-90.39V704zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="6481"></path></svg>`
;
const
SVG_VIDEO
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484193398" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5667" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#8183F1" p-id="5668"></path><path d="M512 341.333c106.325 0 192 86.187 192 192s-86.187 192-192 192-192-86.186-192-192 86.187-192 192-192z m-31.296 102.87a12.8 12.8 0 0 0-19.904 10.666v156.95a12.8 12.8 0 0 0 19.904 10.666l117.717-78.506a12.8 12.8 0 0 0 0-21.291l-117.717-78.507zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5669"></path></svg>`
const
SVG_VIDEO
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484193398" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5667" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#8183F1" p-id="5668"></path><path d="M512 341.333c106.325 0 192 86.187 192 192s-86.187 192-192 192-192-86.186-192-192 86.187-192 192-192z m-31.296 102.87a12.8 12.8 0 0 0-19.904 10.666v156.95a12.8 12.8 0 0 0 19.904 10.666l117.717-78.506a12.8 12.8 0 0 0 0-21.291l-117.717-78.507zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5669"></path></svg>`
;
const
SVG_WORD
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484175478" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5260" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0H646.74l291.926 295.83v681.237A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#66C7FC" p-id="5261"></path><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#3FB0EE" p-id="5262"></path><path d="M385.024 704l-72.917-305.408h63.125l46.037 209.792 55.83-209.792h73.344l53.546 213.333 46.87-213.333h62.08L638.763 704h-65.408l-60.843-228.33L451.904 704zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5263"></path></svg>`
const
SVG_WORD
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484175478" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5260" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0H646.74l291.926 295.83v681.237A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#66C7FC" p-id="5261"></path><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#3FB0EE" p-id="5262"></path><path d="M385.024 704l-72.917-305.408h63.125l46.037 209.792 55.83-209.792h73.344l53.546 213.333 46.87-213.333h62.08L638.763 704h-65.408l-60.843-228.33L451.904 704zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5263"></path></svg>`
;
const
SVG_XMIND
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484203239" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5937" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#EB4E53" p-id="5938"></path><path d="M412.267 394.667L277.333 424.66s0.726 78.294 148.139 114.902c0 0-163.541 40.234-134.933 132.437l117.333-19.755s0-98.773 84.33-84.885c84.331 13.163 101.206 73.173 107.073 98.048l147.392-22.677s-11.008-91.478-155.478-130.262c0 0 130.56-25.6 84.352-110.485L555.99 424.661s27.136 57.814-25.664 65.131-94.592-18.283-118.058-95.125zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5939"></path></svg>`
const
SVG_XMIND
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484203239" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5937" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#EB4E53" p-id="5938"></path><path d="M412.267 394.667L277.333 424.66s0.726 78.294 148.139 114.902c0 0-163.541 40.234-134.933 132.437l117.333-19.755s0-98.773 84.33-84.885c84.331 13.163 101.206 73.173 107.073 98.048l147.392-22.677s-11.008-91.478-155.478-130.262c0 0 130.56-25.6 84.352-110.485L555.99 424.661s27.136 57.814-25.664 65.131-94.592-18.283-118.058-95.125zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5939"></path></svg>`
;
const
SVG_ZIP
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484198283" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5802" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F38C12" p-id="5803"></path><path d="M426.667 0v85.333H512V0h-85.333z m0 170.667V256H512v-85.333h-85.333z m0 170.666v85.334H512v-85.334h-85.333z m85.333-256v85.334h85.333V85.333H512zM512 256v85.333h85.333V256H512z m0 170.667V512h85.333v-85.333H512zM426.667 512v170.667h170.666V512H426.667z m28.437 85.333h113.792v56.896H455.104v-56.896zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5804"></path></svg>`
const
SVG_ZIP
=
`<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1595484198283" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5802" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M132.267 0h518.4l288 288v689.067A46.933 46.933 0 0 1 891.733 1024H132.267a46.933 46.933 0 0 1-46.934-46.933V46.933A46.933 46.933 0 0 1 132.267 0z" fill="#F38C12" p-id="5803"></path><path d="M426.667 0v85.333H512V0h-85.333z m0 170.667V256H512v-85.333h-85.333z m0 170.666v85.334H512v-85.334h-85.333z m85.333-256v85.334h85.333V85.333H512zM512 256v85.333h85.333V256H512z m0 170.667V512h85.333v-85.333H512zM426.667 512v170.667h170.666V512H426.667z m28.437 85.333h113.792v56.896H455.104v-56.896zM650.667 0v241.067A46.933 46.933 0 0 0 697.6 288h241.067l-288-288z" fill="#FFFFFF" p-id="5804"></path></svg>`
;
const
IMAGE_404
=
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25px" height="23px" viewBox="0 0 25 23" version="1.1"><!-- Generator: Sketch 59 (86127) - https://sketch.com --><title>形状</title><desc>Created with Sketch.</desc><g id="页面-" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="聊天记录-全部" transform="translate(-630.000000, -504.000000)" fill="#C5D4E5" fill-rule="nonzero"><g id="输入区" transform="translate(460.500000, 65.000000)"><g id="聊天" transform="translate(21.000000, 57.000000)"><g id="Group-4" transform="translate(0.000000, 306.000000)"><g id="Group-6" transform="translate(50.500000, 22.000000)"><path d="M115.343089,60.4857235 C115.343089,61.4880836 116.155662,62.300657 117.158022,62.300657 C118.160382,62.300657 118.972956,61.4880836 118.972956,60.4857235 C118.972956,59.4833634 118.160382,58.67079 117.158022,58.67079 C116.155662,58.67079 115.343089,59.4833634 115.343089,60.4857235 L115.343089,60.4857235 Z M122.802062,55.1570787 C122.661436,54.9955729 122.46236,54.8966151 122.248709,54.8820154 L110.74929,54.0777982 C110.48502,54.0573212 110.227916,54.1698422 110.063649,54.3778672 L107.739727,57.2728878 C107.496372,57.5757527 107.503492,58.0090641 107.756667,58.3037701 L111.440578,62.5878198 L107.723595,67.4945933 L108.643161,63.1242335 C108.705387,62.8284556 108.597037,62.5227098 108.362451,62.3321158 L103.536341,58.406213 L105.543255,55.2377424 C105.705781,54.9807089 105.709936,54.6541148 105.554001,54.39303 C105.398066,54.1319451 105.108547,53.9807499 104.805182,54.0019743 L98.7505634,54.4246522 C98.5370214,54.4395331 98.3381511,54.5386828 98.1977496,54.7002656 C98.057348,54.8618484 97.9869302,55.0726122 98.0020041,55.2861406 L99.4087793,75.402057 C99.4240595,75.616038 99.5237815,75.8151664 99.6859762,75.9555738 C99.8481709,76.0959812 100.059531,76.1661479 100.273494,76.1506162 L104.722905,75.8182817 C105.167362,75.7852096 105.500503,75.3980238 105.466624,74.9543734 C105.432745,74.510723 105.048786,74.1719354 104.601909,74.2098473 L100.960749,74.481684 L100.798615,72.1496961 L103.957406,71.8326877 C104.170417,71.8114964 104.366269,71.7065053 104.501829,71.5408371 C104.63739,71.3751689 104.70154,71.1624111 104.680153,70.9494201 C104.633914,70.5069599 104.239744,70.1844247 103.796885,70.2266732 L100.686492,70.5396484 L99.6677098,55.9782353 L103.326616,55.7225313 L101.789972,58.1480891 C101.571262,58.4934105 101.645424,58.9477426 101.962592,59.2055904 L106.963742,63.2726547 L105.482757,70.3129834 C105.458801,70.4366147 105.465167,70.5642102 105.501309,70.6848431 C105.496625,70.778974 105.508642,70.8731908 105.536801,70.9631329 L106.835487,74.8591902 C106.936546,75.1634142 107.208317,75.3788038 107.527582,75.4077034 L120.713679,76.6063662 C120.929641,76.6257531 121.144336,76.5575538 121.309522,76.417093 C121.474707,76.2766322 121.576529,76.0756905 121.592107,75.8594202 L122.998075,55.7426972 C123.012827,55.5292412 122.942339,55.3186449 122.802062,55.1570787 Z M120.308747,71.0591227 L109.908775,70.0596994 C109.695255,70.0358706 109.481187,70.0995268 109.315381,70.2361533 C109.149575,70.3727799 109.046166,70.5707294 109.028733,70.7848661 C109.008287,70.99784 109.07329,71.2102124 109.20944,71.3752556 C109.345589,71.5402989 109.54173,71.6444911 109.754707,71.6649072 L120.196624,72.6683638 L120.038523,74.9253344 L108.197897,73.8484739 L107.200087,70.8558502 L113.11919,63.0411498 C113.349319,62.7383982 113.3362,62.3159043 113.087731,62.0280136 L109.416726,57.75929 L111.057426,55.7160782 L121.331563,56.4339852 L120.308747,71.0591227 L120.308747,71.0591227 Z" id="形状"/></g></g></g></g></g></g></svg>`
const
IMAGE_404
=
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25px" height="23px" viewBox="0 0 25 23" version="1.1"><!-- Generator: Sketch 59 (86127) - https://sketch.com --><title>形状</title><desc>Created with Sketch.</desc><g id="页面-" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="聊天记录-全部" transform="translate(-630.000000, -504.000000)" fill="#C5D4E5" fill-rule="nonzero"><g id="输入区" transform="translate(460.500000, 65.000000)"><g id="聊天" transform="translate(21.000000, 57.000000)"><g id="Group-4" transform="translate(0.000000, 306.000000)"><g id="Group-6" transform="translate(50.500000, 22.000000)"><path d="M115.343089,60.4857235 C115.343089,61.4880836 116.155662,62.300657 117.158022,62.300657 C118.160382,62.300657 118.972956,61.4880836 118.972956,60.4857235 C118.972956,59.4833634 118.160382,58.67079 117.158022,58.67079 C116.155662,58.67079 115.343089,59.4833634 115.343089,60.4857235 L115.343089,60.4857235 Z M122.802062,55.1570787 C122.661436,54.9955729 122.46236,54.8966151 122.248709,54.8820154 L110.74929,54.0777982 C110.48502,54.0573212 110.227916,54.1698422 110.063649,54.3778672 L107.739727,57.2728878 C107.496372,57.5757527 107.503492,58.0090641 107.756667,58.3037701 L111.440578,62.5878198 L107.723595,67.4945933 L108.643161,63.1242335 C108.705387,62.8284556 108.597037,62.5227098 108.362451,62.3321158 L103.536341,58.406213 L105.543255,55.2377424 C105.705781,54.9807089 105.709936,54.6541148 105.554001,54.39303 C105.398066,54.1319451 105.108547,53.9807499 104.805182,54.0019743 L98.7505634,54.4246522 C98.5370214,54.4395331 98.3381511,54.5386828 98.1977496,54.7002656 C98.057348,54.8618484 97.9869302,55.0726122 98.0020041,55.2861406 L99.4087793,75.402057 C99.4240595,75.616038 99.5237815,75.8151664 99.6859762,75.9555738 C99.8481709,76.0959812 100.059531,76.1661479 100.273494,76.1506162 L104.722905,75.8182817 C105.167362,75.7852096 105.500503,75.3980238 105.466624,74.9543734 C105.432745,74.510723 105.048786,74.1719354 104.601909,74.2098473 L100.960749,74.481684 L100.798615,72.1496961 L103.957406,71.8326877 C104.170417,71.8114964 104.366269,71.7065053 104.501829,71.5408371 C104.63739,71.3751689 104.70154,71.1624111 104.680153,70.9494201 C104.633914,70.5069599 104.239744,70.1844247 103.796885,70.2266732 L100.686492,70.5396484 L99.6677098,55.9782353 L103.326616,55.7225313 L101.789972,58.1480891 C101.571262,58.4934105 101.645424,58.9477426 101.962592,59.2055904 L106.963742,63.2726547 L105.482757,70.3129834 C105.458801,70.4366147 105.465167,70.5642102 105.501309,70.6848431 C105.496625,70.778974 105.508642,70.8731908 105.536801,70.9631329 L106.835487,74.8591902 C106.936546,75.1634142 107.208317,75.3788038 107.527582,75.4077034 L120.713679,76.6063662 C120.929641,76.6257531 121.144336,76.5575538 121.309522,76.417093 C121.474707,76.2766322 121.576529,76.0756905 121.592107,75.8594202 L122.998075,55.7426972 C123.012827,55.5292412 122.942339,55.3186449 122.802062,55.1570787 Z M120.308747,71.0591227 L109.908775,70.0596994 C109.695255,70.0358706 109.481187,70.0995268 109.315381,70.2361533 C109.149575,70.3727799 109.046166,70.5707294 109.028733,70.7848661 C109.008287,70.99784 109.07329,71.2102124 109.20944,71.3752556 C109.345589,71.5402989 109.54173,71.6444911 109.754707,71.6649072 L120.196624,72.6683638 L120.038523,74.9253344 L108.197897,73.8484739 L107.200087,70.8558502 L113.11919,63.0411498 C113.349319,62.7383982 113.3362,62.3159043 113.087731,62.0280136 L109.416726,57.75929 L111.057426,55.7160782 L121.331563,56.4339852 L120.308747,71.0591227 L120.308747,71.0591227 Z" id="形状"/></g></g></g></g></g></g></svg>`
;
export
const
enum
FileType
{
export
const
enum
FileType
{
Audio
=
"音频文件"
,
Audio
=
"音频文件"
,
...
@@ -46,7 +46,7 @@ const FILE_EXTENSION_VIDEO = [
...
@@ -46,7 +46,7 @@ const FILE_EXTENSION_VIDEO = [
"asf"
,
"asf"
,
"navi"
,
"navi"
,
"ts"
,
"ts"
,
]
]
;
export
const
FILE_EXTENSION_IMAGE
=
[
export
const
FILE_EXTENSION_IMAGE
=
[
"png"
,
"png"
,
...
@@ -73,12 +73,12 @@ export const FILE_EXTENSION_IMAGE = [
...
@@ -73,12 +73,12 @@ export const FILE_EXTENSION_IMAGE = [
"ai"
,
"ai"
,
"raw"
,
"raw"
,
"webp"
,
"webp"
,
]
]
;
const
FILE_EXTENSION_PPT
=
[
"ppt"
,
"pptx"
,
"key"
]
const
FILE_EXTENSION_PPT
=
[
"ppt"
,
"pptx"
,
"key"
]
;
const
FILE_EXTENSION_TEXT
=
[
"txt"
,
"md"
,
"rtf"
]
const
FILE_EXTENSION_TEXT
=
[
"txt"
,
"md"
,
"rtf"
]
;
const
FILE_EXTENSION_WORD
=
[
"doc"
,
"docx"
,
"page"
]
const
FILE_EXTENSION_WORD
=
[
"doc"
,
"docx"
,
"page"
]
;
const
FILE_EXTENSION_EXCEL
=
[
"xls"
,
"xlsx"
,
"numbers"
]
const
FILE_EXTENSION_EXCEL
=
[
"xls"
,
"xlsx"
,
"numbers"
]
;
const
FILE_EXTENSION_AUDIO
=
[
const
FILE_EXTENSION_AUDIO
=
[
"mp3"
,
"mp3"
,
"cda"
,
"cda"
,
...
@@ -92,14 +92,14 @@ const FILE_EXTENSION_AUDIO = [
...
@@ -92,14 +92,14 @@ const FILE_EXTENSION_AUDIO = [
"rm"
,
"rm"
,
"rmx"
,
"rmx"
,
"midi"
,
"midi"
,
]
]
;
const
FILE_EXTENSION_XMIND
=
[
const
FILE_EXTENSION_XMIND
=
[
"xmap"
,
"xmap"
,
"xmind"
,
"xmind"
,
"mmapmindly"
,
"mmapmindly"
,
"mindnode"
,
"mindnode"
,
"mindmaster"
,
"mindmaster"
,
]
]
;
const
FILE_EXTENSION_COMPRESS
=
[
const
FILE_EXTENSION_COMPRESS
=
[
"zip"
,
"zip"
,
"rar"
,
"rar"
,
...
@@ -110,50 +110,50 @@ const FILE_EXTENSION_COMPRESS = [
...
@@ -110,50 +110,50 @@ const FILE_EXTENSION_COMPRESS = [
"cab"
,
"cab"
,
"jar"
,
"jar"
,
"uue"
,
"uue"
,
]
]
;
export
function
getFileType
(
name
:
string
)
{
export
function
getFileType
(
name
:
string
)
{
if
(
!
name
)
{
if
(
!
name
)
{
return
FileType
.
Others
return
FileType
.
Others
;
}
}
const
splits
=
name
.
split
(
"."
)
const
splits
=
name
.
split
(
"."
)
;
const
extension
=
splits
[
splits
.
length
-
1
].
toLowerCase
()
const
extension
=
splits
[
splits
.
length
-
1
].
toLowerCase
()
;
if
(
FILE_EXTENSION_VIDEO
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_VIDEO
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Video
return
FileType
.
Video
;
}
}
if
(
FILE_EXTENSION_IMAGE
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_IMAGE
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Image
return
FileType
.
Image
;
}
}
if
(
FILE_EXTENSION_AUDIO
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_AUDIO
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Audio
return
FileType
.
Audio
;
}
}
if
(
FILE_EXTENSION_PPT
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_PPT
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Ppt
return
FileType
.
Ppt
;
}
}
if
(
FILE_EXTENSION_TEXT
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_TEXT
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Txt
return
FileType
.
Txt
;
}
}
if
(
FILE_EXTENSION_WORD
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_WORD
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Word
return
FileType
.
Word
;
}
}
if
(
FILE_EXTENSION_EXCEL
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_EXCEL
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Excel
return
FileType
.
Excel
;
}
}
if
(
FILE_EXTENSION_XMIND
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_XMIND
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Xmind
return
FileType
.
Xmind
;
}
}
if
(
FILE_EXTENSION_COMPRESS
.
some
((
i
)
=>
i
===
extension
))
{
if
(
FILE_EXTENSION_COMPRESS
.
some
((
i
)
=>
i
===
extension
))
{
return
FileType
.
Zip
return
FileType
.
Zip
;
}
}
if
(
extension
===
"rp"
)
{
if
(
extension
===
"rp"
)
{
return
FileType
.
Rp
return
FileType
.
Rp
;
}
}
if
(
extension
===
"pdf"
)
{
if
(
extension
===
"pdf"
)
{
return
FileType
.
Pdf
return
FileType
.
Pdf
;
}
}
return
FileType
.
Others
return
FileType
.
Others
;
}
}
const
type2SvgMapping
=
new
Map
<
FileType
,
()
=>
string
>
([
const
type2SvgMapping
=
new
Map
<
FileType
,
()
=>
string
>
([
...
@@ -170,36 +170,36 @@ const type2SvgMapping = new Map<FileType, () => string>([
...
@@ -170,36 +170,36 @@ const type2SvgMapping = new Map<FileType, () => string>([
[
FileType
.
Video
,
()
=>
SVG_VIDEO
],
[
FileType
.
Video
,
()
=>
SVG_VIDEO
],
[
FileType
.
Word
,
()
=>
SVG_WORD
],
[
FileType
.
Word
,
()
=>
SVG_WORD
],
[
FileType
.
Image_404
,
()
=>
IMAGE_404
],
[
FileType
.
Image_404
,
()
=>
IMAGE_404
],
])
])
;
export
function
getSvg
(
type
:
FileType
)
{
export
function
getSvg
(
type
:
FileType
)
{
const
action
=
type2SvgMapping
.
get
(
type
)
const
action
=
type2SvgMapping
.
get
(
type
)
;
return
(
action
&&
action
())
||
""
return
(
action
&&
action
())
||
""
;
}
}
export
function
isAudio
(
name
:
string
)
{
export
function
isAudio
(
name
:
string
)
{
return
name
&&
FILE_EXTENSION_AUDIO
.
some
((
i
)
=>
name
.
endsWith
(
i
))
return
name
&&
FILE_EXTENSION_AUDIO
.
some
((
i
)
=>
name
.
endsWith
(
i
))
;
}
}
export
function
isVideo
(
name
:
string
)
{
export
function
isVideo
(
name
:
string
)
{
return
name
&&
FILE_EXTENSION_VIDEO
.
some
((
i
)
=>
name
.
endsWith
(
i
))
return
name
&&
FILE_EXTENSION_VIDEO
.
some
((
i
)
=>
name
.
endsWith
(
i
))
;
}
}
export
function
isImage
(
name
:
string
)
{
export
function
isImage
(
name
:
string
)
{
return
name
&&
FILE_EXTENSION_IMAGE
.
some
((
i
)
=>
name
.
endsWith
(
i
))
return
name
&&
FILE_EXTENSION_IMAGE
.
some
((
i
)
=>
name
.
endsWith
(
i
))
;
}
}
/**
/**
* 最大图片文件大小
* 最大图片文件大小
*/
*/
export
const
MAX_IMAGE_SIZE
=
5
*
1024
*
1024
export
const
MAX_IMAGE_SIZE
=
5
*
1024
*
1024
;
export
const
MAX_IMAGE_SIZE_STRING
=
"5MB"
export
const
MAX_IMAGE_SIZE_STRING
=
"5MB"
;
export
const
MESSAGE_IMAGE_TOO_LARGE
=
`您发送的图片大小超过
${
MAX_IMAGE_SIZE_STRING
}
。`
export
const
MESSAGE_IMAGE_TOO_LARGE
=
`您发送的图片大小超过
${
MAX_IMAGE_SIZE_STRING
}
。`
;
export
const
MESSAGE_FILE_EMPTY
=
"不能发送空文件。"
export
const
MESSAGE_FILE_EMPTY
=
"不能发送空文件。"
;
/**
/**
* 最大文件大小
* 最大文件大小
*/
*/
export
const
MAX_FILE_SIZE
=
20
*
1024
*
1024
export
const
MAX_FILE_SIZE
=
20
*
1024
*
1024
;
export
const
MAX_FILE_SIZE_STRING
=
"20MB"
export
const
MAX_FILE_SIZE_STRING
=
"20MB"
;
export
const
MESSAGE_FILE_TOO_LARGE
=
`您发送的文件大小超过
${
MAX_FILE_SIZE_STRING
}
。`
export
const
MESSAGE_FILE_TOO_LARGE
=
`您发送的文件大小超过
${
MAX_FILE_SIZE_STRING
}
。`
;
model/index.ts
View file @
84b48c2e
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
;
export
interface
Chat
{
export
interface
Chat
{
chat_id
:
number
chat_id
:
number
;
title
:
string
title
:
string
;
service_id
:
number
service_id
:
number
;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
start_time
:
number
start_time
:
number
;
end_time
:
number
end_time
:
number
;
is_finish
:
boolean
is_finish
:
boolean
;
msg_id
:
number
msg_id
:
number
;
last_cs_eid
:
string
last_cs_eid
:
string
;
first_cs_eid
:
string
first_cs_eid
:
string
;
last_msg_eid
:
string
last_msg_eid
:
string
;
last_msg_name
:
string
last_msg_name
:
string
;
last_msg_ts
:
number
last_msg_ts
:
number
;
last_online_time
:
number
last_online_time
:
number
;
msg_type
:
string
msg_type
:
string
;
msg
:
string
msg
:
string
;
customer_name
:
string
customer_name
:
string
;
customer_mobile
:
string
customer_mobile
:
string
;
customer_avatar_url
:
string
customer_avatar_url
:
string
;
customer_online
:
boolean
customer_online
:
boolean
;
customer_eid
:
string
customer_eid
:
string
;
origin
:
string
origin
:
string
;
unread_msg_count
:
number
unread_msg_count
:
number
;
}
}
export
type
TokenStringGetter
=
()
=>
Promise
<
string
>
export
type
TokenStringGetter
=
()
=>
Promise
<
string
>
...
@@ -33,174 +33,174 @@ export interface ChatOption {
...
@@ -33,174 +33,174 @@ export interface ChatOption {
/**
/**
* 企业token [商户端使用,用户端和移动端不需要]
* 企业token [商户端使用,用户端和移动端不需要]
*/
*/
enterpriseTokenString
?:
TokenStringGetter
enterpriseTokenString
?:
TokenStringGetter
;
/**
/**
* 个人token
* 个人token
*/
*/
userTokenString
:
TokenStringGetter
userTokenString
:
TokenStringGetter
;
/**
/**
* 长链接chat sdk地址
* 长链接chat sdk地址
*/
*/
webSocketUri
:
string
webSocketUri
:
string
;
sdk
:
()
=>
UniplatSdk
sdk
:
()
=>
UniplatSdk
;
orgId
:
()
=>
string
|
number
orgId
:
()
=>
string
|
number
;
logger
?:
ChatServiceLogger
logger
?:
ChatServiceLogger
;
}
}
export
interface
ChatServiceLogger
{
export
interface
ChatServiceLogger
{
enabled
:
boolean
enabled
:
boolean
;
debug
(
message
?:
any
,
...
optionalParams
:
any
[]):
void
debug
(
message
?:
any
,
...
optionalParams
:
any
[]):
void
;
info
(
message
?:
any
,
...
optionalParams
:
any
[]):
void
info
(
message
?:
any
,
...
optionalParams
:
any
[]):
void
;
error
(
message
?:
any
,
...
optionalParams
:
any
[]):
void
error
(
message
?:
any
,
...
optionalParams
:
any
[]):
void
;
}
}
export
type
ChatListRequestList
=
{
export
type
ChatListRequestList
=
{
list
:
Chat
[]
list
:
Chat
[]
;
total
:
number
total
:
number
;
}
}
export
interface
Message
{
export
interface
Message
{
at_id
:
string
at_id
:
string
;
chat_id
:
number
chat_id
:
number
;
create_time
:
number
create_time
:
number
;
eid
:
string
eid
:
string
;
id
:
number
id
:
number
;
is_open
:
boolean
is_open
:
boolean
;
is_read
:
boolean
is_read
:
boolean
;
like
:
boolean
like
:
boolean
;
like_count
:
number
like_count
:
number
;
msg
:
string
msg
:
string
;
oid
:
string
oid
:
string
;
read_count
:
number
read_count
:
number
;
ref_id
:
number
ref_id
:
number
;
status
:
number
status
:
number
;
total_read_count
:
number
total_read_count
:
number
;
ts
:
number
ts
:
number
;
type
:
"text"
|
"image"
|
"file"
|
"video"
|
"voice"
type
:
"text"
|
"image"
|
"file"
|
"video"
|
"voice"
;
update_time
:
number
update_time
:
number
;
url
:
string
url
:
string
;
}
}
export
type
MessageRequestResult
=
readonly
Message
[]
export
type
MessageRequestResult
=
readonly
Message
[]
export
interface
CreateChatByServicemanRequestResult
{
export
interface
CreateChatByServicemanRequestResult
{
id
:
number
id
:
number
;
org_id
:
string
org_id
:
string
;
uid
:
string
uid
:
string
;
oid
:
string
oid
:
string
;
eid
:
string
eid
:
string
;
type
:
string
type
:
string
;
title
:
string
title
:
string
;
app_id
:
string
app_id
:
string
;
tag
:
string
tag
:
string
;
msg_id
:
number
msg_id
:
number
;
ext
:
string
ext
:
string
;
exit_msg_id
:
number
exit_msg_id
:
number
;
is_exited
:
boolean
is_exited
:
boolean
;
dnd
:
number
dnd
:
number
;
is_top
:
boolean
is_top
:
boolean
;
label
:
string
label
:
string
;
join_msg_id
:
number
join_msg_id
:
number
;
last_read_msg_id
:
number
last_read_msg_id
:
number
;
biz_id
:
string
biz_id
:
string
;
business_data
:
string
business_data
:
string
;
is_finish
:
boolean
is_finish
:
boolean
;
is_deleted
:
boolean
is_deleted
:
boolean
;
is_remove
:
boolean
is_remove
:
boolean
;
member_type
:
number
member_type
:
number
;
ref_id
:
number
ref_id
:
number
;
unread_msg_count
:
number
unread_msg_count
:
number
;
at_me
:
boolean
at_me
:
boolean
;
at_all
:
boolean
at_all
:
boolean
;
last_login_oid
:
string
last_login_oid
:
string
;
owner_oid
:
string
owner_oid
:
string
;
owner_eid
:
string
owner_eid
:
string
;
is_act
:
boolean
is_act
:
boolean
;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
last_msg_ts
:
number
last_msg_ts
:
number
;
members_updated
:
number
members_updated
:
number
;
user_updated
:
number
user_updated
:
number
;
}
}
export
type
ChatMemberExtraInfo
=
{
export
type
ChatMemberExtraInfo
=
{
name
?:
string
name
?:
string
;
phone
?:
string
phone
?:
string
;
}
}
export
interface
ChatMember
{
export
interface
ChatMember
{
at_all
:
boolean
at_all
:
boolean
;
at_me
:
boolean
at_me
:
boolean
;
chat_id
:
number
chat_id
:
number
;
create_time
:
number
create_time
:
number
;
dnd
:
number
dnd
:
number
;
eid
:
string
eid
:
string
;
exit_msg_id
:
number
exit_msg_id
:
number
;
id
:
number
id
:
number
;
is_act
:
boolean
is_act
:
boolean
;
is_exited
:
boolean
is_exited
:
boolean
;
is_remove
:
boolean
is_remove
:
boolean
;
is_top
:
boolean
is_top
:
boolean
;
join_msg_id
:
number
join_msg_id
:
number
;
label
:
string
label
:
string
;
nickname
:
string
nickname
:
string
;
oid
:
string
oid
:
string
;
org_id
:
string
org_id
:
string
;
type
:
number
type
:
number
;
uid
:
string
uid
:
string
;
unread_msg_count
:
number
unread_msg_count
:
number
;
update_time
:
number
update_time
:
number
;
}
}
export
type
ChatMembers
=
readonly
ChatMember
[]
export
type
ChatMembers
=
readonly
ChatMember
[]
export
interface
ServiceMan
{
export
interface
ServiceMan
{
id
:
number
id
:
number
;
oid
:
string
oid
:
string
;
eid
:
string
eid
:
string
;
is_deleted
:
boolean
is_deleted
:
boolean
;
delete_time
:
number
delete_time
:
number
;
delete_eid
:
string
delete_eid
:
string
;
service_id
:
number
service_id
:
number
;
type
:
number
type
:
number
;
name
:
string
name
:
string
;
mobile
:
string
mobile
:
string
;
email
:
string
email
:
string
;
description
:
string
description
:
string
;
avatar_url
:
string
avatar_url
:
string
;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
chat_count
:
number
chat_count
:
number
;
status
:
number
status
:
number
;
}
}
export
type
AllServiceMan
=
ServiceMan
[]
export
type
AllServiceMan
=
ServiceMan
[]
export
interface
OneWhoReadMessage
{
export
interface
OneWhoReadMessage
{
create_time
:
number
create_time
:
number
;
eid
:
string
eid
:
string
;
id
:
number
id
:
number
;
is_read
:
boolean
is_read
:
boolean
;
like
:
boolean
like
:
boolean
;
like_time
:
number
like_time
:
number
;
oid
:
string
oid
:
string
;
owner_id
:
number
owner_id
:
number
;
read_time
:
number
read_time
:
number
;
target_id
:
number
target_id
:
number
;
type
:
number
type
:
number
;
uid
:
string
uid
:
string
;
}
}
export
interface
GetAllChatListParams
{
export
interface
GetAllChatListParams
{
service_id
:
number
service_id
:
number
;
user_info
?:
string
user_info
?:
string
;
origin
?:
string
origin
?:
string
;
user_id
?:
string
user_id
?:
string
;
is_finish
?:
boolean
|
-
1
|
number
is_finish
?:
boolean
|
-
1
|
number
;
chat_update_time_start
?:
string
chat_update_time_start
?:
string
;
chat_update_time_end
?:
string
chat_update_time_end
?:
string
;
page
?:
number
page
?:
number
;
page_size
?:
number
page_size
?:
number
;
last_cs_eid
?:
string
|
number
last_cs_eid
?:
string
|
number
;
}
}
service/emoji.ts
View file @
84b48c2e
import
{
TokenStringGetter
}
from
"../model"
import
{
TokenStringGetter
}
from
"../model"
;
import
{
invokeGet
}
from
"./request"
import
{
invokeGet
}
from
"./request"
;
export
class
EmojiService
{
export
class
EmojiService
{
private
static
ready
=
false
private
static
ready
=
false
...
@@ -11,39 +12,39 @@ export class EmojiService {
...
@@ -11,39 +12,39 @@ export class EmojiService {
this
.
url
=
this
.
url
=
process
.
env
.
NODE_ENV
===
"production"
process
.
env
.
NODE_ENV
===
"production"
?
"https://file.teammix.com"
?
"https://file.teammix.com"
:
""
:
""
;
}
}
public
async
getEmoji
()
{
public
async
getEmoji
()
{
const
token
=
await
EmojiService
.
token
()
const
token
=
await
EmojiService
.
token
()
;
return
invokeGet
<
{
return
invokeGet
<
{
type
:
string
type
:
string
;
list
:
{
list
:
{
code
:
string
code
:
string
;
name
:
string
name
:
string
;
emoji_chars
:
string
emoji_chars
:
string
;
}[]
}[]
;
}
>
(
`
${
this
.
url
}
/v1/emoji/list?type=chat`
,
token
)
}
>
(
`
${
this
.
url
}
/v1/emoji/list?type=chat`
,
token
)
;
}
}
public
static
onReady
(
callback
:
()
=>
void
)
{
public
static
onReady
(
callback
:
()
=>
void
)
{
if
(
EmojiService
.
ready
)
{
if
(
EmojiService
.
ready
)
{
callback
()
callback
()
;
}
else
{
}
else
{
EmojiService
.
beforeReadyCacheAction
.
push
(
callback
)
EmojiService
.
beforeReadyCacheAction
.
push
(
callback
)
;
}
}
}
}
private
static
fireBeforeReadyAction
()
{
private
static
fireBeforeReadyAction
()
{
for
(
const
item
of
EmojiService
.
beforeReadyCacheAction
)
{
for
(
const
item
of
EmojiService
.
beforeReadyCacheAction
)
{
item
()
item
()
;
}
}
EmojiService
.
beforeReadyCacheAction
=
[]
EmojiService
.
beforeReadyCacheAction
=
[]
;
}
}
public
static
raiseOnReady
(
token
:
TokenStringGetter
)
{
public
static
raiseOnReady
(
token
:
TokenStringGetter
)
{
EmojiService
.
ready
=
true
EmojiService
.
ready
=
true
;
EmojiService
.
token
=
token
EmojiService
.
token
=
token
;
EmojiService
.
fireBeforeReadyAction
()
EmojiService
.
fireBeforeReadyAction
()
;
}
}
}
}
service/request.ts
View file @
84b48c2e
import
Axios
from
"axios"
import
Axios
from
"axios"
;
import
qs
from
"qs"
import
qs
from
"qs"
;
export
function
buildConfig
(
token
:
string
,
url
:
string
)
{
export
function
buildConfig
(
token
:
string
,
url
:
string
)
{
if
(
url
&&
url
.
includes
(
"/general"
))
{
if
(
url
&&
url
.
includes
(
"/general"
))
{
return
{
headers
:
{
Authorization
:
token
,
CurrentOrg
:
this
.
station
}
}
return
{
headers
:
{
Authorization
:
token
,
CurrentOrg
:
this
.
station
}
}
;
}
}
return
{
headers
:
{
Authorization
:
token
}
}
return
{
headers
:
{
Authorization
:
token
}
}
;
}
}
export
function
invokeGet
<
T
>
(
url
:
string
,
token
:
string
)
{
export
function
invokeGet
<
T
>
(
url
:
string
,
token
:
string
)
{
return
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
Axios
.
get
(
url
,
buildConfig
(
token
,
url
))
Axios
.
get
(
url
,
buildConfig
(
token
,
url
))
.
then
((
r
)
=>
{
.
then
((
r
)
=>
{
if
(
r
?.
data
?.
data
!==
undefined
)
{
if
(
r
?.
data
?.
data
!==
undefined
)
{
return
resolve
(
r
.
data
.
data
as
T
)
return
resolve
(
r
.
data
.
data
as
T
)
;
}
}
reject
(
r
)
reject
(
r
)
;
})
})
.
catch
(
reject
)
.
catch
(
reject
)
;
})
})
;
}
}
export
const
enum
DataType
{
export
const
enum
DataType
{
...
@@ -32,21 +32,21 @@ export function invokePost<T>(
...
@@ -32,21 +32,21 @@ export function invokePost<T>(
data
:
any
,
data
:
any
,
dataType
=
DataType
.
Json
dataType
=
DataType
.
Json
):
Promise
<
T
>
{
):
Promise
<
T
>
{
let
postData
:
any
=
null
let
postData
:
any
=
null
;
if
(
dataType
===
DataType
.
Qs
)
{
if
(
dataType
===
DataType
.
Qs
)
{
postData
=
qs
.
stringify
(
data
)
postData
=
qs
.
stringify
(
data
)
;
}
else
{
}
else
{
postData
=
data
postData
=
data
;
}
}
return
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
T
>
((
resolve
,
reject
)
=>
{
Axios
.
post
(
url
,
postData
,
buildConfig
(
token
,
url
))
Axios
.
post
(
url
,
postData
,
buildConfig
(
token
,
url
))
.
then
((
r
)
=>
{
.
then
((
r
)
=>
{
if
(
r
?.
data
?.
data
!==
undefined
)
{
if
(
r
?.
data
?.
data
!==
undefined
)
{
return
resolve
(
r
.
data
.
data
as
T
)
return
resolve
(
r
.
data
.
data
as
T
)
;
}
}
reject
(
r
)
reject
(
r
)
;
})
})
.
catch
(
reject
)
.
catch
(
reject
)
;
})
})
;
}
}
service/tools.ts
View file @
84b48c2e
export
function
isAccessibleUrl
(
url
:
string
)
{
export
function
isAccessibleUrl
(
url
:
string
)
{
return
url
&&
(
url
.
startsWith
(
"blob"
)
||
url
.
startsWith
(
"http"
))
return
url
&&
(
url
.
startsWith
(
"blob"
)
||
url
.
startsWith
(
"http"
))
;
}
}
service/upload.ts
View file @
84b48c2e
import
Vue
from
"vue"
import
Axios
from
"axios"
;
import
{
invokePost
}
from
"./request"
import
Vue
from
"vue"
;
import
Axios
from
"axios"
import
tokenManager
from
"../xim/token"
import
tokenManager
from
"../xim/token"
;
const
orgId
=
()
=>
Vue
.
prototype
.
global
.
org
?.
id
??
"0"
import
{
invokePost
}
from
"./request"
;
const
orgId
=
()
=>
Vue
.
prototype
.
global
.
org
?.
id
??
"0"
;
export
async
function
uploadFile
(
export
async
function
uploadFile
(
file
:
File
,
file
:
File
,
chatId
:
number
,
chatId
:
number
,
width
?:
number
,
width
?:
number
,
height
?:
number
height
?:
number
)
{
)
{
const
splits
=
file
.
name
.
split
(
"."
)
const
splits
=
file
.
name
.
split
(
"."
)
;
const
parameter
=
{
const
parameter
=
{
file_name
:
file
.
name
,
file_name
:
file
.
name
,
size
:
file
.
size
,
size
:
file
.
size
,
...
@@ -18,30 +20,30 @@ export async function uploadFile(
...
@@ -18,30 +20,30 @@ export async function uploadFile(
owner_id
:
chatId
,
owner_id
:
chatId
,
org_id
:
orgId
(),
org_id
:
orgId
(),
ext_type
:
splits
[
splits
.
length
-
1
],
ext_type
:
splits
[
splits
.
length
-
1
],
}
}
;
if
(
width
&&
height
)
{
if
(
width
&&
height
)
{
Object
.
assign
(
parameter
,
{
width
,
height
})
Object
.
assign
(
parameter
,
{
width
,
height
})
;
}
}
const
token
=
await
invokePost
<
{
const
token
=
await
invokePost
<
{
url_id
:
string
url_id
:
string
;
sign
:
string
sign
:
string
;
domain
:
string
domain
:
string
;
file_name
:
string
file_name
:
string
;
id
:
number
id
:
number
;
}
>
(
"/xchat/personal/upload_token"
,
await
tokenManager
.
getToken
(),
parameter
)
}
>
(
"/xchat/personal/upload_token"
,
await
tokenManager
.
getToken
(),
parameter
)
;
const
uri
=
`
${
token
.
domain
}
/gw/file/upload`
const
uri
=
`
${
token
.
domain
}
/gw/file/upload`
;
const
form
=
new
FormData
()
const
form
=
new
FormData
()
;
form
.
append
(
"file"
,
file
)
form
.
append
(
"file"
,
file
)
;
form
.
append
(
"fileId"
,
token
.
url_id
)
form
.
append
(
"fileId"
,
token
.
url_id
)
;
form
.
append
(
"fileSize"
,
file
.
size
.
toString
())
form
.
append
(
"fileSize"
,
file
.
size
.
toString
())
;
form
.
append
(
"orgId"
,
orgId
())
form
.
append
(
"orgId"
,
orgId
())
;
form
.
append
(
"sign"
,
token
.
sign
)
form
.
append
(
"sign"
,
token
.
sign
)
;
const
result
=
await
Axios
.
post
(
uri
,
form
,
{
const
result
=
await
Axios
.
post
(
uri
,
form
,
{
headers
:
{
"Content-Type"
:
"multipart/form-data"
},
headers
:
{
"Content-Type"
:
"multipart/form-data"
},
})
})
;
if
(
result
&&
result
.
data
&&
result
.
data
.
errcode
===
0
)
{
if
(
result
&&
result
.
data
&&
result
.
data
.
errcode
===
0
)
{
return
token
.
url_id
return
token
.
url_id
;
}
}
return
""
return
""
;
}
}
store/index.ts
View file @
84b48c2e
import
{
Module
}
from
"vuex"
import
{
Module
}
from
"vuex"
;
import
{
RootStoreState
}
from
"@/store/model"
import
{
ChatMember
}
from
"../model"
import
{
ChatStore
,
ChatStoreState
,
ChatStatus
,
ChatMemberType
}
from
"./model"
import
xim
,
{
ChatNotifyListener
}
from
"../xim/xim"
import
{
unique
}
from
"../utils"
import
Chat
from
"../xim"
import
{
decode
}
from
"../utils/jwt"
import
chatType
from
"../xim/chat-type"
import
{
isAccessibleUrl
}
from
"../service/tools"
import
chat
from
"../xim/"
export
const
ns
=
ChatStore
.
ns
import
{
ChatMember
}
from
"../model"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
unique
}
from
"../utils"
;
import
{
decode
}
from
"../utils/jwt"
;
import
Chat
from
"../xim"
;
import
chat
from
"../xim/"
;
import
chatType
from
"../xim/chat-type"
;
import
xim
,
{
ChatNotifyListener
}
from
"../xim/xim"
;
const
sdk
=
chat
.
getSdk
import
{
ChatMemberType
,
ChatStatus
,
ChatStore
,
ChatStoreState
}
from
"./model"
;
const
UniplatChatModelName
=
"UniplatChat"
const
model
=
()
=>
sdk
().
model
(
UniplatChatModelName
)
import
{
RootStoreState
}
from
"@/store/model"
;
const
orgId
=
chat
.
getOrgId
export
const
ns
=
ChatStore
.
ns
;
const
sdk
=
chat
.
getSdk
;
const
UniplatChatModelName
=
"UniplatChat"
;
const
model
=
()
=>
sdk
().
model
(
UniplatChatModelName
);
const
orgId
=
chat
.
getOrgId
;
const
getMyinfo
=
(
function
()
{
const
getMyinfo
=
(
function
()
{
let
data
let
data
;
return
async
()
=>
{
return
async
()
=>
{
if
(
data
!=
null
)
return
data
if
(
data
!=
null
)
return
data
;
data
=
sdk
().
getUserInfo
()
data
=
sdk
().
getUserInfo
()
;
return
data
return
data
;
}
}
;
})()
})()
;
function
uniqueMessages
(
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
)
;
})
})
;
}
}
function
filterMessages
(
function
filterMessages
(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
,
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
,
...
@@ -38,35 +41,35 @@ function filterMessages(
...
@@ -38,35 +41,35 @@ function filterMessages(
)
{
)
{
return
uniqueMessages
(
Array
.
from
(
messages
)).
filter
(
return
uniqueMessages
(
Array
.
from
(
messages
)).
filter
(
(
k
)
=>
k
.
chat_id
===
chatid
(
k
)
=>
k
.
chat_id
===
chatid
)
)
;
}
}
const
removeRegisterChatEvents
:
(()
=>
void
)[]
=
[]
const
removeRegisterChatEvents
:
(()
=>
void
)[]
=
[]
;
async
function
preCacheImgs
(
msgs
:
any
[])
{
async
function
preCacheImgs
(
msgs
:
any
[])
{
await
Promise
.
all
(
await
Promise
.
all
(
msgs
.
map
((
k
)
=>
{
msgs
.
map
((
k
)
=>
{
return
new
Promise
((
done
:
(
p
:
void
)
=>
void
)
=>
{
return
new
Promise
((
done
:
(
p
:
void
)
=>
void
)
=>
{
if
(
k
.
type
===
"image"
)
{
if
(
k
.
type
===
"image"
)
{
const
msg
=
JSON
.
parse
(
k
.
msg
)
const
msg
=
JSON
.
parse
(
k
.
msg
)
;
const
url
=
msg
.
url
const
url
=
msg
.
url
;
if
(
!
isAccessibleUrl
(
url
))
{
if
(
!
isAccessibleUrl
(
url
))
{
done
()
done
()
;
}
}
if
(
url
&&
isAccessibleUrl
(
url
))
{
if
(
url
&&
isAccessibleUrl
(
url
))
{
const
preCache
=
new
Image
()
const
preCache
=
new
Image
()
;
preCache
.
src
=
url
preCache
.
src
=
url
;
preCache
.
onload
=
()
=>
done
()
preCache
.
onload
=
()
=>
done
()
;
setTimeout
(
done
,
2000
)
setTimeout
(
done
,
2000
)
;
}
else
{
}
else
{
done
()
done
()
;
}
}
}
else
{
}
else
{
done
()
done
()
;
}
}
})
})
;
})
})
)
)
;
}
}
export
default
{
export
default
{
namespaced
:
true
,
namespaced
:
true
,
...
@@ -90,121 +93,121 @@ export default {
...
@@ -90,121 +93,121 @@ export default {
}),
}),
mutations
:
{
mutations
:
{
[
ChatStore
.
MUTATION_SHOW_CHAT
](
state
)
{
[
ChatStore
.
MUTATION_SHOW_CHAT
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]
=
true
state
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]
=
true
;
},
},
[
ChatStore
.
MUTATION_HIDE_CHAT
](
state
)
{
[
ChatStore
.
MUTATION_HIDE_CHAT
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]
=
false
state
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]
=
false
;
},
},
[
ChatStore
.
MUTATION_SHOW_CHAT_CREATOR
](
state
)
{
[
ChatStore
.
MUTATION_SHOW_CHAT_CREATOR
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
]
=
true
state
[
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
]
=
true
;
},
},
[
ChatStore
.
MUTATION_HIDE_CHAT_CREATOR
](
state
)
{
[
ChatStore
.
MUTATION_HIDE_CHAT_CREATOR
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
]
=
false
state
[
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
]
=
false
;
},
},
[
ChatStore
.
MUTATION_SAVE_CHAT_LIST
](
[
ChatStore
.
MUTATION_SAVE_CHAT_LIST
](
state
,
state
,
data
:
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
data
:
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
)
{
)
{
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
]
=
data
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
]
=
data
;
},
},
[
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
null
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
null
;
},
},
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_ID
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_ID
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
=
null
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
=
null
;
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_ID
](
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_ID
](
state
,
state
,
id
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
id
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
{
)
{
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
=
Number
(
id
)
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
=
Number
(
id
)
;
},
},
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_VERSION
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_VERSION
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
=
null
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
=
null
;
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_VERSION
](
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_VERSION
](
state
,
state
,
v
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
v
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
)
{
)
{
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
=
v
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
=
v
;
},
},
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_UNIPLAT_ID
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_UNIPLAT_ID
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
=
null
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
=
null
;
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
](
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
](
state
,
state
,
id
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
id
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
)
{
)
{
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
=
id
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
=
id
;
},
},
[
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
](
[
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
](
state
,
state
,
data
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
data
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
)
{
)
{
const
old
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
||
[]
const
old
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
||
[]
;
const
chatid
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatid
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatid
==
null
)
return
if
(
chatid
==
null
)
return
;
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...
old
,
...(
data
||
[])],
chatid
)
filterMessages
([...
old
,
...(
data
||
[])],
chatid
)
)
)
;
},
},
[
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
(
token
)
;
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
eid
.
eid
||
eid
.
sub
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
eid
.
eid
||
eid
.
sub
;
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
eid
.
sub
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
eid
.
sub
;
})
})
;
},
},
[
ChatStore
.
MUTATION_CLEAR_MYSELF_ID
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_MYSELF_ID
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
null
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
null
;
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
null
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
null
;
},
},
[
ChatStore
.
MUTATION_SET_CHAT_SOURCE
](
[
ChatStore
.
MUTATION_SET_CHAT_SOURCE
](
state
,
state
,
data
:
ChatStore
.
STATE_CHAT_SOURCE
data
:
ChatStore
.
STATE_CHAT_SOURCE
)
{
)
{
state
[
ChatStore
.
STATE_CHAT_SOURCE
]
=
data
state
[
ChatStore
.
STATE_CHAT_SOURCE
]
=
data
;
},
},
[
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
](
[
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
](
state
,
state
,
data
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
data
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
)
{
)
{
const
old
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
||
[]
const
old
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
||
[]
;
const
chatid
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatid
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatid
==
null
)
return
if
(
chatid
==
null
)
return
;
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...(
data
||
[]),
...
old
],
chatid
)
filterMessages
([...(
data
||
[]),
...
old
],
chatid
)
)
)
;
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
](
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
](
state
,
state
,
data
:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
data
:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
)
{
)
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
=
Object
.
freeze
(
data
)
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
=
Object
.
freeze
(
data
)
;
},
},
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
](
state
)
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
=
null
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
=
null
;
},
},
[
ChatStore
.
MUTATION_SAVE_CHAT_TITLE
](
[
ChatStore
.
MUTATION_SAVE_CHAT_TITLE
](
state
,
state
,
data
:
ChatStore
.
STATE_CURRENT_CHAT_TITLE
data
:
ChatStore
.
STATE_CURRENT_CHAT_TITLE
)
{
)
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]
=
data
state
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]
=
data
;
},
},
[
ChatStore
.
MUTATION_CLEAR_CHAT_TITLE
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_CHAT_TITLE
](
state
)
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]
=
""
state
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]
=
""
;
},
},
[
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
](
state
)
{
[
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
](
state
)
{
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]()
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]()
;
},
},
[
ChatStore
.
MUTATION_SAVE_FUNC_SCROLL_TO_BOTTOM
](
[
ChatStore
.
MUTATION_SAVE_FUNC_SCROLL_TO_BOTTOM
](
state
,
state
,
data
:
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
data
:
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
)
{
)
{
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]
=
data
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]
=
data
;
},
},
[
ChatStore
.
MUTATION_CLEAR_FUNC_SCROLL_TO_BOTTOM
](
state
)
{
[
ChatStore
.
MUTATION_CLEAR_FUNC_SCROLL_TO_BOTTOM
](
state
)
{
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]
=
()
=>
true
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]
=
()
=>
true
;
},
},
[
ChatStore
.
MUTATION_APPEND_SENDING_MESSAGE
]:
(
[
ChatStore
.
MUTATION_APPEND_SENDING_MESSAGE
]:
(
state
,
state
,
...
@@ -212,15 +215,15 @@ export default {
...
@@ -212,15 +215,15 @@ export default {
)
=>
{
)
=>
{
const
current
=
state
[
const
current
=
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
as
ChatStore
.
STATE_CHAT_SENDING_MESSAGE
[]
]
as
ChatStore
.
STATE_CHAT_SENDING_MESSAGE
[]
;
if
(
current
)
{
if
(
current
)
{
current
.
push
(
payload
)
current
.
push
(
payload
)
;
}
}
preCacheImgs
([
payload
]).
then
(()
=>
{
preCacheImgs
([
payload
]).
then
(()
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]()
state
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]()
;
},
100
)
},
100
)
;
})
})
;
},
},
[
ChatStore
.
MUTATION_REMOVE_SENDING_MESSAGE
]:
(
[
ChatStore
.
MUTATION_REMOVE_SENDING_MESSAGE
]:
(
state
,
state
,
...
@@ -228,12 +231,12 @@ export default {
...
@@ -228,12 +231,12 @@ export default {
)
=>
{
)
=>
{
const
current
=
state
[
const
current
=
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
as
ChatStore
.
STATE_CHAT_SENDING_MESSAGE
[]
]
as
ChatStore
.
STATE_CHAT_SENDING_MESSAGE
[]
;
if
(
current
)
{
if
(
current
)
{
const
target
=
current
.
find
((
i
)
=>
i
.
id
===
payload
)
const
target
=
current
.
find
((
i
)
=>
i
.
id
===
payload
)
;
if
(
target
)
{
if
(
target
)
{
const
index
=
current
.
indexOf
(
target
)
const
index
=
current
.
indexOf
(
target
)
;
current
.
splice
(
index
,
1
)
current
.
splice
(
index
,
1
)
;
}
}
}
}
},
},
...
@@ -243,46 +246,46 @@ export default {
...
@@ -243,46 +246,46 @@ export default {
)
=>
{
)
=>
{
const
current
=
state
[
const
current
=
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
as
ChatStore
.
STATE_CHAT_SENDING_MESSAGE
[]
]
as
ChatStore
.
STATE_CHAT_SENDING_MESSAGE
[]
;
if
(
current
)
{
if
(
current
)
{
const
target
=
current
.
find
((
i
)
=>
i
.
id
===
payload
)
const
target
=
current
.
find
((
i
)
=>
i
.
id
===
payload
)
;
if
(
target
)
{
if
(
target
)
{
target
.
status
=
-
1
target
.
status
=
-
1
;
}
}
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
,
payload
:
Parameters
<
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
>
[
0
]
payload
:
Parameters
<
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
>
[
0
]
)
=>
{
)
=>
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatId
==
null
)
return
if
(
chatId
==
null
)
return
;
if
(
payload
.
chat_id
!==
chatId
)
return
if
(
payload
.
chat_id
!==
chatId
)
return
;
const
arr
=
state
[
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
]
const
arr
=
state
[
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
]
;
const
eid
=
payload
.
eid
const
eid
=
payload
.
eid
;
if
(
eid
===
state
[
ChatStore
.
STATE_CHAT_MY_ID
])
return
if
(
eid
===
state
[
ChatStore
.
STATE_CHAT_MY_ID
])
return
;
if
(
arr
.
includes
(
eid
))
{
if
(
arr
.
includes
(
eid
))
{
window
.
clearTimeout
(
setTimeoutId
[
eid
])
window
.
clearTimeout
(
setTimeoutId
[
eid
])
;
}
else
{
}
else
{
arr
.
push
(
eid
)
arr
.
push
(
eid
)
;
}
}
setTimeoutId
[
eid
]
=
window
.
setTimeout
(()
=>
{
setTimeoutId
[
eid
]
=
window
.
setTimeout
(()
=>
{
arr
.
splice
(
arr
.
indexOf
(
eid
),
1
)
arr
.
splice
(
arr
.
indexOf
(
eid
),
1
)
;
},
4000
)
},
4000
)
;
}
}
;
})(),
})(),
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_INPUTING
]:
(
state
)
=>
{
[
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_INPUTING
]:
(
state
)
=>
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
]
=
[]
state
[
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
]
=
[]
;
},
},
[
ChatStore
.
MUTATION_INITING_CHAT
]:
(
state
)
=>
{
[
ChatStore
.
MUTATION_INITING_CHAT
]:
(
state
)
=>
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]
=
true
state
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]
=
true
;
},
},
[
ChatStore
.
MUTATION_INITING_CHAT_DONE
]:
(
state
)
=>
{
[
ChatStore
.
MUTATION_INITING_CHAT_DONE
]:
(
state
)
=>
{
state
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]
=
false
state
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]
=
false
;
},
},
},
},
actions
:
{
actions
:
{
...
@@ -293,7 +296,7 @@ export default {
...
@@ -293,7 +296,7 @@ export default {
const
{
pageData
}
=
await
model
().
list
().
query
({
const
{
pageData
}
=
await
model
().
list
().
query
({
pageIndex
:
1
,
pageIndex
:
1
,
item_size
:
50
,
item_size
:
50
,
})
})
;
const
result
=
pageData
.
rows
const
result
=
pageData
.
rows
.
map
((
row
)
=>
{
.
map
((
row
)
=>
{
return
{
return
{
...
@@ -305,13 +308,13 @@ export default {
...
@@ -305,13 +308,13 @@ export default {
uniplat_version
:
Number
(
row
.
uniplat_version
.
value
),
uniplat_version
:
Number
(
row
.
uniplat_version
.
value
),
msg_type
:
row
.
LastMsgType
.
value
,
msg_type
:
row
.
LastMsgType
.
value
,
is_finish
:
row
.
Status
.
value
,
is_finish
:
row
.
Status
.
value
,
}
}
;
})
})
.
filter
((
k
)
=>
!
k
.
is_finish
)
.
filter
((
k
)
=>
!
k
.
is_finish
)
;
commit
(
ChatStore
.
MUTATION_SAVE_CHAT_LIST
,
{
commit
(
ChatStore
.
MUTATION_SAVE_CHAT_LIST
,
{
list
:
result
,
list
:
result
,
total
:
pageData
.
record_count
,
total
:
pageData
.
record_count
,
})
})
;
},
},
async
[
ChatStore
.
ACTION_JOIN_CHAT
](
async
[
ChatStore
.
ACTION_JOIN_CHAT
](
{
commit
},
{
commit
},
...
@@ -320,46 +323,46 @@ export default {
...
@@ -320,46 +323,46 @@ export default {
// return await XimService.getInstance().joinChat(chatId)
// return await XimService.getInstance().joinChat(chatId)
},
},
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES
]({
state
,
commit
})
{
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES
]({
state
,
commit
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatId
==
null
)
return
if
(
chatId
==
null
)
return
;
try
{
try
{
const
data
=
await
xim
.
queryLastPageMsg
(
chatType
,
chatId
,
20
)
const
data
=
await
xim
.
queryLastPageMsg
(
chatType
,
chatId
,
20
)
;
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
)
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
)
;
await
preCacheImgs
(
data
)
await
preCacheImgs
(
data
)
;
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
)
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
)
;
return
data
return
data
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
)
console
.
error
(
error
)
;
}
}
},
},
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
](
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
](
{
state
,
commit
},
{
state
,
commit
},
msgId
:
Parameters
<
ChatStore
.
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
>
[
0
]
msgId
:
Parameters
<
ChatStore
.
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
>
[
0
]
)
{
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatId
==
null
)
return
if
(
chatId
==
null
)
return
;
const
data
=
await
xim
.
queryPrevPageMsg
(
chatType
,
chatId
,
msgId
,
10
)
const
data
=
await
xim
.
queryPrevPageMsg
(
chatType
,
chatId
,
msgId
,
10
)
;
commit
(
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
,
data
)
commit
(
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
,
data
)
;
return
data
return
data
;
},
},
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
](
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
](
{
state
,
commit
},
{
state
,
commit
},
msgId
:
Parameters
<
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
>
[
0
]
msgId
:
Parameters
<
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
>
[
0
]
)
{
)
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatId
==
null
)
return
if
(
chatId
==
null
)
return
;
const
data
=
await
xim
.
queryNextPageMsg
(
chatType
,
chatId
,
msgId
,
10
)
const
data
=
await
xim
.
queryNextPageMsg
(
chatType
,
chatId
,
msgId
,
10
)
;
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
)
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
)
;
return
data
return
data
;
},
},
async
[
ChatStore
.
ACTION_SEND_MESSAGE
](
async
[
ChatStore
.
ACTION_SEND_MESSAGE
](
{
state
,
dispatch
},
{
state
,
dispatch
},
params
:
Parameters
<
ChatStore
.
ACTION_SEND_MESSAGE
>
[
0
]
params
:
Parameters
<
ChatStore
.
ACTION_SEND_MESSAGE
>
[
0
]
)
{
)
{
const
uniplatId
=
const
uniplatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
;
const
version
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
const
version
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
;
if
(
uniplatId
==
null
)
return
if
(
uniplatId
==
null
)
return
;
try
{
try
{
const
data
=
await
model
()
const
data
=
await
model
()
.
action
(
"sendMsg"
)
.
action
(
"sendMsg"
)
...
@@ -372,11 +375,11 @@ export default {
...
@@ -372,11 +375,11 @@ export default {
LastMsgType
:
params
.
msgType
,
LastMsgType
:
params
.
msgType
,
LastMsgContent
:
params
.
msg
,
LastMsgContent
:
params
.
msg
,
})
})
.
dryExecute
()
.
dryExecute
()
;
await
dispatch
(
ChatStore
.
ACTION_GET_FRESH_MESSAGE
)
await
dispatch
(
ChatStore
.
ACTION_GET_FRESH_MESSAGE
)
;
return
data
return
data
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"testing 信息发送失败"
,
error
)
console
.
error
(
"testing 信息发送失败"
,
error
)
;
}
}
},
},
async
[
ChatStore
.
ACTION_GET_FRESH_MESSAGE
]({
async
[
ChatStore
.
ACTION_GET_FRESH_MESSAGE
]({
...
@@ -384,191 +387,191 @@ export default {
...
@@ -384,191 +387,191 @@ export default {
dispatch
,
dispatch
,
commit
,
commit
,
})
{
})
{
const
msgs
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
const
msgs
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
;
let
newMsgsArr
let
newMsgsArr
;
if
(
msgs
==
null
||
msgs
.
length
===
0
)
{
if
(
msgs
==
null
||
msgs
.
length
===
0
)
{
newMsgsArr
=
await
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES
)
newMsgsArr
=
await
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES
)
;
}
else
{
}
else
{
newMsgsArr
=
await
dispatch
(
newMsgsArr
=
await
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
,
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
,
msgs
[
msgs
.
length
-
1
].
id
msgs
[
msgs
.
length
-
1
].
id
)
)
;
}
}
const
lastMsg
=
newMsgsArr
[
newMsgsArr
.
length
-
1
]
const
lastMsg
=
newMsgsArr
[
newMsgsArr
.
length
-
1
]
;
await
preCacheImgs
(
newMsgsArr
)
await
preCacheImgs
(
newMsgsArr
)
;
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
)
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
)
;
},
},
async
[
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
](
async
[
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
](
{
state
,
commit
,
dispatch
},
{
state
,
commit
,
dispatch
},
params
:
Parameters
<
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
>
[
0
]
params
:
Parameters
<
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
>
[
0
]
)
{
)
{
const
myId
=
"1"
/* (await getMyinfo()).id */
const
myId
=
"1"
;
/* (await getMyinfo()).id */
const
action
=
sdk
().
model
(
UniplatChatModelName
).
action
(
"insert"
)
const
action
=
sdk
().
model
(
UniplatChatModelName
).
action
(
"insert"
)
;
action
.
addInputs_parameter
({
action
.
addInputs_parameter
({
OrgId
:
orgId
(),
OrgId
:
orgId
(),
ModelName
:
params
.
modelName
,
ModelName
:
params
.
modelName
,
ObjId
:
+
params
.
selectedListId
,
ObjId
:
+
params
.
selectedListId
,
Creator
:
myId
,
Creator
:
myId
,
Status
:
ChatStatus
.
opening
,
Status
:
ChatStatus
.
opening
,
})
})
;
const
detailManager
=
await
action
.
getDetailParametersManagerByName
(
const
detailManager
=
await
action
.
getDetailParametersManagerByName
(
"UniplatChatMember"
"UniplatChatMember"
)
)
;
detailManager
.
add
({
detailManager
.
add
({
OrgId
:
orgId
(),
OrgId
:
orgId
(),
Uid
:
myId
,
Uid
:
myId
,
type
:
ChatMemberType
.
member
,
type
:
ChatMemberType
.
member
,
})
})
;
params
.
uids
.
forEach
((
id
)
=>
{
params
.
uids
.
forEach
((
id
)
=>
{
detailManager
.
add
({
detailManager
.
add
({
OrgId
:
orgId
(),
OrgId
:
orgId
(),
Uid
:
id
,
Uid
:
id
,
type
:
ChatMemberType
.
member
,
type
:
ChatMemberType
.
member
,
})
})
;
})
})
;
detailManager
.
done
()
detailManager
.
done
()
;
const
{
id
}
=
await
action
.
dryExecute
()
const
{
id
}
=
await
action
.
dryExecute
()
;
//无法得到chat id
//
无法得到chat id
const
data
=
await
sdk
()
const
data
=
await
sdk
()
.
model
(
UniplatChatModelName
)
.
model
(
UniplatChatModelName
)
.
action
(
"createXimChat"
)
.
action
(
"createXimChat"
)
.
updateInitialParams
({
.
updateInitialParams
({
selected_list
:
[{
v
:
0
,
id
}],
selected_list
:
[{
v
:
0
,
id
}],
})
})
.
dryExecute
()
.
dryExecute
()
;
commit
(
ChatStore
.
MUTATION_HIDE_CHAT_CREATOR
)
commit
(
ChatStore
.
MUTATION_HIDE_CHAT_CREATOR
)
;
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
;
const
newChat
=
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
].
list
.
find
(
const
newChat
=
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
].
list
.
find
(
(
k
)
=>
k
.
uniplatId
===
id
(
k
)
=>
k
.
uniplatId
===
id
)
)
;
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
)
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
)
;
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
{
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
{
chatId
:
newChat
.
chat_id
,
chatId
:
newChat
.
chat_id
,
v
:
newChat
.
uniplat_version
,
v
:
newChat
.
uniplat_version
,
uniplatId
:
newChat
.
uniplatId
,
uniplatId
:
newChat
.
uniplatId
,
})
})
;
},
},
async
[
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE
](
async
[
ChatStore
.
ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE
](
{
commit
,
dispatch
},
{
commit
,
dispatch
},
option
:
{
option
:
{
customerServiceId
?:
number
|
string
customerServiceId
?:
number
|
string
;
customerServiceGroupId
?:
number
customerServiceGroupId
?:
number
;
}
}
)
{},
)
{},
async
[
ChatStore
.
ACTION_REGISTER_EVENT
]({
dispatch
,
commit
,
state
})
{
async
[
ChatStore
.
ACTION_REGISTER_EVENT
]({
dispatch
,
commit
,
state
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatId
==
null
)
return
if
(
chatId
==
null
)
return
;
const
onNewMsg
=
()
=>
{
const
onNewMsg
=
()
=>
{
dispatch
(
ChatStore
.
ACTION_GET_FRESH_MESSAGE
)
dispatch
(
ChatStore
.
ACTION_GET_FRESH_MESSAGE
)
;
}
}
;
const
onMsgRead
:
ChatNotifyListener
=
async
(
e
)
=>
{
const
onMsgRead
:
ChatNotifyListener
=
async
(
e
)
=>
{
if
(
if
(
process
.
env
.
VUE_APP_API_CLIENT_ID
!==
process
.
env
.
VUE_APP_API_CLIENT_ID
!==
"teamix-fast-service-merchant"
"teamix-fast-service-merchant"
)
{
)
{
return
return
;
}
}
console
.
log
(
"事件消息已读"
,
e
)
console
.
log
(
"事件消息已读"
,
e
)
;
if
(
chatId
!==
e
.
chat_id
)
return
if
(
chatId
!==
e
.
chat_id
)
return
;
const
msgs
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
const
msgs
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
;
if
(
msgs
==
null
)
return
if
(
msgs
==
null
)
return
;
const
oldestMsgId
=
msgs
[
0
].
id
-
1
const
oldestMsgId
=
msgs
[
0
].
id
-
1
;
const
lastMsgId
=
msgs
[
msgs
.
length
-
1
].
id
+
1
const
lastMsgId
=
msgs
[
msgs
.
length
-
1
].
id
+
1
;
const
freshMsgs
=
await
xim
.
queryMsgs
(
const
freshMsgs
=
await
xim
.
queryMsgs
(
chatType
,
chatType
,
chatId
,
chatId
,
oldestMsgId
<
1
?
1
:
oldestMsgId
,
oldestMsgId
<
1
?
1
:
oldestMsgId
,
lastMsgId
lastMsgId
)
)
;
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
)
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
)
;
commit
(
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
msgs
.
map
((
msg
)
=>
{
msgs
.
map
((
msg
)
=>
{
msg
=
{
...
msg
}
msg
=
{
...
msg
}
;
const
newMsg
=
freshMsgs
.
find
(
const
newMsg
=
freshMsgs
.
find
(
(
freshMsg
)
=>
freshMsg
.
id
===
msg
.
id
(
freshMsg
)
=>
freshMsg
.
id
===
msg
.
id
)
)
;
if
(
newMsg
!=
null
)
{
if
(
newMsg
!=
null
)
{
msg
.
read_count
=
newMsg
.
read_count
msg
.
read_count
=
newMsg
.
read_count
;
}
}
return
msg
return
msg
;
})
})
)
)
;
}
}
;
const
onInputing
:
ChatNotifyListener
=
(
e
)
=>
{
const
onInputing
:
ChatNotifyListener
=
(
e
)
=>
{
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
,
e
)
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
,
e
)
;
}
}
;
removeRegisterChatEvents
.
push
(()
=>
{
removeRegisterChatEvents
.
push
(()
=>
{
xim
.
off
(
"msg"
,
chatId
,
onNewMsg
)
xim
.
off
(
"msg"
,
chatId
,
onNewMsg
)
;
xim
.
off
(
"chat_notify"
,
"read"
,
onMsgRead
)
xim
.
off
(
"chat_notify"
,
"read"
,
onMsgRead
)
;
xim
.
off
(
"chat_notify"
,
"user.input"
,
onInputing
)
xim
.
off
(
"chat_notify"
,
"user.input"
,
onInputing
)
;
})
})
;
xim
.
on
(
"msg"
,
chatId
,
onNewMsg
)
xim
.
on
(
"msg"
,
chatId
,
onNewMsg
)
;
xim
.
on
(
"chat_notify"
,
"read"
,
onMsgRead
)
xim
.
on
(
"chat_notify"
,
"read"
,
onMsgRead
)
;
xim
.
on
(
"chat_notify"
,
"user.input"
,
onInputing
)
xim
.
on
(
"chat_notify"
,
"user.input"
,
onInputing
)
;
},
},
async
[
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
](
async
[
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
](
{
commit
,
dispatch
},
{
commit
,
dispatch
},
params
:
Parameters
<
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
>
[
0
]
params
:
Parameters
<
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
>
[
0
]
)
{
)
{
const
{
chatId
,
v
,
uniplatId
}
=
params
const
{
chatId
,
v
,
uniplatId
}
=
params
;
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
)
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
)
;
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_ID
,
chatId
)
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_ID
,
chatId
)
;
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_VERSION
,
v
)
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_VERSION
,
v
)
;
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
,
uniplatId
)
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
,
uniplatId
)
;
commit
(
ChatStore
.
MUTATION_INITING_CHAT
)
commit
(
ChatStore
.
MUTATION_INITING_CHAT
)
;
removeRegisterChatEvents
.
forEach
((
k
)
=>
k
())
removeRegisterChatEvents
.
forEach
((
k
)
=>
k
())
;
await
Promise
.
all
([
await
Promise
.
all
([
dispatch
(
ChatStore
.
ACTION_REGISTER_EVENT
),
dispatch
(
ChatStore
.
ACTION_REGISTER_EVENT
),
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES
),
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES
),
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MEMBERS
),
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MEMBERS
),
])
])
;
commit
(
ChatStore
.
MUTATION_INITING_CHAT_DONE
)
commit
(
ChatStore
.
MUTATION_INITING_CHAT_DONE
)
;
},
},
async
[
ChatStore
.
ACTION_CLEAR_CURRENT_CHAT_DATA
]({
commit
})
{
async
[
ChatStore
.
ACTION_CLEAR_CURRENT_CHAT_DATA
]({
commit
})
{
commit
(
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_ID
)
commit
(
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_ID
)
;
commit
(
ChatStore
.
MUTATION_CLEAR_MYSELF_ID
)
commit
(
ChatStore
.
MUTATION_CLEAR_MYSELF_ID
)
;
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
)
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_MSG_HISTORY
)
;
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_TITLE
)
commit
(
ChatStore
.
MUTATION_CLEAR_CHAT_TITLE
)
;
commit
(
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
)
commit
(
ChatStore
.
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
)
;
},
},
async
[
ChatStore
.
ACTION_GET_CHAT_MEMBERS
]({
commit
,
state
})
{
async
[
ChatStore
.
ACTION_GET_CHAT_MEMBERS
]({
commit
,
state
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
;
if
(
chatId
==
null
)
return
if
(
chatId
==
null
)
return
;
const
getChatMembersResult
=
await
xim
.
fetchChatMembers
(
chatId
)
const
getChatMembersResult
=
await
xim
.
fetchChatMembers
(
chatId
)
;
const
chatMembers
=
getChatMembersResult
.
args
[
0
]
as
ChatMember
[]
const
chatMembers
=
getChatMembersResult
.
args
[
0
]
as
ChatMember
[]
;
const
newChatMembers
=
await
Promise
.
all
(
const
newChatMembers
=
await
Promise
.
all
(
chatMembers
.
map
(
async
(
member
)
=>
{
chatMembers
.
map
(
async
(
member
)
=>
{
let
result
:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
[
number
]
let
result
:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
[
number
]
;
try
{
try
{
le
t
info
=
await
sdk
()
cons
t
info
=
await
sdk
()
.
model
(
"user"
)
.
model
(
"user"
)
.
detail
(
member
.
eid
)
.
detail
(
member
.
eid
)
.
query
()
.
query
()
;
result
=
{
result
=
{
...
member
,
...
member
,
name
:
info
.
row
.
first_name
.
value
as
string
,
name
:
info
.
row
.
first_name
.
value
as
string
,
phone
:
info
.
row
.
last_name
.
value
as
string
,
phone
:
info
.
row
.
last_name
.
value
as
string
,
}
}
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
)
console
.
error
(
error
)
;
result
=
member
result
=
member
;
}
}
return
result
return
result
;
})
})
)
)
;
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
)
;
})
})
)
)
;
},
},
async
[
ChatStore
.
ACTION_TERINATE_CHAT
]({
state
,
dispatch
})
{
async
[
ChatStore
.
ACTION_TERINATE_CHAT
]({
state
,
dispatch
})
{
const
v
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
const
v
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]
;
const
id
=
Number
(
const
id
=
Number
(
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]
)
)
;
await
sdk
()
await
sdk
()
.
model
(
UniplatChatModelName
)
.
model
(
UniplatChatModelName
)
.
action
(
"update"
)
.
action
(
"update"
)
...
@@ -578,30 +581,30 @@ export default {
...
@@ -578,30 +581,30 @@ export default {
.
addInputs_parameter
({
.
addInputs_parameter
({
Status
:
ChatStatus
.
terminated
,
Status
:
ChatStatus
.
terminated
,
})
})
.
execute
()
.
execute
()
;
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
await
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
;
},
},
},
},
getters
:
{
getters
:
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
return
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
??
[]
return
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
??
[]
;
},
},
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
](
state
)
{
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
](
state
)
{
return
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
||
[]
return
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
||
[]
;
},
},
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
](
state
)
{
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
](
state
)
{
return
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
??
[]
return
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
??
[]
;
},
},
[
ChatStore
.
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
](
state
)
{
[
ChatStore
.
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
](
state
)
{
return
(
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
??
[]).
filter
(
return
(
state
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]
??
[]).
filter
(
(
member
)
=>
!
member
.
is_exited
(
member
)
=>
!
member
.
is_exited
)
)
;
},
},
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
](
state
)
{
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
](
state
)
{
return
state
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]
||
""
return
state
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]
||
""
;
},
},
[
ChatStore
.
STATE_CHAT_SOURCE
](
state
)
{
[
ChatStore
.
STATE_CHAT_SOURCE
](
state
)
{
return
state
[
ChatStore
.
STATE_CHAT_SOURCE
]
||
0
return
state
[
ChatStore
.
STATE_CHAT_SOURCE
]
||
0
;
},
},
},
},
}
as
Module
<
ChatStoreState
,
RootStoreState
>
}
as
Module
<
ChatStoreState
,
RootStoreState
>
;
store/model.ts
View file @
84b48c2e
import
*
as
dto
from
"../model"
import
{
namespace
}
from
"vuex-class"
;
import
*
as
chatDto
from
"../xim/models/chat"
import
{
namespace
}
from
"vuex-class"
import
*
as
dto
from
"../model"
;
import
*
as
chatDto
from
"../xim/models/chat"
;
export
enum
ChatStatus
{
export
enum
ChatStatus
{
opening
=
0
,
opening
=
0
,
terminated
=
1
,
terminated
=
1
,
...
@@ -10,53 +11,53 @@ export enum ChatMemberType {
...
@@ -10,53 +11,53 @@ export enum ChatMemberType {
admin
=
"85"
,
admin
=
"85"
,
}
}
export
namespace
ChatStore
{
export
namespace
ChatStore
{
export
const
ns
=
"chatStore"
export
const
ns
=
"chatStore"
;
/* state */
/* state */
export
const
STATE_CHAT_CREATOR_VISIBLE
=
"创建会话弹窗显示状态"
export
const
STATE_CHAT_CREATOR_VISIBLE
=
"创建会话弹窗显示状态"
;
export
type
STATE_CHAT_CREATOR_VISIBLE
=
boolean
export
type
STATE_CHAT_CREATOR_VISIBLE
=
boolean
export
const
STATE_CHAT_DIALOG_VISIBLE
=
"会话模块弹窗显示状态"
export
const
STATE_CHAT_DIALOG_VISIBLE
=
"会话模块弹窗显示状态"
;
export
type
STATE_CHAT_DIALOG_VISIBLE
=
boolean
export
type
STATE_CHAT_DIALOG_VISIBLE
=
boolean
export
const
STATE_MY_CHAT_ROOM_LIST
=
"我的会话列表"
export
const
STATE_MY_CHAT_ROOM_LIST
=
"我的会话列表"
;
export
type
STATE_MY_CHAT_ROOM_LIST
=
{
export
type
STATE_MY_CHAT_ROOM_LIST
=
{
list
:
{
list
:
{
uniplatId
:
string
uniplatId
:
string
;
chat_id
:
number
chat_id
:
number
;
msg
:
string
msg
:
string
;
customer_name
:
string
customer_name
:
string
;
customer_avatar_url
:
string
customer_avatar_url
:
string
;
uniplat_version
:
number
uniplat_version
:
number
;
msg_type
:
string
msg_type
:
string
;
is_finish
:
0
|
1
is_finish
:
0
|
1
;
}[]
}[]
;
total
:
number
total
:
number
;
}
}
export
const
STATE_CHAT_MSG_HISTORY
=
"某个会话聊天记录"
export
const
STATE_CHAT_MSG_HISTORY
=
"某个会话聊天记录"
;
export
type
STATE_CHAT_MSG_HISTORY
=
dto
.
MessageRequestResult
|
null
export
type
STATE_CHAT_MSG_HISTORY
=
dto
.
MessageRequestResult
|
null
export
const
STATE_CHAT_SENDING_MESSAGES
=
"sendingMessages"
export
const
STATE_CHAT_SENDING_MESSAGES
=
"sendingMessages"
;
export
type
STATE_CHAT_SENDING_MESSAGES
=
dto
.
MessageRequestResult
|
null
export
type
STATE_CHAT_SENDING_MESSAGES
=
dto
.
MessageRequestResult
|
null
export
type
STATE_CHAT_SENDING_MESSAGE
=
dto
.
Message
export
type
STATE_CHAT_SENDING_MESSAGE
=
dto
.
Message
export
const
STATE_CHAT_CURRENT_CHAT_ID
=
"当前chat-id"
export
const
STATE_CHAT_CURRENT_CHAT_ID
=
"当前chat-id"
;
export
type
STATE_CHAT_CURRENT_CHAT_ID
=
number
|
null
export
type
STATE_CHAT_CURRENT_CHAT_ID
=
number
|
null
export
const
STATE_CHAT_CURRENT_CHAT_VERSION
=
"当前chat的Uniplat version"
export
const
STATE_CHAT_CURRENT_CHAT_VERSION
=
"当前chat的Uniplat version"
;
export
type
STATE_CHAT_CURRENT_CHAT_VERSION
=
number
|
null
export
type
STATE_CHAT_CURRENT_CHAT_VERSION
=
number
|
null
export
const
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
=
"当前chat的Uniplat id"
export
const
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
=
"当前chat的Uniplat id"
;
export
type
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
=
string
|
null
export
type
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
=
string
|
null
export
const
STATE_CHAT_MY_ID
=
"聊天窗口显示在右边那个人的id"
export
const
STATE_CHAT_MY_ID
=
"聊天窗口显示在右边那个人的id"
;
export
type
STATE_CHAT_MY_ID
=
string
|
null
export
type
STATE_CHAT_MY_ID
=
string
|
null
export
const
STATE_CHAT_MY_UID
=
"聊天窗口显示在右边那个人的uid"
export
const
STATE_CHAT_MY_UID
=
"聊天窗口显示在右边那个人的uid"
;
export
type
STATE_CHAT_MY_UID
=
string
|
null
export
type
STATE_CHAT_MY_UID
=
string
|
null
export
const
STATE_CHAT_SOURCE
=
"stateChatSource"
export
const
STATE_CHAT_SOURCE
=
"stateChatSource"
;
export
type
STATE_CHAT_SOURCE
=
StateChatSourceDirection
export
type
STATE_CHAT_SOURCE
=
StateChatSourceDirection
export
const
STATE_CURRENT_CHAT_INPUTING
=
"当前会话正在输入的人"
export
const
STATE_CURRENT_CHAT_INPUTING
=
"当前会话正在输入的人"
;
export
type
STATE_CURRENT_CHAT_INPUTING
=
string
[]
export
type
STATE_CURRENT_CHAT_INPUTING
=
string
[]
export
const
STATE_CURRENT_CHAT_INITING
=
"当前会是否正在初始化"
export
const
STATE_CURRENT_CHAT_INITING
=
"当前会是否正在初始化"
;
export
type
STATE_CURRENT_CHAT_INITING
=
boolean
export
type
STATE_CURRENT_CHAT_INITING
=
boolean
/**
/**
...
@@ -67,218 +68,218 @@ export namespace ChatStore {
...
@@ -67,218 +68,218 @@ export namespace ChatStore {
Client
=
0
,
Client
=
0
,
}
}
export
const
STATE_CURRENT_CHAT_MEMBERS
=
"当前会话参与者"
export
const
STATE_CURRENT_CHAT_MEMBERS
=
"当前会话参与者"
;
export
type
STATE_CURRENT_CHAT_MEMBERS
=
export
type
STATE_CURRENT_CHAT_MEMBERS
=
|
readonly
(
dto
.
ChatMember
&
dto
.
ChatMemberExtraInfo
)[]
|
readonly
(
dto
.
ChatMember
&
dto
.
ChatMemberExtraInfo
)[]
|
null
|
null
export
const
STATE_CURRENT_CHAT_TITLE
=
"会话标题"
export
const
STATE_CURRENT_CHAT_TITLE
=
"会话标题"
;
export
type
STATE_CURRENT_CHAT_TITLE
=
string
export
type
STATE_CURRENT_CHAT_TITLE
=
string
export
const
STATE_FUNC_SCROLL_TO_BOTTOM
=
"收到消息后滚动到底部的方法"
export
const
STATE_FUNC_SCROLL_TO_BOTTOM
=
"收到消息后滚动到底部的方法"
;
export
type
STATE_FUNC_SCROLL_TO_BOTTOM
=
()
=>
void
export
type
STATE_FUNC_SCROLL_TO_BOTTOM
=
()
=>
void
/* getter */
/* getter */
export
const
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
=
"当前会话未退出的参与者"
export
const
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
=
"当前会话未退出的参与者"
;
export
type
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
=
dto
.
ChatMembers
|
null
export
type
GETTER_CURRENT_CHAT_PRESENT_MEMBERS
=
dto
.
ChatMembers
|
null
/* mutation */
/* mutation */
export
const
MUTATION_SHOW_CHAT_CREATOR
=
"打开创建会话弹窗"
export
const
MUTATION_SHOW_CHAT_CREATOR
=
"打开创建会话弹窗"
;
export
type
MUTATION_SHOW_CHAT_CREATOR
=
()
=>
void
export
type
MUTATION_SHOW_CHAT_CREATOR
=
()
=>
void
export
const
MUTATION_HIDE_CHAT_CREATOR
=
"关闭创建会话弹窗"
export
const
MUTATION_HIDE_CHAT_CREATOR
=
"关闭创建会话弹窗"
;
export
type
MUTATION_HIDE_CHAT_CREATOR
=
()
=>
void
export
type
MUTATION_HIDE_CHAT_CREATOR
=
()
=>
void
export
const
MUTATION_SHOW_CHAT
=
"打开会话弹窗"
export
const
MUTATION_SHOW_CHAT
=
"打开会话弹窗"
;
export
type
MUTATION_SHOW_CHAT
=
()
=>
void
export
type
MUTATION_SHOW_CHAT
=
()
=>
void
export
const
MUTATION_HIDE_CHAT
=
"关闭会话弹窗"
export
const
MUTATION_HIDE_CHAT
=
"关闭会话弹窗"
;
export
type
MUTATION_HIDE_CHAT
=
()
=>
void
export
type
MUTATION_HIDE_CHAT
=
()
=>
void
export
const
MUTATION_SAVE_CHAT_LIST
=
"保存我的会话列表"
export
const
MUTATION_SAVE_CHAT_LIST
=
"保存我的会话列表"
;
export
type
MUTATION_SAVE_CHAT_LIST
=
(
export
type
MUTATION_SAVE_CHAT_LIST
=
(
list
:
STATE_MY_CHAT_ROOM_LIST
list
:
STATE_MY_CHAT_ROOM_LIST
)
=>
void
)
=>
void
export
const
MUTATION_PUSH_CHAT_MSG_HISTORY
=
"新增下一页聊天记录"
export
const
MUTATION_PUSH_CHAT_MSG_HISTORY
=
"新增下一页聊天记录"
;
export
type
MUTATION_PUSH_CHAT_MSG_HISTORY
=
(
export
type
MUTATION_PUSH_CHAT_MSG_HISTORY
=
(
list
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
list
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
)
=>
void
)
=>
void
export
const
MUTATION_INITING_CHAT
=
"当前会话正在初始化"
export
const
MUTATION_INITING_CHAT
=
"当前会话正在初始化"
;
export
type
MUTATION_INITING_CHAT
=
()
=>
void
export
type
MUTATION_INITING_CHAT
=
()
=>
void
export
const
MUTATION_INITING_CHAT_DONE
=
"当前会话初始完成"
export
const
MUTATION_INITING_CHAT_DONE
=
"当前会话初始完成"
;
export
type
MUTATION_INITING_CHAT_DONE
=
()
=>
void
export
type
MUTATION_INITING_CHAT_DONE
=
()
=>
void
export
const
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
=
"新增上一页聊天记录"
export
const
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
=
"新增上一页聊天记录"
;
export
type
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
=
(
export
type
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
=
(
list
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
list
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CHAT_MSG_HISTORY
=
"清空聊天记录"
export
const
MUTATION_CLEAR_CHAT_MSG_HISTORY
=
"清空聊天记录"
;
export
type
MUTATION_CLEAR_CHAT_MSG_HISTORY
=
()
=>
void
export
type
MUTATION_CLEAR_CHAT_MSG_HISTORY
=
()
=>
void
export
const
MUTATION_SAVE_CURRENT_CHAT_ID
=
"保存当前chat-id"
export
const
MUTATION_SAVE_CURRENT_CHAT_ID
=
"保存当前chat-id"
;
export
type
MUTATION_SAVE_CURRENT_CHAT_ID
=
(
export
type
MUTATION_SAVE_CURRENT_CHAT_ID
=
(
chatId
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
chatId
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CURRENT_CHAT_ID
=
"清空chat-id"
export
const
MUTATION_CLEAR_CURRENT_CHAT_ID
=
"清空chat-id"
;
export
type
MUTATION_CLEAR_CURRENT_CHAT_ID
=
()
=>
void
export
type
MUTATION_CLEAR_CURRENT_CHAT_ID
=
()
=>
void
export
const
MUTATION_SAVE_CURRENT_CHAT_VERSION
=
export
const
MUTATION_SAVE_CURRENT_CHAT_VERSION
=
"保存当前chat uniplat version"
"保存当前chat uniplat version"
;
export
type
MUTATION_SAVE_CURRENT_CHAT_VERSION
=
(
export
type
MUTATION_SAVE_CURRENT_CHAT_VERSION
=
(
v
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
v
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CURRENT_CHAT_VERSION
=
export
const
MUTATION_CLEAR_CURRENT_CHAT_VERSION
=
"清空chat uniplat version"
"清空chat uniplat version"
;
export
type
MUTATION_CLEAR_CURRENT_CHAT_VERSION
=
()
=>
void
export
type
MUTATION_CLEAR_CURRENT_CHAT_VERSION
=
()
=>
void
export
const
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
=
export
const
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
=
"保存当前chat uniplat id"
"保存当前chat uniplat id"
;
export
type
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
=
(
export
type
MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID
=
(
v
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
v
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CURRENT_CHAT_UNIPLAT_ID
=
"清空chat uniplat id"
export
const
MUTATION_CLEAR_CURRENT_CHAT_UNIPLAT_ID
=
"清空chat uniplat id"
;
export
type
MUTATION_CLEAR_CURRENT_CHAT_UNIPLAT_ID
=
()
=>
void
export
type
MUTATION_CLEAR_CURRENT_CHAT_UNIPLAT_ID
=
()
=>
void
export
const
MUTATION_SAVE_MYSELF_ID
=
export
const
MUTATION_SAVE_MYSELF_ID
=
"保存我的id:聊天窗口显示在右边那个人的id"
"保存我的id:聊天窗口显示在右边那个人的id"
;
export
type
MUTATION_SAVE_MYSELF_ID
=
()
=>
void
export
type
MUTATION_SAVE_MYSELF_ID
=
()
=>
void
export
const
MUTATION_CLEAR_MYSELF_ID
=
export
const
MUTATION_CLEAR_MYSELF_ID
=
"清空我的id:聊天窗口显示在右边那个人的id"
"清空我的id:聊天窗口显示在右边那个人的id"
;
export
type
MUTATION_CLEAR_MYSELF_ID
=
()
=>
void
export
type
MUTATION_CLEAR_MYSELF_ID
=
()
=>
void
export
const
MUTATION_SET_CHAT_SOURCE
=
"setChatSource"
export
const
MUTATION_SET_CHAT_SOURCE
=
"setChatSource"
;
export
type
MUTATION_SET_CHAT_SOURCE
=
(
export
type
MUTATION_SET_CHAT_SOURCE
=
(
payload
:
StateChatSourceDirection
payload
:
StateChatSourceDirection
)
=>
void
)
=>
void
export
const
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
=
"保存当前会话参与者"
export
const
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
=
"保存当前会话参与者"
;
export
type
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
=
(
export
type
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
=
(
params
:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
params
:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
=
"清空当前会话参与者"
export
const
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
=
"清空当前会话参与者"
;
export
type
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
=
()
=>
void
export
type
MUTATION_CLEAR_CURRENT_CHAT_MEMBERS
=
()
=>
void
export
const
MUTATION_SAVE_CHAT_TITLE
=
"保存会话标题"
export
const
MUTATION_SAVE_CHAT_TITLE
=
"保存会话标题"
;
export
type
MUTATION_SAVE_CHAT_TITLE
=
(
export
type
MUTATION_SAVE_CHAT_TITLE
=
(
title
:
ChatStore
.
STATE_CURRENT_CHAT_TITLE
title
:
ChatStore
.
STATE_CURRENT_CHAT_TITLE
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CHAT_TITLE
=
"清空会话标题"
export
const
MUTATION_CLEAR_CHAT_TITLE
=
"清空会话标题"
;
export
type
MUTATION_CLEAR_CHAT_TITLE
=
()
=>
void
export
type
MUTATION_CLEAR_CHAT_TITLE
=
()
=>
void
export
const
MUTATION_SCROLL_TO_BOTTOM
=
"收到新消息后滚动到底部"
export
const
MUTATION_SCROLL_TO_BOTTOM
=
"收到新消息后滚动到底部"
;
export
type
MUTATION_SCROLL_TO_BOTTOM
=
()
=>
void
export
type
MUTATION_SCROLL_TO_BOTTOM
=
()
=>
void
export
const
MUTATION_SAVE_FUNC_SCROLL_TO_BOTTOM
=
export
const
MUTATION_SAVE_FUNC_SCROLL_TO_BOTTOM
=
"保存收到新消息后滚动到底部的方法"
"保存收到新消息后滚动到底部的方法"
;
export
type
MUTATION_SAVE_FUNC_SCROLL_TO_BOTTOM
=
(
func
:
()
=>
void
)
=>
void
export
type
MUTATION_SAVE_FUNC_SCROLL_TO_BOTTOM
=
(
func
:
()
=>
void
)
=>
void
export
const
MUTATION_CLEAR_FUNC_SCROLL_TO_BOTTOM
=
export
const
MUTATION_CLEAR_FUNC_SCROLL_TO_BOTTOM
=
"删除收到新消息后滚动到底部的方法"
"删除收到新消息后滚动到底部的方法"
;
export
type
MUTATION_CLEAR_FUNC_SCROLL_TO_BOTTOM
=
()
=>
void
export
type
MUTATION_CLEAR_FUNC_SCROLL_TO_BOTTOM
=
()
=>
void
export
const
MUTATION_APPEND_SENDING_MESSAGE
=
"appendSendingMessage"
export
const
MUTATION_APPEND_SENDING_MESSAGE
=
"appendSendingMessage"
;
export
type
MUTATION_APPEND_SENDING_MESSAGE
=
(
payload
:
dto
.
Message
)
=>
void
export
type
MUTATION_APPEND_SENDING_MESSAGE
=
(
payload
:
dto
.
Message
)
=>
void
export
const
MUTATION_REMOVE_SENDING_MESSAGE
=
"removeSendingMessage"
export
const
MUTATION_REMOVE_SENDING_MESSAGE
=
"removeSendingMessage"
;
export
type
MUTATION_REMOVE_SENDING_MESSAGE
=
(
id
:
number
)
=>
void
export
type
MUTATION_REMOVE_SENDING_MESSAGE
=
(
id
:
number
)
=>
void
export
const
MUTATION_FAILED_SENDING_MESSAGE
=
"failedSendingMessage"
export
const
MUTATION_FAILED_SENDING_MESSAGE
=
"failedSendingMessage"
;
export
type
MUTATION_FAILED_SENDING_MESSAGE
=
(
id
:
number
)
=>
void
export
type
MUTATION_FAILED_SENDING_MESSAGE
=
(
id
:
number
)
=>
void
export
const
MUTATION_SAVE_CURRENT_CHAT_INPUTING
=
"保存正在输入"
export
const
MUTATION_SAVE_CURRENT_CHAT_INPUTING
=
"保存正在输入"
;
export
type
MUTATION_SAVE_CURRENT_CHAT_INPUTING
=
(
export
type
MUTATION_SAVE_CURRENT_CHAT_INPUTING
=
(
params
:
chatDto
.
NotifyMessage
params
:
chatDto
.
NotifyMessage
)
=>
void
)
=>
void
export
const
MUTATION_CLEAR_CURRENT_CHAT_INPUTING
=
"清空正在输入"
export
const
MUTATION_CLEAR_CURRENT_CHAT_INPUTING
=
"清空正在输入"
;
export
type
MUTATION_CLEAR_CURRENT_CHAT_INPUTING
=
()
=>
void
export
type
MUTATION_CLEAR_CURRENT_CHAT_INPUTING
=
()
=>
void
/* action */
/* action */
export
const
ACTION_GET_MY_CHAT_LIST
=
"获取我的会话列表"
export
const
ACTION_GET_MY_CHAT_LIST
=
"获取我的会话列表"
;
export
type
ACTION_GET_MY_CHAT_LIST
=
(
keyword
?:
string
)
=>
void
export
type
ACTION_GET_MY_CHAT_LIST
=
(
keyword
?:
string
)
=>
void
export
const
ACTION_JOIN_CHAT
=
"加入某个会话"
export
const
ACTION_JOIN_CHAT
=
"加入某个会话"
;
export
type
ACTION_JOIN_CHAT
=
(
chatId
:
number
)
=>
void
export
type
ACTION_JOIN_CHAT
=
(
chatId
:
number
)
=>
void
export
const
ACTION_GET_CHAT_MESSAGES
=
"打开某个会话时获取他的聊天记录"
export
const
ACTION_GET_CHAT_MESSAGES
=
"打开某个会话时获取他的聊天记录"
;
export
type
ACTION_GET_CHAT_MESSAGES
=
export
type
ACTION_GET_CHAT_MESSAGES
=
()
=>
Promise
<
dto
.
MessageRequestResult
>
()
=>
Promise
<
dto
.
MessageRequestResult
>
export
const
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
=
export
const
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
=
"获取某个消息之前的10条消息"
"获取某个消息之前的10条消息"
;
export
type
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
=
(
export
type
ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID
=
(
msgId
:
number
msgId
:
number
)
=>
Promise
<
dto
.
MessageRequestResult
>
)
=>
Promise
<
dto
.
MessageRequestResult
>
export
const
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
=
export
const
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
=
"获取某个消息之后的10条消息"
"获取某个消息之后的10条消息"
;
export
type
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
=
(
export
type
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
=
(
msgId
:
number
msgId
:
number
)
=>
Promise
<
dto
.
MessageRequestResult
>
)
=>
Promise
<
dto
.
MessageRequestResult
>
export
const
ACTION_GET_FRESH_MESSAGE
=
"获取最新的消息"
export
const
ACTION_GET_FRESH_MESSAGE
=
"获取最新的消息"
;
export
type
ACTION_GET_FRESH_MESSAGE
=
export
type
ACTION_GET_FRESH_MESSAGE
=
()
=>
Promise
<
dto
.
MessageRequestResult
>
()
=>
Promise
<
dto
.
MessageRequestResult
>
export
const
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
=
"客服向顾客发起新会话"
export
const
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
=
"客服向顾客发起新会话"
;
export
type
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
=
(
params
:
{
export
type
ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN
=
(
params
:
{
modelName
:
string
modelName
:
string
;
selectedListId
:
string
selectedListId
:
string
;
uids
:
string
[]
uids
:
string
[]
;
})
=>
Promise
<
void
>
})
=>
Promise
<
void
>
export
const
ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE
=
export
const
ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE
=
"startNewConversationByCustomerSide"
"startNewConversationByCustomerSide"
;
export
type
ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE
=
(
option
:
{
export
type
ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE
=
(
option
:
{
customerServiceId
?:
number
|
string
customerServiceId
?:
number
|
string
;
customerServiceGroupId
?:
number
|
string
customerServiceGroupId
?:
number
|
string
;
})
=>
Promise
<
number
>
})
=>
Promise
<
number
>
export
const
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
=
"action:保存当前chat-id"
export
const
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
=
"action:保存当前chat-id"
;
export
type
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
=
(
params
:
{
export
type
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
=
(
params
:
{
chatId
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
chatId
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
v
:
number
v
:
number
;
uniplatId
:
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
uniplatId
:
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
;
})
=>
Promise
<
void
>
})
=>
Promise
<
void
>
export
const
ACTION_CLEAR_CURRENT_CHAT_DATA
=
"action:清空当前会话数据"
export
const
ACTION_CLEAR_CURRENT_CHAT_DATA
=
"action:清空当前会话数据"
;
export
type
ACTION_CLEAR_CURRENT_CHAT_DATA
=
()
=>
Promise
<
void
>
export
type
ACTION_CLEAR_CURRENT_CHAT_DATA
=
()
=>
Promise
<
void
>
export
const
ACTION_REGISTER_EVENT
=
"给当前会话注册事件通知"
export
const
ACTION_REGISTER_EVENT
=
"给当前会话注册事件通知"
;
export
type
ACTION_REGISTER_EVENT
=
()
=>
Promise
<
void
>
export
type
ACTION_REGISTER_EVENT
=
()
=>
Promise
<
void
>
export
const
ACTION_GET_CHAT_MEMBERS
=
"获取会话成员列表"
export
const
ACTION_GET_CHAT_MEMBERS
=
"获取会话成员列表"
;
export
type
ACTION_GET_CHAT_MEMBERS
=
()
=>
Promise
<
void
>
export
type
ACTION_GET_CHAT_MEMBERS
=
()
=>
Promise
<
void
>
export
const
ACTION_SEND_MESSAGE
=
"发送消息"
export
const
ACTION_SEND_MESSAGE
=
"发送消息"
;
export
type
ACTION_SEND_MESSAGE
=
(
params
:
{
export
type
ACTION_SEND_MESSAGE
=
(
params
:
{
msgType
:
"text"
|
"image"
|
"file"
|
"voice"
|
"video"
msgType
:
"text"
|
"image"
|
"file"
|
"voice"
|
"video"
;
msg
:
string
msg
:
string
;
})
=>
void
})
=>
void
export
const
ACTION_TERINATE_CHAT
=
"结束会话"
export
const
ACTION_TERINATE_CHAT
=
"结束会话"
;
export
type
ACTION_TERINATE_CHAT
=
()
=>
Promise
<
void
>
export
type
ACTION_TERINATE_CHAT
=
()
=>
Promise
<
void
>
}
}
export
interface
ChatStoreState
{
export
interface
ChatStoreState
{
[
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
]:
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
[
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
]:
ChatStore
.
STATE_CHAT_CREATOR_VISIBLE
;
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]:
ChatStore
.
STATE_CHAT_MSG_HISTORY
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]:
ChatStore
.
STATE_CHAT_MSG_HISTORY
;
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]:
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]:
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
;
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID
;
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_VERSION
;
[
ChatStore
.
STATE_CHAT_MY_UID
]:
ChatStore
.
STATE_CHAT_MY_UID
[
ChatStore
.
STATE_CHAT_MY_UID
]:
ChatStore
.
STATE_CHAT_MY_UID
;
[
ChatStore
.
STATE_CHAT_MY_ID
]:
ChatStore
.
STATE_CHAT_MY_ID
[
ChatStore
.
STATE_CHAT_MY_ID
]:
ChatStore
.
STATE_CHAT_MY_ID
;
[
ChatStore
.
STATE_CHAT_SOURCE
]:
ChatStore
.
STATE_CHAT_SOURCE
[
ChatStore
.
STATE_CHAT_SOURCE
]:
ChatStore
.
STATE_CHAT_SOURCE
;
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
[
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
]:
ChatStore
.
STATE_CURRENT_CHAT_MEMBERS
;
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]:
ChatStore
.
STATE_CURRENT_CHAT_TITLE
[
ChatStore
.
STATE_CURRENT_CHAT_TITLE
]:
ChatStore
.
STATE_CURRENT_CHAT_TITLE
;
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]:
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
[
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
]:
ChatStore
.
STATE_FUNC_SCROLL_TO_BOTTOM
;
[
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
]:
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
[
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
]:
ChatStore
.
STATE_CURRENT_CHAT_INPUTING
;
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]:
ChatStore
.
STATE_CURRENT_CHAT_INITING
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]:
ChatStore
.
STATE_CURRENT_CHAT_INITING
;
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
]:
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
]:
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
;
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]:
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]:
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
;
}
}
export
const
chatStore
=
namespace
(
ChatStore
.
ns
)
export
const
chatStore
=
namespace
(
ChatStore
.
ns
)
;
third-party/image/index.ts
View file @
84b48c2e
export
class
ImageCompresser
{
export
class
ImageCompresser
{
public
static
dataURL2File
(
data
:
string
,
name
:
string
)
{
public
static
dataURL2File
(
data
:
string
,
name
:
string
)
{
const
arr
=
data
.
split
(
","
)
const
arr
=
data
.
split
(
","
)
;
if
(
arr
)
{
if
(
arr
)
{
if
(
arr
[
0
])
{
if
(
arr
[
0
])
{
const
match
=
arr
[
0
].
match
(
/:
(
.*
?)
;/
)
const
match
=
arr
[
0
].
match
(
/:
(
.*
?)
;/
)
;
if
(
match
)
{
if
(
match
)
{
const
mime
=
match
[
1
]
const
mime
=
match
[
1
]
;
const
bstr
=
atob
(
arr
[
1
])
const
bstr
=
atob
(
arr
[
1
])
;
let
n
=
bstr
.
length
let
n
=
bstr
.
length
;
const
u8arr
=
new
Uint8Array
(
n
)
const
u8arr
=
new
Uint8Array
(
n
)
;
// eslint-disable-next-line no-plusplus
// eslint-disable-next-line no-plusplus
while
(
n
--
)
{
while
(
n
--
)
{
u8arr
[
n
]
=
bstr
.
charCodeAt
(
n
)
u8arr
[
n
]
=
bstr
.
charCodeAt
(
n
)
;
}
}
return
new
File
([
u8arr
],
name
,
{
type
:
mime
})
return
new
File
([
u8arr
],
name
,
{
type
:
mime
})
;
}
}
}
}
}
}
return
null
return
null
;
}
}
public
static
readFile2Image
(
public
static
readFile2Image
(
...
@@ -26,38 +26,38 @@ export class ImageCompresser {
...
@@ -26,38 +26,38 @@ export class ImageCompresser {
maxHeight
:
number
maxHeight
:
number
):
Promise
<
File
|
null
>
{
):
Promise
<
File
|
null
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
img
=
new
Image
()
const
img
=
new
Image
()
;
const
reader
=
new
FileReader
()
const
reader
=
new
FileReader
()
;
reader
.
onload
=
(
e
)
=>
{
reader
.
onload
=
(
e
)
=>
{
if
(
e
&&
e
.
target
&&
e
.
target
.
result
)
{
if
(
e
&&
e
.
target
&&
e
.
target
.
result
)
{
img
.
src
=
e
.
target
.
result
as
string
img
.
src
=
e
.
target
.
result
as
string
;
}
else
{
}
else
{
reject
()
reject
()
;
}
}
}
}
;
reader
.
readAsDataURL
(
file
)
reader
.
readAsDataURL
(
file
)
;
img
.
onload
=
()
=>
{
img
.
onload
=
()
=>
{
const
originWidth
=
img
.
naturalWidth
const
originWidth
=
img
.
naturalWidth
;
const
originHeight
=
img
.
naturalHeight
const
originHeight
=
img
.
naturalHeight
;
if
(
originWidth
>
maxWidth
||
originHeight
>
maxHeight
)
{
if
(
originWidth
>
maxWidth
||
originHeight
>
maxHeight
)
{
ImageCompresser
.
compressImg
(
img
,
maxWidth
,
maxHeight
)
ImageCompresser
.
compressImg
(
img
,
maxWidth
,
maxHeight
)
.
then
((
b
)
=>
{
.
then
((
b
)
=>
{
if
(
b
)
{
if
(
b
)
{
const
newFile
=
new
File
([
b
],
file
.
name
)
const
newFile
=
new
File
([
b
],
file
.
name
)
;
// 如果压缩完还不如原始图片size小,直接返回原始图片
// 如果压缩完还不如原始图片size小,直接返回原始图片
resolve
(
resolve
(
newFile
.
size
<=
file
.
size
?
newFile
:
file
newFile
.
size
<=
file
.
size
?
newFile
:
file
)
)
;
}
else
{
}
else
{
reject
()
reject
()
;
}
}
})
})
.
catch
(
reject
)
.
catch
(
reject
)
;
}
else
{
}
else
{
resolve
(
file
)
resolve
(
file
)
;
}
}
}
}
;
})
})
;
}
}
/**
/**
...
@@ -74,40 +74,40 @@ export class ImageCompresser {
...
@@ -74,40 +74,40 @@ export class ImageCompresser {
type
?:
string
type
?:
string
):
Promise
<
Blob
|
null
>
{
):
Promise
<
Blob
|
null
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
canvas
=
document
.
createElement
(
"canvas"
)
const
canvas
=
document
.
createElement
(
"canvas"
)
;
const
context
=
canvas
.
getContext
(
"2d"
)
const
context
=
canvas
.
getContext
(
"2d"
)
;
if
(
!
context
)
{
if
(
!
context
)
{
reject
()
reject
()
;
return
return
;
}
}
const
{
width
:
originWidth
,
height
:
originHeight
}
=
img
// 最大尺寸限制
const
{
width
:
originWidth
,
height
:
originHeight
}
=
img
;
// 最大尺寸限制
const
maxWidth
=
mx
const
maxWidth
=
mx
;
const
maxHeight
=
mh
// 目标尺寸
const
maxHeight
=
mh
;
// 目标尺寸
let
targetWidth
=
originWidth
let
targetWidth
=
originWidth
;
let
targetHeight
=
originHeight
let
targetHeight
=
originHeight
;
if
(
originWidth
>
maxWidth
||
originHeight
>
maxHeight
)
{
if
(
originWidth
>
maxWidth
||
originHeight
>
maxHeight
)
{
if
(
originWidth
/
originHeight
>
1
)
{
if
(
originWidth
/
originHeight
>
1
)
{
// 宽图片
// 宽图片
targetWidth
=
maxWidth
targetWidth
=
maxWidth
;
targetHeight
=
Math
.
round
(
targetHeight
=
Math
.
round
(
maxWidth
*
(
originHeight
/
originWidth
)
maxWidth
*
(
originHeight
/
originWidth
)
)
)
;
}
else
{
}
else
{
// 高图片
// 高图片
targetHeight
=
maxHeight
targetHeight
=
maxHeight
;
targetWidth
=
Math
.
round
(
targetWidth
=
Math
.
round
(
maxHeight
*
(
originWidth
/
originHeight
)
maxHeight
*
(
originWidth
/
originHeight
)
)
)
;
}
}
}
}
canvas
.
width
=
targetWidth
canvas
.
width
=
targetWidth
;
canvas
.
height
=
targetHeight
canvas
.
height
=
targetHeight
;
context
.
clearRect
(
0
,
0
,
targetWidth
,
targetHeight
)
context
.
clearRect
(
0
,
0
,
targetWidth
,
targetHeight
)
;
context
.
drawImage
(
img
,
0
,
0
,
targetWidth
,
targetHeight
)
context
.
drawImage
(
img
,
0
,
0
,
targetWidth
,
targetHeight
)
;
canvas
.
toBlob
((
blob
)
=>
{
canvas
.
toBlob
((
blob
)
=>
{
resolve
(
blob
)
resolve
(
blob
)
;
canvas
.
remove
()
canvas
.
remove
()
;
},
type
||
"image/png"
)
},
type
||
"image/png"
)
;
})
})
;
}
}
}
}
third-party/pc-mobile-transformer/index.ts
View file @
84b48c2e
import
{
UserAgentHelper
}
from
"../user-agent"
import
{
UserAgentHelper
}
from
"../user-agent"
;
export
enum
TransformTarget
{
export
enum
TransformTarget
{
Mobile
,
Mobile
,
...
@@ -36,12 +36,12 @@ export interface PcMobileTransformerOption {
...
@@ -36,12 +36,12 @@ export interface PcMobileTransformerOption {
/**
/**
* 手机端根host,如 https://www.teammix.com/ms
* 手机端根host,如 https://www.teammix.com/ms
*/
*/
mobileHost
?:
string
mobileHost
?:
string
;
/**
/**
* 桌面端根host,如 https://www.teammix.com/s
* 桌面端根host,如 https://www.teammix.com/s
*/
*/
desktopHost
?:
string
desktopHost
?:
string
;
}
}
/**
/**
...
@@ -79,84 +79,84 @@ export class PcMobileTransformer {
...
@@ -79,84 +79,84 @@ export class PcMobileTransformer {
public
static
setup
(
option
:
PcMobileTransformerOption
)
{
public
static
setup
(
option
:
PcMobileTransformerOption
)
{
if
(
option
.
desktopHost
)
{
if
(
option
.
desktopHost
)
{
PcMobileTransformer
.
target
=
TransformTarget
.
Desktop
PcMobileTransformer
.
target
=
TransformTarget
.
Desktop
;
PcMobileTransformer
.
host
=
PcMobileTransformer
.
trimEnd
(
PcMobileTransformer
.
host
=
PcMobileTransformer
.
trimEnd
(
option
.
desktopHost
option
.
desktopHost
)
)
;
}
}
if
(
option
.
mobileHost
)
{
if
(
option
.
mobileHost
)
{
PcMobileTransformer
.
target
=
TransformTarget
.
Mobile
PcMobileTransformer
.
target
=
TransformTarget
.
Mobile
;
PcMobileTransformer
.
host
=
PcMobileTransformer
.
trimEnd
(
PcMobileTransformer
.
host
=
PcMobileTransformer
.
trimEnd
(
option
.
mobileHost
option
.
mobileHost
)
)
;
}
}
}
}
public
static
isNeed2Redirect
()
{
public
static
isNeed2Redirect
()
{
if
(
PcMobileTransformer
.
target
===
TransformTarget
.
Mobile
)
{
if
(
PcMobileTransformer
.
target
===
TransformTarget
.
Mobile
)
{
return
PcMobileTransformer
.
isMobileDevice
()
return
PcMobileTransformer
.
isMobileDevice
()
;
}
}
return
false
return
false
;
}
}
private
static
trimEnd
(
input
:
string
)
{
private
static
trimEnd
(
input
:
string
)
{
if
(
input
&&
input
.
endsWith
(
"/"
))
{
if
(
input
&&
input
.
endsWith
(
"/"
))
{
return
input
.
substring
(
0
,
input
.
length
-
1
)
return
input
.
substring
(
0
,
input
.
length
-
1
)
;
}
}
return
input
return
input
;
}
}
private
static
isMobileDevice
()
{
private
static
isMobileDevice
()
{
const
ua
=
window
.
navigator
.
userAgent
const
ua
=
window
.
navigator
.
userAgent
;
return
UserAgentHelper
.
isMobile
(
ua
)
return
UserAgentHelper
.
isMobile
(
ua
)
;
}
}
public
static
transform
(
public
static
transform
(
parameters
:
(
string
|
number
)[],
parameters
:
(
string
|
number
)[],
target
:
TransformDirection
target
:
TransformDirection
)
{
)
{
let
v
=
""
let
v
=
""
;
if
(
PcMobileTransformer
.
target
===
TransformTarget
.
Desktop
)
{
if
(
PcMobileTransformer
.
target
===
TransformTarget
.
Desktop
)
{
v
=
PcMobileTransformer
.
transform2Desktop
(
parameters
,
target
)
v
=
PcMobileTransformer
.
transform2Desktop
(
parameters
,
target
)
;
}
}
if
(
PcMobileTransformer
.
target
===
TransformTarget
.
Mobile
)
{
if
(
PcMobileTransformer
.
target
===
TransformTarget
.
Mobile
)
{
v
=
PcMobileTransformer
.
transform2Mobile
(
parameters
,
target
)
v
=
PcMobileTransformer
.
transform2Mobile
(
parameters
,
target
)
;
}
}
return
v
.
replace
(
/
\.
html/gi
,
""
)
return
v
.
replace
(
/
\.
html/gi
,
""
)
;
}
}
private
static
transform2Mobile
(
private
static
transform2Mobile
(
parameters
:
(
string
|
number
)[],
parameters
:
(
string
|
number
)[],
target
:
TransformDirection
target
:
TransformDirection
)
{
)
{
const
url
=
PcMobileTransformer
.
desktop2MobileMapping
.
get
(
target
)
const
url
=
PcMobileTransformer
.
desktop2MobileMapping
.
get
(
target
)
;
if
(
url
)
{
if
(
url
)
{
let
targetUrl
=
`
${
PcMobileTransformer
.
host
}${
url
}
`
let
targetUrl
=
`
${
PcMobileTransformer
.
host
}${
url
}
`
;
for
(
let
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
targetUrl
=
targetUrl
.
replace
(
`{
${
i
}
}`
,
parameters
[
i
]
+
""
)
targetUrl
=
targetUrl
.
replace
(
`{
${
i
}
}`
,
parameters
[
i
]
+
""
)
;
}
}
return
targetUrl
return
targetUrl
;
}
}
const
base
=
PcMobileTransformer
.
rebuildMapping
.
get
(
target
)
const
base
=
PcMobileTransformer
.
rebuildMapping
.
get
(
target
)
;
if
(
base
)
{
if
(
base
)
{
let
rebuildUrl
=
base
let
rebuildUrl
=
base
;
for
(
let
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
rebuildUrl
=
rebuildUrl
.
replace
(
`{
${
i
}
}`
,
parameters
[
i
]
+
""
)
rebuildUrl
=
rebuildUrl
.
replace
(
`{
${
i
}
}`
,
parameters
[
i
]
+
""
)
;
}
}
return
`
${
PcMobileTransformer
.
host
}${
rebuildUrl
}
`
return
`
${
PcMobileTransformer
.
host
}${
rebuildUrl
}
`
;
}
}
return
PcMobileTransformer
.
host
return
PcMobileTransformer
.
host
;
}
}
private
static
transform2Desktop
(
private
static
transform2Desktop
(
parameters
:
(
string
|
number
)[],
parameters
:
(
string
|
number
)[],
target
:
TransformDirection
target
:
TransformDirection
)
{
)
{
return
target
+
""
return
target
+
""
;
}
}
}
}
third-party/seo/index.ts
View file @
84b48c2e
...
@@ -4,24 +4,24 @@ export class SeoHelper {
...
@@ -4,24 +4,24 @@ export class SeoHelper {
title
&&
title
&&
(
title
.
indexOf
(
"TeamMix"
)
>
-
1
||
title
.
indexOf
(
"亲亲小站"
)
>
-
1
)
(
title
.
indexOf
(
"TeamMix"
)
>
-
1
||
title
.
indexOf
(
"亲亲小站"
)
>
-
1
)
)
{
)
{
return
title
return
title
;
}
}
return
`
${
title
||
""
}
-亲亲小站`
return
`
${
title
||
""
}
-亲亲小站`
;
}
}
public
static
updateFavicon
(
path
:
string
)
{
public
static
updateFavicon
(
path
:
string
)
{
const
link
=
document
.
querySelector
(
const
link
=
document
.
querySelector
(
"link[rel*='icon']"
"link[rel*='icon']"
)
as
HTMLLinkElement
)
as
HTMLLinkElement
;
if
(
link
)
{
if
(
link
)
{
link
.
href
=
path
link
.
href
=
path
;
}
else
{
}
else
{
const
l
=
document
.
createElement
(
"link"
)
const
l
=
document
.
createElement
(
"link"
)
;
l
.
type
=
"image/x-icon"
l
.
type
=
"image/x-icon"
;
l
.
rel
=
"shortcut icon"
l
.
rel
=
"shortcut icon"
;
l
.
href
=
path
l
.
href
=
path
;
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
l
)
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
l
)
;
}
}
}
}
}
}
third-party/user-agent/index.ts
View file @
84b48c2e
...
@@ -39,79 +39,79 @@ export const enum UserAgentType {
...
@@ -39,79 +39,79 @@ export const enum UserAgentType {
export
class
UserAgentHelper
{
export
class
UserAgentHelper
{
private
static
contains
(
source
:
string
,
match
:
string
)
{
private
static
contains
(
source
:
string
,
match
:
string
)
{
return
source
.
indexOf
(
match
)
>
-
1
return
source
.
indexOf
(
match
)
>
-
1
;
}
}
private
static
containsAll
(
source
:
string
,
matches
:
string
[])
{
private
static
containsAll
(
source
:
string
,
matches
:
string
[])
{
for
(
const
item
of
matches
)
{
for
(
const
item
of
matches
)
{
if
(
!
UserAgentHelper
.
contains
(
source
,
item
))
{
if
(
!
UserAgentHelper
.
contains
(
source
,
item
))
{
return
false
return
false
;
}
}
}
}
return
true
return
true
;
}
}
private
static
containsAny
(
source
:
string
,
matches
:
string
[])
{
private
static
containsAny
(
source
:
string
,
matches
:
string
[])
{
for
(
const
item
of
matches
)
{
for
(
const
item
of
matches
)
{
if
(
UserAgentHelper
.
contains
(
source
,
item
))
{
if
(
UserAgentHelper
.
contains
(
source
,
item
))
{
return
true
return
true
;
}
}
}
}
return
false
return
false
;
}
}
public
static
getType
(
ua
:
string
)
{
public
static
getType
(
ua
:
string
)
{
const
lower
=
ua
.
toLowerCase
()
const
lower
=
ua
.
toLowerCase
()
;
if
(
UserAgentHelper
.
contains
(
lower
,
"ipad"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"ipad"
))
{
return
UserAgentType
.
IPad
return
UserAgentType
.
IPad
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"android_tablet"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"android_tablet"
))
{
return
UserAgentType
.
Tablet
return
UserAgentType
.
Tablet
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"iphone"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"iphone"
))
{
return
UserAgentType
.
IPhone
return
UserAgentType
.
IPhone
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"ipod"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"ipod"
))
{
return
UserAgentType
.
IPhone
return
UserAgentType
.
IPhone
;
}
}
if
(
UserAgentHelper
.
containsAny
(
lower
,
[
"android"
,
"mobile"
]))
{
if
(
UserAgentHelper
.
containsAny
(
lower
,
[
"android"
,
"mobile"
]))
{
return
UserAgentType
.
Andriod
return
UserAgentType
.
Andriod
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"safari"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"safari"
))
{
return
UserAgentType
.
DesktopSafari
return
UserAgentType
.
DesktopSafari
;
}
}
if
(
UserAgentHelper
.
containsAny
(
lower
,
[
"edge"
,
"edg"
]))
{
if
(
UserAgentHelper
.
containsAny
(
lower
,
[
"edge"
,
"edg"
]))
{
return
UserAgentType
.
DesktopEdge
return
UserAgentType
.
DesktopEdge
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"trident"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"trident"
))
{
return
UserAgentType
.
DesktopIE
return
UserAgentType
.
DesktopIE
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"firefox"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"firefox"
))
{
return
UserAgentType
.
DesktopFirefox
return
UserAgentType
.
DesktopFirefox
;
}
}
if
(
UserAgentHelper
.
contains
(
lower
,
"chrome"
))
{
if
(
UserAgentHelper
.
contains
(
lower
,
"chrome"
))
{
return
UserAgentType
.
DesktopChrome
return
UserAgentType
.
DesktopChrome
;
}
}
if
(
UserAgentHelper
.
containsAny
(
lower
,
[
"360"
,
"baidu"
,
"qq"
]))
{
if
(
UserAgentHelper
.
containsAny
(
lower
,
[
"360"
,
"baidu"
,
"qq"
]))
{
return
UserAgentType
.
DesktopOthers
return
UserAgentType
.
DesktopOthers
;
}
}
return
UserAgentType
.
None
return
UserAgentType
.
None
;
}
}
public
static
isMobile
(
ua
:
string
)
{
public
static
isMobile
(
ua
:
string
)
{
const
type
=
UserAgentHelper
.
getType
(
ua
)
const
type
=
UserAgentHelper
.
getType
(
ua
)
;
return
type
===
UserAgentType
.
Andriod
||
type
===
UserAgentType
.
IPhone
return
type
===
UserAgentType
.
Andriod
||
type
===
UserAgentType
.
IPhone
;
}
}
}
}
utils/jwt/index.ts
View file @
84b48c2e
function
b64DecodeUnicode
(
str
:
string
)
{
function
b64DecodeUnicode
(
str
:
string
)
{
return
decodeURIComponent
(
return
decodeURIComponent
(
atob
(
str
).
replace
(
/
(
.
)
/g
,
function
(
m
,
p
)
{
atob
(
str
).
replace
(
/
(
.
)
/g
,
function
(
m
,
p
)
{
let
code
=
p
.
charCodeAt
(
0
).
toString
(
16
).
toUpperCase
()
let
code
=
p
.
charCodeAt
(
0
).
toString
(
16
).
toUpperCase
()
;
if
(
code
.
length
<
2
)
{
if
(
code
.
length
<
2
)
{
code
=
"0"
+
code
code
=
"0"
+
code
;
}
}
return
"%"
+
code
return
"%"
+
code
;
})
})
)
)
;
}
}
function
base64_url_decode
(
str
:
string
)
{
function
base64_url_decode
(
str
:
string
)
{
let
output
=
str
.
replace
(
/-/g
,
"+"
).
replace
(
/_/g
,
"/"
)
let
output
=
str
.
replace
(
/-/g
,
"+"
).
replace
(
/_/g
,
"/"
)
;
switch
(
output
.
length
%
4
)
{
switch
(
output
.
length
%
4
)
{
case
0
:
case
0
:
break
break
;
case
2
:
case
2
:
output
+=
"=="
output
+=
"=="
;
break
break
;
case
3
:
case
3
:
output
+=
"="
output
+=
"="
;
break
break
;
default
:
default
:
throw
"Illegal base64url string!"
throw
"Illegal base64url string!"
;
}
}
try
{
try
{
return
b64DecodeUnicode
(
output
)
return
b64DecodeUnicode
(
output
)
;
}
catch
{
}
catch
{
return
atob
(
output
)
return
atob
(
output
)
;
}
}
}
}
export
function
decode
(
token
:
string
)
{
export
function
decode
(
token
:
string
)
{
return
JSON
.
parse
(
base64_url_decode
(
token
.
split
(
"."
)[
1
]))
return
JSON
.
parse
(
base64_url_decode
(
token
.
split
(
"."
)[
1
]))
;
}
}
utils/time/index.ts
View file @
84b48c2e
const
STANDARD
=
Math
.
pow
(
10
,
12
)
const
STANDARD
=
Math
.
pow
(
10
,
12
)
;
const
ONE_DAY_TICKS
=
86400000
const
ONE_DAY_TICKS
=
86400000
;
const
ONE_MINUTE_TICKS
=
60
*
1000
const
ONE_MINUTE_TICKS
=
60
*
1000
;
const
ONE_HOUR_TICKS
=
60
*
60
*
1000
const
ONE_HOUR_TICKS
=
60
*
60
*
1000
;
export
const
enum
TimeFormatRule
{
export
const
enum
TimeFormatRule
{
/**
/**
...
@@ -17,43 +17,43 @@ export const enum TimeFormatRule {
...
@@ -17,43 +17,43 @@ export const enum TimeFormatRule {
function
formatHour2Friendly
(
hour
:
number
)
{
function
formatHour2Friendly
(
hour
:
number
)
{
if
(
hour
<=
1
)
{
if
(
hour
<=
1
)
{
return
"凌晨"
return
"凌晨"
;
}
}
if
(
hour
<
12
)
{
if
(
hour
<
12
)
{
return
"上午"
return
"上午"
;
}
}
if
(
hour
===
12
)
{
if
(
hour
===
12
)
{
return
"中午"
return
"中午"
;
}
}
if
(
hour
<
20
)
{
if
(
hour
<
20
)
{
return
"下午"
return
"下午"
;
}
}
return
"晚上"
return
"晚上"
;
}
}
function
formatHour12Unit
(
hour
:
number
,
rule
:
TimeFormatRule
)
{
function
formatHour12Unit
(
hour
:
number
,
rule
:
TimeFormatRule
)
{
if
(
rule
===
TimeFormatRule
.
Hour12
)
{
if
(
rule
===
TimeFormatRule
.
Hour12
)
{
return
hour
>
12
?
hour
-
12
:
hour
return
hour
>
12
?
hour
-
12
:
hour
;
}
}
return
hour
return
hour
;
}
}
function
format2DetailTime
(
hour
:
number
,
time
:
Date
,
rule
:
TimeFormatRule
)
{
function
format2DetailTime
(
hour
:
number
,
time
:
Date
,
rule
:
TimeFormatRule
)
{
let
hourString
=
""
let
hourString
=
""
;
const
h
=
formatHour12Unit
(
hour
,
rule
)
const
h
=
formatHour12Unit
(
hour
,
rule
)
;
if
(
h
<
10
)
{
if
(
h
<
10
)
{
hourString
=
"0"
+
h
hourString
=
"0"
+
h
;
}
else
{
}
else
{
hourString
=
h
+
""
hourString
=
h
+
""
;
}
}
let
minuteString
=
""
let
minuteString
=
""
;
const
m
=
time
.
getMinutes
()
const
m
=
time
.
getMinutes
()
;
if
(
m
<
10
)
{
if
(
m
<
10
)
{
minuteString
=
"0"
+
m
minuteString
=
"0"
+
m
;
}
else
{
}
else
{
minuteString
=
""
+
m
minuteString
=
""
+
m
;
}
}
return
`
${
formatHour2Friendly
(
hour
)}
${
hourString
}
:
${
minuteString
}
`
return
`
${
formatHour2Friendly
(
hour
)}
${
hourString
}
:
${
minuteString
}
`
;
}
}
function
isSameDay
(
d1
:
Date
,
d2
:
Date
)
{
function
isSameDay
(
d1
:
Date
,
d2
:
Date
)
{
...
@@ -61,43 +61,43 @@ function isSameDay(d1: Date, d2: Date) {
...
@@ -61,43 +61,43 @@ function isSameDay(d1: Date, d2: Date) {
d1
.
getFullYear
()
===
d2
.
getFullYear
()
&&
d1
.
getFullYear
()
===
d2
.
getFullYear
()
&&
d1
.
getMonth
()
===
d2
.
getMonth
()
&&
d1
.
getMonth
()
===
d2
.
getMonth
()
&&
d1
.
getDate
()
===
d2
.
getDate
()
d1
.
getDate
()
===
d2
.
getDate
()
)
)
;
}
}
function
isInMinute
(
d1
:
Date
,
d2
:
Date
)
{
function
isInMinute
(
d1
:
Date
,
d2
:
Date
)
{
return
Math
.
abs
(
d1
.
valueOf
()
-
d2
.
valueOf
())
<=
ONE_MINUTE_TICKS
return
Math
.
abs
(
d1
.
valueOf
()
-
d2
.
valueOf
())
<=
ONE_MINUTE_TICKS
;
}
}
function
isInHour
(
d1
:
Date
,
d2
:
Date
)
{
function
isInHour
(
d1
:
Date
,
d2
:
Date
)
{
return
Math
.
abs
(
d1
.
valueOf
()
-
d2
.
valueOf
())
<
ONE_HOUR_TICKS
return
Math
.
abs
(
d1
.
valueOf
()
-
d2
.
valueOf
())
<
ONE_HOUR_TICKS
;
}
}
function
isYesterday
(
date
:
Date
)
{
function
isYesterday
(
date
:
Date
)
{
const
now
=
new
Date
()
const
now
=
new
Date
()
;
now
.
setHours
(
0
)
now
.
setHours
(
0
)
;
now
.
setMinutes
(
0
)
now
.
setMinutes
(
0
)
;
now
.
setSeconds
(
0
)
now
.
setSeconds
(
0
)
;
now
.
setMilliseconds
(
0
)
now
.
setMilliseconds
(
0
)
;
const
ticks
=
now
.
valueOf
()
const
ticks
=
now
.
valueOf
()
;
const
yesterday
=
ticks
-
ONE_DAY_TICKS
const
yesterday
=
ticks
-
ONE_DAY_TICKS
;
const
v
=
date
.
valueOf
()
const
v
=
date
.
valueOf
()
;
return
v
>=
yesterday
&&
v
<
ticks
return
v
>=
yesterday
&&
v
<
ticks
;
}
}
function
isIn6Days
(
date
:
Date
)
{
function
isIn6Days
(
date
:
Date
)
{
const
now
=
new
Date
()
const
now
=
new
Date
()
;
now
.
setHours
(
0
)
now
.
setHours
(
0
)
;
now
.
setMinutes
(
0
)
now
.
setMinutes
(
0
)
;
now
.
setSeconds
(
0
)
now
.
setSeconds
(
0
)
;
now
.
setMilliseconds
(
0
)
now
.
setMilliseconds
(
0
)
;
const
ticks
=
now
.
valueOf
()
const
ticks
=
now
.
valueOf
()
;
const
sixDaysAgo
=
ticks
-
ONE_DAY_TICKS
*
6
const
sixDaysAgo
=
ticks
-
ONE_DAY_TICKS
*
6
;
const
v
=
date
.
valueOf
()
const
v
=
date
.
valueOf
()
;
return
v
>=
sixDaysAgo
&&
v
<
ticks
return
v
>=
sixDaysAgo
&&
v
<
ticks
;
}
}
function
isSameYear
(
d1
:
Date
,
d2
:
Date
)
{
function
isSameYear
(
d1
:
Date
,
d2
:
Date
)
{
return
d1
.
getFullYear
()
===
d2
.
getFullYear
()
return
d1
.
getFullYear
()
===
d2
.
getFullYear
()
;
}
}
const
DAY_MAPPING
:
{
[
key
:
number
]:
string
}
=
{
const
DAY_MAPPING
:
{
[
key
:
number
]:
string
}
=
{
...
@@ -108,39 +108,39 @@ const DAY_MAPPING: { [key: number]: string } = {
...
@@ -108,39 +108,39 @@ const DAY_MAPPING: { [key: number]: string } = {
4
:
"四"
,
4
:
"四"
,
5
:
"五"
,
5
:
"五"
,
6
:
"六"
,
6
:
"六"
,
}
}
;
function
getDayInWeek
(
time
:
Date
)
{
function
getDayInWeek
(
time
:
Date
)
{
const
d
=
time
.
getDay
()
const
d
=
time
.
getDay
()
;
return
DAY_MAPPING
[
d
]
return
DAY_MAPPING
[
d
]
;
}
}
function
formatWithTwoNumber
(
number
:
number
)
{
function
formatWithTwoNumber
(
number
:
number
)
{
return
number
<
10
?
`0
${
number
}
`
:
`
${
number
}
`
return
number
<
10
?
`0
${
number
}
`
:
`
${
number
}
`
;
}
}
function
formatTime2MonthDate
(
time
:
Date
)
{
function
formatTime2MonthDate
(
time
:
Date
)
{
return
`
${
formatWithTwoNumber
(
time
.
getMonth
()
+
1
)}
月
${
formatWithTwoNumber
(
return
`
${
formatWithTwoNumber
(
time
.
getMonth
()
+
1
)}
月
${
formatWithTwoNumber
(
time
.
getDate
()
time
.
getDate
()
)}
日`
)}
日`
;
}
}
function
formatTime2ShortMonthDate
(
time
:
Date
)
{
function
formatTime2ShortMonthDate
(
time
:
Date
)
{
return
`
${
formatWithTwoNumber
(
time
.
getMonth
()
+
1
)}
/
${
formatWithTwoNumber
(
return
`
${
formatWithTwoNumber
(
time
.
getMonth
()
+
1
)}
/
${
formatWithTwoNumber
(
time
.
getDate
()
time
.
getDate
()
)}
`
)}
`
;
}
}
function
formatTime2YearMonthDate
(
time
:
Date
)
{
function
formatTime2YearMonthDate
(
time
:
Date
)
{
return
`
${
time
.
getFullYear
()}
年
${
formatWithTwoNumber
(
return
`
${
time
.
getFullYear
()}
年
${
formatWithTwoNumber
(
time
.
getMonth
()
+
1
time
.
getMonth
()
+
1
)}
月
${
formatWithTwoNumber
(
time
.
getDate
())}
日`
)}
月
${
formatWithTwoNumber
(
time
.
getDate
())}
日`
;
}
}
function
formatTime2ShortYearMonthDate
(
time
:
Date
)
{
function
formatTime2ShortYearMonthDate
(
time
:
Date
)
{
return
`
${
time
.
getFullYear
()}
/
${
formatWithTwoNumber
(
return
`
${
time
.
getFullYear
()}
/
${
formatWithTwoNumber
(
time
.
getMonth
()
+
1
time
.
getMonth
()
+
1
)}
/
${
formatWithTwoNumber
(
time
.
getDate
())}
`
)}
/
${
formatWithTwoNumber
(
time
.
getDate
())}
`
;
}
}
/**
/**
...
@@ -160,63 +160,63 @@ export function formatTime(
...
@@ -160,63 +160,63 @@ export function formatTime(
option
=
{
rule
:
TimeFormatRule
.
Hour12
,
short
:
false
}
option
=
{
rule
:
TimeFormatRule
.
Hour12
,
short
:
false
}
)
{
)
{
if
(
time
<
STANDARD
)
{
if
(
time
<
STANDARD
)
{
time
*=
1000
time
*=
1000
;
}
}
const
t
=
new
Date
(
time
)
const
t
=
new
Date
(
time
)
;
const
now
=
new
Date
()
const
now
=
new
Date
()
;
if
(
!
option
.
short
)
{
if
(
!
option
.
short
)
{
if
(
isInMinute
(
t
,
now
))
{
if
(
isInMinute
(
t
,
now
))
{
return
"刚刚"
return
"刚刚"
;
}
}
if
(
isInHour
(
t
,
now
))
{
if
(
isInHour
(
t
,
now
))
{
return
`
${
Math
.
round
(
return
`
${
Math
.
round
(
Math
.
abs
(
t
.
valueOf
()
-
now
.
valueOf
())
/
1000
/
60
Math
.
abs
(
t
.
valueOf
()
-
now
.
valueOf
())
/
1000
/
60
)}
分钟前`
)}
分钟前`
;
}
}
}
}
const
hour
=
t
.
getHours
()
const
hour
=
t
.
getHours
()
;
if
(
isSameDay
(
t
,
now
))
{
if
(
isSameDay
(
t
,
now
))
{
return
format2DetailTime
(
hour
,
t
,
option
.
rule
)
return
format2DetailTime
(
hour
,
t
,
option
.
rule
)
;
}
}
if
(
isYesterday
(
t
))
{
if
(
isYesterday
(
t
))
{
if
(
option
.
short
)
{
if
(
option
.
short
)
{
return
"昨天"
return
"昨天"
;
}
}
return
"昨天 "
+
format2DetailTime
(
hour
,
t
,
option
.
rule
)
return
"昨天 "
+
format2DetailTime
(
hour
,
t
,
option
.
rule
)
;
}
}
if
(
isIn6Days
(
t
))
{
if
(
isIn6Days
(
t
))
{
if
(
option
.
short
)
{
if
(
option
.
short
)
{
return
`星期
${
getDayInWeek
(
t
)}
`
return
`星期
${
getDayInWeek
(
t
)}
`
;
}
}
return
(
return
(
`星期
${
getDayInWeek
(
t
)}
`
+
format2DetailTime
(
hour
,
t
,
option
.
rule
)
`星期
${
getDayInWeek
(
t
)}
`
+
format2DetailTime
(
hour
,
t
,
option
.
rule
)
)
)
;
}
}
if
(
isSameYear
(
t
,
now
))
{
if
(
isSameYear
(
t
,
now
))
{
if
(
option
.
short
)
{
if
(
option
.
short
)
{
return
formatTime2ShortMonthDate
(
t
)
return
formatTime2ShortMonthDate
(
t
)
;
}
}
return
(
return
(
formatTime2MonthDate
(
t
)
+
formatTime2MonthDate
(
t
)
+
" "
+
" "
+
format2DetailTime
(
hour
,
t
,
option
.
rule
)
format2DetailTime
(
hour
,
t
,
option
.
rule
)
)
)
;
}
}
if
(
option
.
short
)
{
if
(
option
.
short
)
{
return
formatTime2ShortYearMonthDate
(
t
)
return
formatTime2ShortYearMonthDate
(
t
)
;
}
}
return
(
return
(
formatTime2YearMonthDate
(
t
)
+
formatTime2YearMonthDate
(
t
)
+
" "
+
" "
+
format2DetailTime
(
hour
,
t
,
option
.
rule
)
format2DetailTime
(
hour
,
t
,
option
.
rule
)
)
)
;
}
}
xim/chat-type.ts
View file @
84b48c2e
export
default
"group"
export
default
"group"
;
xim/index.ts
View file @
84b48c2e
import
xim
from
"./xim"
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
;
import
{
ChatOption
,
TokenStringGetter
}
from
"./../model"
import
{
ChatLoggerService
}
from
"./logger"
import
{
EmojiService
}
from
"../service/emoji"
;
import
{
EmojiService
}
from
"../service/emoji"
import
tokenManager
from
"./token"
import
{
ChatOption
,
TokenStringGetter
}
from
"./../model"
;
import
type
{
UniplatSdk
}
from
"uniplat-sdk"
import
{
ChatLoggerService
}
from
"./logger"
;
import
tokenManager
from
"./token"
;
import
xim
from
"./xim"
;
class
Chat
{
class
Chat
{
private
_sdk
?:
()
=>
UniplatSdk
private
_sdk
?:
()
=>
UniplatSdk
private
_orgId
:
()
=>
string
|
number
=
()
=>
"0"
private
_orgId
:
()
=>
string
|
number
=
()
=>
"0"
...
@@ -11,11 +14,12 @@ class Chat {
...
@@ -11,11 +14,12 @@ class Chat {
private
userMapping
:
{
[
key
:
string
]:
{
name
:
string
;
avatar
:
string
}
}
=
private
userMapping
:
{
[
key
:
string
]:
{
name
:
string
;
avatar
:
string
}
}
=
{}
{}
private
webHost
=
false
private
webHost
=
false
public
async
setup
(
option
:
ChatOption
)
{
public
async
setup
(
option
:
ChatOption
)
{
if
(
!
option
)
{
if
(
!
option
)
{
throw
new
Error
(
`You must specify a chat option for chat service`
)
throw
new
Error
(
`You must specify a chat option for chat service`
)
;
}
}
// if (!option.userTokenString) {
// if (!option.userTokenString) {
// throw new Error(`You must specify a user token for chat service`)
// throw new Error(`You must specify a user token for chat service`)
...
@@ -23,75 +27,75 @@ class Chat {
...
@@ -23,75 +27,75 @@ class Chat {
if
(
!
option
.
webSocketUri
)
{
if
(
!
option
.
webSocketUri
)
{
throw
new
Error
(
throw
new
Error
(
`You must specify a web socket address for chat service`
`You must specify a web socket address for chat service`
)
)
;
}
}
this
.
_sdk
=
option
.
sdk
this
.
_sdk
=
option
.
sdk
;
this
.
_orgId
=
option
.
orgId
this
.
_orgId
=
option
.
orgId
;
// if (option.enterpriseTokenString) {
// if (option.enterpriseTokenString) {
// this.token = option.enterpriseTokenString
// this.token = option.enterpriseTokenString
// } else {
// } else {
this
.
token
=
option
.
userTokenString
this
.
token
=
option
.
userTokenString
;
tokenManager
.
save
(
this
.
token
)
tokenManager
.
save
(
this
.
token
)
;
// }
// }
EmojiService
.
raiseOnReady
(
this
.
token
)
EmojiService
.
raiseOnReady
(
this
.
token
)
;
return
this
.
initChatSdk
(
option
.
webSocketUri
)
return
this
.
initChatSdk
(
option
.
webSocketUri
)
;
}
}
public
getSdk
=
()
=>
{
public
getSdk
=
()
=>
{
if
(
this
.
_sdk
==
null
)
return
if
(
this
.
_sdk
==
null
)
return
;
return
this
.
_sdk
()
return
this
.
_sdk
()
;
}
}
public
getOrgId
=
()
=>
{
public
getOrgId
=
()
=>
{
return
this
.
_orgId
()
return
this
.
_orgId
()
;
}
}
public
isWebHost
()
{
public
isWebHost
()
{
return
this
.
webHost
return
this
.
webHost
;
}
}
private
trimToken
(
token
:
string
)
{
private
trimToken
(
token
:
string
)
{
return
token
.
replace
(
/^Bearer
\s
/
,
""
)
return
token
.
replace
(
/^Bearer
\s
/
,
""
)
;
}
}
public
async
getToken
()
{
public
async
getToken
()
{
return
this
.
trimToken
(
await
this
.
token
())
return
this
.
trimToken
(
await
this
.
token
())
;
}
}
private
async
initChatSdk
(
uri
:
string
)
{
private
async
initChatSdk
(
uri
:
string
)
{
if
(
xim
.
isConnected
())
{
if
(
xim
.
isConnected
())
{
return
uri
return
uri
;
}
}
return
new
Promise
((
resolve
:
(
p
?:
unknown
)
=>
void
)
=>
{
return
new
Promise
((
resolve
:
(
p
?:
unknown
)
=>
void
)
=>
{
xim
.
open
(
uri
,
this
.
token
)
xim
.
open
(
uri
,
this
.
token
)
;
this
.
registerXimEvent
(
resolve
)
this
.
registerXimEvent
(
resolve
)
;
})
})
;
}
}
public
registerXimEvent
(
onConnected
?:
()
=>
void
)
{
public
registerXimEvent
(
onConnected
?:
()
=>
void
)
{
xim
.
off
(
"status"
,
(
e
)
=>
this
.
raiseOnStatusChanged
(
e
,
onConnected
))
xim
.
off
(
"status"
,
(
e
)
=>
this
.
raiseOnStatusChanged
(
e
,
onConnected
))
;
xim
.
on
(
"status"
,
(
e
)
=>
this
.
raiseOnStatusChanged
(
e
,
onConnected
))
xim
.
on
(
"status"
,
(
e
)
=>
this
.
raiseOnStatusChanged
(
e
,
onConnected
))
;
}
}
private
raiseOnStatusChanged
(
e
:
any
,
onConnected
?:
()
=>
void
)
{
private
raiseOnStatusChanged
(
e
:
any
,
onConnected
?:
()
=>
void
)
{
if
(
e
===
"CONNECTED"
)
{
if
(
e
===
"CONNECTED"
)
{
if
(
onConnected
)
{
if
(
onConnected
)
{
onConnected
()
onConnected
()
;
}
}
}
}
this
.
debug
(
`client status
${
e
}
`
)
this
.
debug
(
`client status
${
e
}
`
)
;
}
}
public
getUserMapping
()
{
public
getUserMapping
()
{
return
{}
return
{}
;
}
}
private
debug
(
message
:
string
)
{
private
debug
(
message
:
string
)
{
ChatLoggerService
.
logger
?.
debug
(
message
)
ChatLoggerService
.
logger
?.
debug
(
message
)
;
}
}
}
}
export
default
new
Chat
()
export
default
new
Chat
()
;
xim/logger.ts
View file @
84b48c2e
import
{
ChatServiceLogger
}
from
"../model"
import
{
ChatServiceLogger
}
from
"../model"
;
export
class
ChatLoggerService
{
export
class
ChatLoggerService
{
public
static
logger
=
console
public
static
logger
=
console
...
...
xim/models/chat.ts
View file @
84b48c2e
export
interface
Chat
{
export
interface
Chat
{
type
:
string
type
:
string
;
chat_id
:
number
chat_id
:
number
;
service_id
:
number
service_id
:
number
;
title
:
string
title
:
string
;
// tag: string;
// tag: string;
// ext: string;
// ext: string;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
// exit_msg_id: number;
// exit_msg_id: number;
// is_exited: boolean;
// is_exited: boolean;
// dnd: number;
// dnd: number;
is_top
:
boolean
is_top
:
boolean
;
// label: string;
// label: string;
// join_msg_id: number;
// join_msg_id: number;
// last_read_msg_id: number;
// last_read_msg_id: number;
...
@@ -22,62 +22,62 @@ export interface Chat {
...
@@ -22,62 +22,62 @@ export interface Chat {
// is_remove: boolean;
// is_remove: boolean;
// member_type: number;
// member_type: number;
// ref_id: number;
// ref_id: number;
unread_msg_count
:
number
unread_msg_count
:
number
;
// at_me: boolean;
// at_me: boolean;
// at_all: boolean;
// at_all: boolean;
// last_login_oid: string;
// last_login_oid: string;
last_msg_eid
:
string
last_msg_eid
:
string
;
last_msg_name
:
string
last_msg_name
:
string
;
last_msg_ts
:
number
last_msg_ts
:
number
;
msg_id
:
number
msg_id
:
number
;
msg_type
:
string
msg_type
:
string
;
msg
:
string
msg
:
string
;
}
}
export
interface
Message
{
export
interface
Message
{
chat_id
:
number
chat_id
:
number
;
oid
:
string
oid
:
string
;
eid
:
string
eid
:
string
;
id
:
number
id
:
number
;
ts
:
number
ts
:
number
;
type
:
string
type
:
string
;
msg
:
string
msg
:
string
;
total_read_count
:
number
total_read_count
:
number
;
read_count
:
number
read_count
:
number
;
like_count
:
number
like_count
:
number
;
ref_id
:
number
ref_id
:
number
;
at_id
:
string
at_id
:
string
;
is_read
:
boolean
is_read
:
boolean
;
like
:
boolean
like
:
boolean
;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
status
:
number
status
:
number
;
url
:
string
url
:
string
;
is_open
:
boolean
is_open
:
boolean
;
}
}
export
interface
NotifyMessage
{
export
interface
NotifyMessage
{
chat_type
:
string
chat_type
:
string
;
chat_id
:
number
chat_id
:
number
;
eid
:
string
eid
:
string
;
ts
:
number
ts
:
number
;
msg_type
:
string
msg_type
:
string
;
msg
:
string
msg
:
string
;
}
}
export
interface
Member
{
export
interface
Member
{
chat_id
:
number
chat_id
:
number
;
oid
:
string
oid
:
string
;
eid
:
string
eid
:
string
;
type
:
number
type
:
number
;
is_exited
:
boolean
is_exited
:
boolean
;
is_remove
:
boolean
is_remove
:
boolean
;
is_top
:
boolean
is_top
:
boolean
;
label
:
string
label
:
string
;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
nick_name
:
string
nick_name
:
string
;
}
}
/**
/**
...
@@ -119,102 +119,102 @@ export type ChatInputBoxData = { key: string } & (
...
@@ -119,102 +119,102 @@ export type ChatInputBoxData = { key: string } & (
)
)
export
type
TextMessageBody
=
{
export
type
TextMessageBody
=
{
text
:
string
text
:
string
;
}
}
export
type
FileMessageBody
=
{
export
type
FileMessageBody
=
{
name
:
string
name
:
string
;
url
:
string
// 生消息是本地path,熟消息是文件url_id
url
:
string
;
// 生消息是本地path,熟消息是文件url_id
size
:
number
// number, 可选,文件大小:单位-字节
size
:
number
;
// number, 可选,文件大小:单位-字节
remark
:
string
remark
:
string
;
isNeedUploaded
?:
boolean
// pc客户端自定义属性(只有生消息的消息体才有该属性, 值为false时不需要上传, true和undefined时需要上传)
isNeedUploaded
?:
boolean
;
// pc客户端自定义属性(只有生消息的消息体才有该属性, 值为false时不需要上传, true和undefined时需要上传)
source
?:
{
source
?:
{
source_type
:
number
//
来源类型(若为团队小站文件,则来源类型为团队小站文件)
source_type
:
number
;
//
来源类型(若为团队小站文件,则来源类型为团队小站文件)
source_id
:
number
//
来源id(若为团队小站文件,此处为团队工作站id)
source_id
:
number
;
//
来源id(若为团队小站文件,此处为团队工作站id)
source_name
:
string
//
来源名称(若为团队小站文件,此处传入团队小站名称)
source_name
:
string
;
//
来源名称(若为团队小站文件,此处传入团队小站名称)
source_icon
:
string
//
来源图标(若为团队小站文件,此处传入团队icon的url)
source_icon
:
string
;
//
来源图标(若为团队小站文件,此处传入团队icon的url)
extra
?:
{
[
prop
:
string
]:
any
}
//
附加信息
extra
?:
{
[
prop
:
string
]:
any
}
;
//
附加信息
}
}
;
}
}
export
type
ImageMessageBody
=
{
export
type
ImageMessageBody
=
{
name
:
string
name
:
string
;
url
:
string
url
:
string
;
size
:
number
size
:
number
;
w
:
number
w
:
number
;
h
:
number
h
:
number
;
thumbnail
?:
string
// 缩略图地址
thumbnail
?:
string
;
// 缩略图地址
preview
?:
string
// 预览图地址
preview
?:
string
;
// 预览图地址
remark
:
string
remark
:
string
;
}
}
export
type
VoiceMessageBody
=
{
export
type
VoiceMessageBody
=
{
name
:
string
name
:
string
;
url
:
string
url
:
string
;
size
:
number
size
:
number
;
duration
:
number
// 语音时间:单位-ms
duration
:
number
;
// 语音时间:单位-ms
}
}
//第一顺序 default_text 第二顺序 operator_text、receiver_text
//
第一顺序 default_text 第二顺序 operator_text、receiver_text
export
type
NotifyMessageBody
=
{
export
type
NotifyMessageBody
=
{
operator_id
:
string
operator_id
:
string
;
receiver_ids
:
string
[]
receiver_ids
:
string
[]
;
default_text
:
string
//
默认文本
default_text
:
string
;
//
默认文本
operator_text
:
string
//
操作人文本
operator_text
:
string
;
//
操作人文本
receiver_text
:
string
//
处理人文本
receiver_text
:
string
;
//
处理人文本
}
}
export
type
TextNoticeMessageBody
=
{
export
type
TextNoticeMessageBody
=
{
title
:
string
title
:
string
;
text
:
string
text
:
string
;
is_at_all
:
boolean
//
是否@全部人
is_at_all
:
boolean
;
//
是否@全部人
}
}
export
type
VideoMessageBody
=
{
export
type
VideoMessageBody
=
{
name
:
string
name
:
string
;
url
:
string
// 生消息是本地path,熟消息是文件url_id
url
:
string
;
// 生消息是本地path,熟消息是文件url_id
size
:
number
size
:
number
;
cover
?:
string
cover
?:
string
;
duration
:
number
duration
:
number
;
w
:
number
w
:
number
;
h
:
number
h
:
number
;
isNeedUploaded
?:
boolean
// pc客户端自定义属性(只有生消息的消息体才有该属性, 值为false时不需要上传, true和undefined时需要上传)
isNeedUploaded
?:
boolean
;
// pc客户端自定义属性(只有生消息的消息体才有该属性, 值为false时不需要上传, true和undefined时需要上传)
}
}
export
type
UrlMessageBody
=
{
export
type
UrlMessageBody
=
{
title
:
string
title
:
string
;
icon
:
string
icon
:
string
;
url
:
string
url
:
string
;
desc
:
string
desc
:
string
;
source
?:
{
source
?:
{
source_type
:
number
//
来源类型(若为团队小站文件,则来源类型为团队小站文件)
source_type
:
number
;
//
来源类型(若为团队小站文件,则来源类型为团队小站文件)
source_id
:
number
//
来源id(若为团队小站文件,此处为团队工作站id)
source_id
:
number
;
//
来源id(若为团队小站文件,此处为团队工作站id)
source_name
:
string
//
来源名称(若为团队小站文件,此处传入团队小站名称)
source_name
:
string
;
//
来源名称(若为团队小站文件,此处传入团队小站名称)
source_icon
:
string
//
来源图标(若为团队小站文件,此处传入团队icon的url)
source_icon
:
string
;
//
来源图标(若为团队小站文件,此处传入团队icon的url)
extra
?:
{
[
prop
:
string
]:
any
}
//
附加信息
extra
?:
{
[
prop
:
string
]:
any
}
;
//
附加信息
}
}
;
}
}
export
type
ForwardMessageBody
=
{
export
type
ForwardMessageBody
=
{
snap
:
string
snap
:
string
;
chat_type
:
string
//
会话类型
chat_type
:
string
;
//
会话类型
chat_id
:
number
// 会话id
chat_id
:
number
;
// 会话id
msg_ids
:
number
[]
//
消息id集合
msg_ids
:
number
[]
;
//
消息id集合
}
}
export
type
QuoteMessageBody
=
{
export
type
QuoteMessageBody
=
{
text
:
string
text
:
string
;
quote_text
:
string
// JSON字符串
quote_text
:
string
;
// JSON字符串
quote_msg_type
:
string
quote_msg_type
:
string
;
quote_eid
:
string
quote_eid
:
string
;
quote_msg_id
:
number
//
引用id
quote_msg_id
:
number
;
//
引用id
}
}
export
type
CommentForwardMessageBody
=
{
export
type
CommentForwardMessageBody
=
{
snap
:
string
snap
:
string
;
channel_id
:
number
//
团队工作站id
channel_id
:
number
;
//
团队工作站id
topic_id
:
number
// 主题id
topic_id
:
number
;
// 主题id
comment_ids
:
number
[]
//
评论id集合
comment_ids
:
number
[]
;
//
评论id集合
}
}
// export type SpecifiedChatRecordMsg = SpecifiedChatRecord & {
// export type SpecifiedChatRecordMsg = SpecifiedChatRecord & {
...
@@ -229,21 +229,21 @@ export type CommentForwardMessageBody = {
...
@@ -229,21 +229,21 @@ export type CommentForwardMessageBody = {
// 客服
// 客服
export
interface
CsUser
{
export
interface
CsUser
{
id
:
number
id
:
number
;
oid
:
string
oid
:
string
;
eid
:
string
eid
:
string
;
is_deleted
:
boolean
is_deleted
:
boolean
;
delete_time
:
number
delete_time
:
number
;
delete_oid
:
string
delete_oid
:
string
;
delete_eid
:
string
delete_eid
:
string
;
service_id
:
number
service_id
:
number
;
type
:
number
type
:
number
;
name
:
string
name
:
string
;
mobile
:
string
mobile
:
string
;
email
:
string
email
:
string
;
description
:
string
description
:
string
;
create_time
:
number
create_time
:
number
;
update_time
:
number
update_time
:
number
;
chat_count
:
number
chat_count
:
number
;
status
:
number
status
:
number
;
}
}
xim/models/user.ts
View file @
84b48c2e
...
@@ -5,9 +5,9 @@ export enum UserType {
...
@@ -5,9 +5,9 @@ export enum UserType {
}
}
export
default
interface
User
{
export
default
interface
User
{
uid
:
string
uid
:
string
;
oid
:
string
oid
:
string
;
eid
:
string
eid
:
string
;
jwt
:
string
jwt
:
string
;
userType
:
UserType
userType
:
UserType
;
}
}
;;;;;;;;;;
xim/token.ts
View file @
84b48c2e
import
{
ChatOption
,
TokenStringGetter
}
from
"./../model"
import
{
ChatOption
,
TokenStringGetter
}
from
"./../model"
;
function
Token
()
{
function
Token
()
{
let
_token
:
TokenStringGetter
let
_token
:
TokenStringGetter
;
return
{
return
{
save
(
token
:
TokenStringGetter
)
{
save
(
token
:
TokenStringGetter
)
{
_token
=
token
_token
=
token
;
},
},
getToken
()
{
getToken
()
{
return
_token
()
return
_token
()
;
},
},
}
}
;
}
}
export
default
Token
()
export
default
Token
()
;
xim/xim.ts
View file @
84b48c2e
import
Vue
from
"vue"
import
Vue
from
"vue"
;
import
{
XChatClient
,
wampDebug
}
from
"xchat-client"
import
{
wampDebug
,
XChatClient
}
from
"xchat-client"
;
import
{
NotifyMessage
,
Message
}
from
"./models/chat"
import
{
ChatLoggerService
}
from
"./logger"
import
{
TokenStringGetter
}
from
"./../model"
import
chatType
from
"../xim/chat-type"
wampDebug
(
true
)
import
chatType
from
"../xim/chat-type"
;
const
DefaultMsgPageSize
=
20
import
{
TokenStringGetter
}
from
"./../model"
;
import
{
ChatLoggerService
}
from
"./logger"
;
import
{
Message
,
NotifyMessage
}
from
"./models/chat"
;
wampDebug
(
true
);
const
DefaultMsgPageSize
=
20
;
function
emptyFunc
()
{
function
emptyFunc
()
{
return
}
}
export
type
MsgListener
=
(
msg
:
Message
)
=>
void
export
type
MsgListener
=
(
msg
:
Message
)
=>
void
...
@@ -36,69 +38,69 @@ export class Xim {
...
@@ -36,69 +38,69 @@ export class Xim {
private
client
?:
XChatClient
private
client
?:
XChatClient
private
paramsForReconnection
?:
{
private
paramsForReconnection
?:
{
url
:
string
url
:
string
;
token
:
TokenStringGetter
token
:
TokenStringGetter
;
}
}
public
close
()
{
public
close
()
{
if
(
this
.
client
)
{
if
(
this
.
client
)
{
if
(
this
.
client
.
connected
)
{
if
(
this
.
client
.
connected
)
{
this
.
client
.
close
()
this
.
client
.
close
()
;
}
}
this
.
client
.
onconnected
=
emptyFunc
this
.
client
.
onconnected
=
emptyFunc
;
this
.
client
.
onmsg
=
emptyFunc
this
.
client
.
onmsg
=
emptyFunc
;
this
.
client
=
undefined
this
.
client
=
undefined
;
}
}
}
}
private
connectionPending
=
false
private
connectionPending
=
false
public
async
open
(
url
:
string
,
token
:
TokenStringGetter
)
{
public
async
open
(
url
:
string
,
token
:
TokenStringGetter
)
{
this
.
connectionPending
=
true
this
.
connectionPending
=
true
;
await
new
Promise
((
success
:
(
p
?:
unknown
)
=>
void
,
failed
)
=>
{
await
new
Promise
((
success
:
(
p
?:
unknown
)
=>
void
,
failed
)
=>
{
this
.
paramsForReconnection
=
{
url
,
token
}
this
.
paramsForReconnection
=
{
url
,
token
}
;
this
.
close
()
this
.
close
()
;
token
().
then
((
t
)
=>
{
token
().
then
((
t
)
=>
{
const
client
=
new
XChatClient
(
url
,
this
.
trimToken
(
t
))
const
client
=
new
XChatClient
(
url
,
this
.
trimToken
(
t
))
;
this
.
client
=
client
this
.
client
=
client
;
client
.
onstatuschange
=
(
status
:
any
,
details
:
any
)
=>
{
client
.
onstatuschange
=
(
status
:
any
,
details
:
any
)
=>
{
this
.
onStatusChange
.
call
(
this
,
status
,
details
)
this
.
onStatusChange
.
call
(
this
,
status
,
details
)
;
if
(
status
===
"DISCONNECTED"
||
status
===
"CLOSED"
)
{
if
(
status
===
"DISCONNECTED"
||
status
===
"CLOSED"
)
{
failed
()
failed
()
;
}
}
}
}
;
client
.
onconnected
=
()
=>
{
client
.
onconnected
=
()
=>
{
this
.
onConnected
.
apply
(
this
)
this
.
onConnected
.
apply
(
this
)
;
success
()
success
()
;
}
}
;
client
.
onmsg
=
this
.
handleMsg
.
bind
(
this
)
client
.
onmsg
=
this
.
handleMsg
.
bind
(
this
)
;
client
.
open
()
client
.
open
()
;
})
})
;
}).
finally
(()
=>
(
this
.
connectionPending
=
false
))
}).
finally
(()
=>
(
this
.
connectionPending
=
false
))
;
}
}
private
trimToken
(
token
:
string
)
{
private
trimToken
(
token
:
string
)
{
return
token
.
replace
(
/^Bearer
\s
/
,
""
)
return
token
.
replace
(
/^Bearer
\s
/
,
""
)
;
}
}
/**
/**
* token过期或者切换用户登录时,需要设置新的token
* token过期或者切换用户登录时,需要设置新的token
*/
*/
public
async
setToken
(
token
:
TokenStringGetter
)
{
public
async
setToken
(
token
:
TokenStringGetter
)
{
const
client
=
this
.
client
!
const
client
=
this
.
client
!
;
client
.
close
()
client
.
close
()
;
client
.
setToken
(
this
.
trimToken
(
await
token
()))
client
.
setToken
(
this
.
trimToken
(
await
token
()))
;
client
.
open
()
client
.
open
()
;
}
}
public
fetchMsgInBox
(
chatId
:
number
,
msgId
:
number
)
{
public
fetchMsgInBox
(
chatId
:
number
,
msgId
:
number
)
{
return
this
.
client
!
.
fetchMsgInBox
(
chatType
,
chatId
,
msgId
)
return
this
.
client
!
.
fetchMsgInBox
(
chatType
,
chatId
,
msgId
)
;
}
}
/**
/**
...
@@ -110,23 +112,23 @@ export class Xim {
...
@@ -110,23 +112,23 @@ export class Xim {
msgType
:
string
,
msgType
:
string
,
msg
:
string
msg
:
string
)
{
)
{
this
.
checkConnected
()
this
.
checkConnected
()
;
return
this
.
client
!
.
sendMsg
(
chatType
,
chatId
,
msgType
,
msg
,
""
,
{})
return
this
.
client
!
.
sendMsg
(
chatType
,
chatId
,
msgType
,
msg
,
""
,
{})
;
}
}
public
inputing
(
chatId
:
number
)
{
public
inputing
(
chatId
:
number
)
{
this
.
checkConnected
()
this
.
checkConnected
()
;
return
this
.
client
!
.
userInput
(
chatType
,
chatId
)
return
this
.
client
!
.
userInput
(
chatType
,
chatId
)
;
}
}
/*
/*
* 查询会话
* 查询会话
*/
*/
public
fetchChatMembers
(
chat_id
:
number
)
{
public
fetchChatMembers
(
chat_id
:
number
)
{
this
.
checkConnected
()
this
.
checkConnected
()
;
return
this
.
client
!
.
fetchChatMembers
(
chat_id
)
return
this
.
client
!
.
fetchChatMembers
(
chat_id
)
;
}
}
/**
/**
...
@@ -140,19 +142,19 @@ export class Xim {
...
@@ -140,19 +142,19 @@ export class Xim {
limit
=
DefaultMsgPageSize
,
limit
=
DefaultMsgPageSize
,
desc
=
true
desc
=
true
):
Promise
<
Message
[]
>
{
):
Promise
<
Message
[]
>
{
this
.
checkConnected
()
this
.
checkConnected
()
;
const
res
=
await
this
.
client
!
.
fetchChatMsgs
(
chatType
,
chatId
,
{
const
res
=
await
this
.
client
!
.
fetchChatMsgs
(
chatType
,
chatId
,
{
lid
,
lid
,
rid
,
rid
,
limit
,
limit
,
desc
,
desc
,
})
})
;
return
res
.
args
[
0
]
return
res
.
args
[
0
]
;
}
}
private
setMessagesRead
(
chatId
:
number
,
msg
:
Message
[])
{
private
setMessagesRead
(
chatId
:
number
,
msg
:
Message
[])
{
if
(
msg
.
length
===
0
)
return
if
(
msg
.
length
===
0
)
return
;
return
this
.
setRead
(
chatId
,
msg
[
0
].
id
,
msg
[
msg
.
length
-
1
].
id
)
return
this
.
setRead
(
chatId
,
msg
[
0
].
id
,
msg
[
msg
.
length
-
1
].
id
)
;
}
}
/** 查询最后一页消息 */
/** 查询最后一页消息 */
...
@@ -161,9 +163,9 @@ export class Xim {
...
@@ -161,9 +163,9 @@ export class Xim {
chatId
:
number
,
chatId
:
number
,
limit
:
number
limit
:
number
)
{
)
{
const
data
=
await
this
.
queryMsgs
(
chatType
,
chatId
,
0
,
0
,
limit
,
true
)
const
data
=
await
this
.
queryMsgs
(
chatType
,
chatId
,
0
,
0
,
limit
,
true
)
;
this
.
setMessagesRead
(
chatId
,
data
)
this
.
setMessagesRead
(
chatId
,
data
)
;
return
data
return
data
;
}
}
/** 查询上一页消息 */
/** 查询上一页消息 */
...
@@ -180,9 +182,9 @@ export class Xim {
...
@@ -180,9 +182,9 @@ export class Xim {
msgId
,
msgId
,
limit
,
limit
,
true
true
)
)
;
this
.
setMessagesRead
(
chatId
,
data
)
this
.
setMessagesRead
(
chatId
,
data
)
;
return
data
return
data
;
}
}
/** 查询下一页消息 */
/** 查询下一页消息 */
...
@@ -199,9 +201,9 @@ export class Xim {
...
@@ -199,9 +201,9 @@ export class Xim {
0
,
0
,
limit
,
limit
,
false
false
)
)
;
this
.
setMessagesRead
(
chatId
,
data
)
this
.
setMessagesRead
(
chatId
,
data
)
;
return
data
return
data
;
}
}
public
on
(
event
:
"msg"
,
chatId
:
number
,
listener
:
MsgListener
):
this
public
on
(
event
:
"msg"
,
chatId
:
number
,
listener
:
MsgListener
):
this
...
@@ -211,16 +213,18 @@ export class Xim {
...
@@ -211,16 +213,18 @@ export class Xim {
kind
:
"chat_change"
,
kind
:
"chat_change"
,
listener
:
ChatNotifyListener
listener
:
ChatNotifyListener
):
this
):
this
public
on
(
public
on
(
event
:
"chat_notify"
,
event
:
"chat_notify"
,
kind
:
string
,
kind
:
string
,
listener
:
ChatNotifyListener
listener
:
ChatNotifyListener
):
this
):
this
public
on
(
event
:
"chat_notify"
,
listener
:
ChatNotifyListener
):
this
public
on
(
event
:
"chat_notify"
,
listener
:
ChatNotifyListener
):
this
public
on
(
event
:
"status"
,
listener
:
StatusChangeListener
):
this
public
on
(
event
:
"status"
,
listener
:
StatusChangeListener
):
this
public
on
(...
args
:
any
[]):
this
{
public
on
(...
args
:
any
[]):
this
{
this
.
eventBus
.
$on
(...
this
.
parseEventListener
(...
args
))
this
.
eventBus
.
$on
(...
this
.
parseEventListener
(...
args
))
;
return
this
return
this
;
}
}
public
off
(
event
:
"msg"
,
chatId
:
number
,
listener
:
MsgListener
):
this
public
off
(
event
:
"msg"
,
chatId
:
number
,
listener
:
MsgListener
):
this
...
@@ -230,119 +234,121 @@ export class Xim {
...
@@ -230,119 +234,121 @@ export class Xim {
kind
:
"chat_change"
,
kind
:
"chat_change"
,
listener
:
ChatNotifyListener
listener
:
ChatNotifyListener
):
this
):
this
public
off
(
public
off
(
event
:
"chat_notify"
,
event
:
"chat_notify"
,
kind
:
string
,
kind
:
string
,
listener
:
ChatNotifyListener
listener
:
ChatNotifyListener
):
this
):
this
public
off
(
event
:
"chat_notify"
,
listener
:
ChatNotifyListener
):
this
public
off
(
event
:
"chat_notify"
,
listener
:
ChatNotifyListener
):
this
public
off
(
event
:
"status"
,
listener
:
StatusChangeListener
):
this
public
off
(
event
:
"status"
,
listener
:
StatusChangeListener
):
this
public
off
(...
args
:
any
[]):
this
{
public
off
(...
args
:
any
[]):
this
{
this
.
eventBus
.
$off
(...
this
.
parseEventListener
(...
args
))
this
.
eventBus
.
$off
(...
this
.
parseEventListener
(...
args
))
;
return
this
return
this
;
}
}
public
once
(...
args
:
any
[]):
this
{
public
once
(...
args
:
any
[]):
this
{
this
.
eventBus
.
$once
(...
this
.
parseEventListener
(...
args
))
this
.
eventBus
.
$once
(...
this
.
parseEventListener
(...
args
))
;
return
this
return
this
;
}
}
public
emit
(
event
:
string
,
...
args
:
any
[]):
this
{
public
emit
(
event
:
string
,
...
args
:
any
[]):
this
{
this
.
eventBus
.
$emit
(
event
,
...
args
)
this
.
eventBus
.
$emit
(
event
,
...
args
)
;
return
this
return
this
;
}
}
/**
/**
* 移除会话(用户端/移动端使用)
* 移除会话(用户端/移动端使用)
*/
*/
public
async
closeChat
(
chatId
:
number
)
{
public
async
closeChat
(
chatId
:
number
)
{
return
this
.
client
?.
setChat
(
chatId
,
{
is_remove
:
true
})
return
this
.
client
?.
setChat
(
chatId
,
{
is_remove
:
true
})
;
}
}
public
isConnected
()
{
public
isConnected
()
{
return
this
.
client
?.
connected
return
this
.
client
?.
connected
;
}
}
public
setRead
(
chatId
:
number
,
start_msg_id
:
number
,
end_msg_id
:
number
)
{
public
setRead
(
chatId
:
number
,
start_msg_id
:
number
,
end_msg_id
:
number
)
{
return
this
.
client
?.
syncReadMsg
(
chatId
,
start_msg_id
,
end_msg_id
)
return
this
.
client
?.
syncReadMsg
(
chatId
,
start_msg_id
,
end_msg_id
)
;
}
}
private
parseEventListener
(...
args
:
any
[]):
[
string
,
Function
]
{
private
parseEventListener
(...
args
:
any
[]):
[
string
,
Function
]
{
if
(
args
.
length
<
2
)
{
if
(
args
.
length
<
2
)
{
throw
new
Error
(
"参数个数不正确"
)
throw
new
Error
(
"参数个数不正确"
)
;
}
}
const
listener
:
Function
=
args
[
args
.
length
-
1
]
const
listener
:
Function
=
args
[
args
.
length
-
1
]
;
return
[
args
.
slice
(
0
,
-
1
).
join
(
"."
),
listener
]
return
[
args
.
slice
(
0
,
-
1
).
join
(
"."
),
listener
]
;
}
}
private
onConnected
()
{
private
onConnected
()
{
// 连接成功后,需要调用pubUserInfo, 否则服务端会认为此连接无效
// 连接成功后,需要调用pubUserInfo, 否则服务端会认为此连接无效
this
.
client
!
.
pubUserInfo
(
""
)
this
.
client
!
.
pubUserInfo
(
""
)
;
this
.
debug
(
"xim connected"
)
this
.
debug
(
"xim connected"
)
;
}
}
/*
/*
DISCONNECTED: "DISCONNECTED",
DISCONNECTED: "DISCONNECTED",
CONNECTING: "CONNECTING",
CONNECTING: "CONNECTING",
CONNECTED: "CONNECTED",
CONNECTED: "CONNECTED",
CLOSED: "CLOSED",
CLOSED: "CLOSED",
*/
*/
private
onStatusChange
(
status
:
any
,
details
:
any
)
{
private
onStatusChange
(
status
:
any
,
details
:
any
)
{
this
.
debug
(
"onstatuschange"
,
status
,
details
)
this
.
debug
(
"onstatuschange"
,
status
,
details
)
;
this
.
emit
(
Events
.
Status
,
status
,
details
)
this
.
emit
(
Events
.
Status
,
status
,
details
)
;
if
(
status
===
"DISCONNECTED"
||
status
===
"CLOSED"
)
{
if
(
status
===
"DISCONNECTED"
||
status
===
"CLOSED"
)
{
this
.
hanldeOffline
()
this
.
hanldeOffline
()
;
}
}
}
}
private
hanldeOffline
()
{
private
hanldeOffline
()
{
this
.
debug
(
"开始重连"
)
this
.
debug
(
"开始重连"
)
;
this
.
reOpen
()
this
.
reOpen
()
;
}
}
private
reOpen
()
{
private
reOpen
()
{
if
(
this
.
connectionPending
)
return
if
(
this
.
connectionPending
)
return
;
if
(
this
.
paramsForReconnection
==
null
)
return
if
(
this
.
paramsForReconnection
==
null
)
return
;
this
.
open
(
this
.
open
(
this
.
paramsForReconnection
.
url
,
this
.
paramsForReconnection
.
url
,
this
.
paramsForReconnection
.
token
this
.
paramsForReconnection
.
token
)
)
;
}
}
private
handleMsg
(
kind
:
any
,
msg
:
any
)
{
private
handleMsg
(
kind
:
any
,
msg
:
any
)
{
this
.
debug
(
`收到消息
${
new
Date
().
getTime
()}
`
,
kind
,
msg
)
this
.
debug
(
`收到消息
${
new
Date
().
getTime
()}
`
,
kind
,
msg
)
;
switch
(
kind
)
{
switch
(
kind
)
{
case
"chat"
:
case
"chat"
:
this
.
emit
(
`msg`
,
msg
)
this
.
emit
(
`msg`
,
msg
)
;
this
.
emit
(
`msg.
${
msg
.
chat_id
}
`
,
msg
)
this
.
emit
(
`msg.
${
msg
.
chat_id
}
`
,
msg
)
;
break
break
;
case
"chat_notify"
:
case
"chat_notify"
:
this
.
emit
(
`chat_notify`
,
msg
)
this
.
emit
(
`chat_notify`
,
msg
)
;
this
.
emit
(
`chat_notify.
${
msg
.
msg_type
}
`
,
msg
)
this
.
emit
(
`chat_notify.
${
msg
.
msg_type
}
`
,
msg
)
;
break
break
;
default
:
default
:
this
.
emit
(
kind
,
msg
)
this
.
emit
(
kind
,
msg
)
;
}
}
}
}
private
checkConnected
()
{
private
checkConnected
()
{
if
(
!
this
.
client
!
.
connected
)
{
if
(
!
this
.
client
!
.
connected
)
{
try
{
try
{
this
.
client
?.
open
()
this
.
client
?.
open
()
;
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
"checkConnected"
,
e
)
console
.
error
(
"checkConnected"
,
e
)
;
this
.
reOpen
()
this
.
reOpen
()
;
}
}
}
}
}
}
private
debug
(
message
:
any
,
...
params
:
any
[])
{
private
debug
(
message
:
any
,
...
params
:
any
[])
{
ChatLoggerService
.
logger
?.
debug
(
message
,
params
)
ChatLoggerService
.
logger
?.
debug
(
message
,
params
)
;
}
}
}
}
const
ximInstance
=
new
Xim
()
const
ximInstance
=
new
Xim
()
;
export
default
ximInstance
export
default
ximInstance
;
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