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
6476e76f
authored
Jan 14, 2022
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整缩约图
parent
de39e602
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
32 deletions
components/controller/index.ts
components/message-item/image-message.vue
store/index.ts
components/controller/index.ts
View file @
6476e76f
import
{
MessageType
}
from
"@/customer-service/model"
;
import
{
CardMessage
}
from
'@/customer-service/model/card'
;
import
{
CardMessage
}
from
"@/customer-service/model/card"
;
import
Chat
from
"@/customer-service/xim"
;
const
fsImg
=
/
(
fs
(
.*
))
/
;
const
mapping
=
new
Map
<
MessageType
,
string
>
([
[
MessageType
.
Image
,
'图片'
],
[
MessageType
.
Video
,
'视频'
],
[
MessageType
.
Voice
,
'语音'
],
[
MessageType
.
File
,
'文件'
],
[
MessageType
.
Withdraw
,
'撤回了一条消息'
],
[
MessageType
.
MyPurchasePlan
,
'我的采购计划'
],
[
MessageType
.
MyWelfare
,
'我的福利'
],
[
MessageType
.
QuestionAnswer
,
'问答'
],
[
MessageType
.
Pay
,
'付款通知'
],
[
MessageType
.
PayV1
,
'付款通知'
],
[
MessageType
.
Refund
,
'退款通知'
],
[
MessageType
.
RefundV1
,
'退款通知'
],
[
MessageType
.
Notify
,
'通知'
],
])
[
MessageType
.
Image
,
"图片"
],
[
MessageType
.
Video
,
"视频"
],
[
MessageType
.
Voice
,
"语音"
],
[
MessageType
.
File
,
"文件"
],
[
MessageType
.
Withdraw
,
"撤回了一条消息"
],
[
MessageType
.
MyPurchasePlan
,
"我的采购计划"
],
[
MessageType
.
MyWelfare
,
"我的福利"
],
[
MessageType
.
QuestionAnswer
,
"问答"
],
[
MessageType
.
Pay
,
"付款通知"
],
[
MessageType
.
PayV1
,
"付款通知"
],
[
MessageType
.
Refund
,
"退款通知"
],
[
MessageType
.
RefundV1
,
"退款通知"
],
[
MessageType
.
Notify
,
"通知"
],
])
;
export
function
parserMessage
(
type
:
MessageType
,
rawMsg
:
string
)
{
try
{
...
...
@@ -35,15 +38,28 @@ export function parserMessage(type: MessageType, rawMsg: string) {
if
(
type
===
MessageType
.
Card
)
{
const
p
=
JSON
.
parse
(
rawMsg
)
as
CardMessage
;
if
(
p
&&
p
.
title
)
{
return
p
.
title
||
'通知'
;
return
p
.
title
||
"通知"
;
}
}
const
t
=
mapping
.
get
(
type
)
const
t
=
mapping
.
get
(
type
)
;
if
(
t
)
{
return
`[
${
t
}
]`
;
}
return
`[系统自动回复]`
;
}
catch
{
return
""
return
""
;
}
}
export
function
rebuildImage
(
url
:
string
)
{
if
(
url
)
{
const
sdk
=
Chat
.
getSdk
();
const
s
=
sdk
.
mediaController
.
buildThumbnail
;
if
(
fsImg
.
test
(
url
))
{
const
m
=
fsImg
.
exec
(
url
);
return
sdk
.
global
.
baseUrl
+
s
(
m
[
0
],
300
);
}
return
url
;
}
return
""
;
}
components/message-item/image-message.vue
View file @
6476e76f
...
...
@@ -22,9 +22,7 @@
import
BaseMessage
from
"./index"
;
import
FileIcon
from
"./file-icon.vue"
;
import
{
UserAgentHelper
}
from
"@/customer-service/third-party/user-agent"
;
import
Chat
from
"@/customer-service/xim/"
;
const
fsImg
=
/
(
fs
(
.*
))
/
;
import
{
rebuildImage
}
from
"../controller"
;
@
Component
({
components
:
{
FileIcon
}
})
export
default
class
Index
extends
BaseMessage
{
...
...
@@ -35,16 +33,7 @@
);
private
get
mini
()
{
if
(
this
.
messageRealUrl
)
{
const
sdk
=
Chat
.
getSdk
();
const
s
=
sdk
.
mediaController
.
buildThumbnail
;
if
(
fsImg
.
test
(
this
.
messageRealUrl
))
{
const
m
=
fsImg
.
exec
(
this
.
messageRealUrl
);
return
sdk
.
global
.
baseUrl
+
s
(
m
[
0
],
300
);
}
return
this
.
messageRealUrl
;
}
return
""
;
return
rebuildImage
(
this
.
messageRealUrl
);
}
private
onImageError
()
{
...
...
store/index.ts
View file @
6476e76f
...
...
@@ -21,6 +21,7 @@ import { decodeJwt } from "uniplat-sdk";
import
{
ChatStatus
,
ChatStore
,
ChatStoreState
}
from
"./model"
;
import
{
RootStoreState
}
from
"@/store/model"
;
import
{
rebuildImage
}
from
"../components/controller"
;
export
const
ns
=
ChatStore
.
ns
;
...
...
@@ -71,7 +72,7 @@ async function preCacheImgs(msgs?: any[]) {
typeof
Image
!==
"undefined"
)
{
const
preCache
=
new
Image
();
preCache
.
src
=
url
;
preCache
.
src
=
rebuildImage
(
url
)
;
preCache
.
onload
=
()
=>
resolve
();
setTimeout
(
resolve
,
2000
);
}
else
{
...
...
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