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
7c3fe629
authored
Oct 08, 2021
by
zhousil
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
不同类型消息样式分离
parent
55070bdd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
218 additions
and
128 deletions
components/message-item/audio-message.vue
components/message-item/file-message.vue
components/message-item/image-message.vue
components/message-item/text-message.vue
components/message-item/video-message.vue
components/message-item/withdraw-message.vue
components/message.vue
components/message-item/audio-message.vue
View file @
7c3fe629
...
...
@@ -25,63 +25,87 @@
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Ref
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
VoiceIcon
from
"./voice.vue"
;
import
{
Component
,
Ref
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
VoiceIcon
from
"./voice.vue"
;
@
Component
({
components
:
{
VoiceIcon
}
})
export
default
class
Index
extends
BaseMessage
{
@
Ref
(
"audio"
)
private
readonly
audioRef
!
:
HTMLAudioElement
;
@
Component
({
components
:
{
VoiceIcon
}
})
export
default
class
Index
extends
BaseMessage
{
@
Ref
(
"audio"
)
private
readonly
audioRef
!
:
HTMLAudioElement
;
private
playing
=
false
;
private
playing
=
false
;
private
get
duration
()
{
const
v
=
this
.
messageBody
.
msg
.
duration
as
number
;
return
v
||
0
;
}
private
get
duration
()
{
const
v
=
this
.
messageBody
.
msg
.
duration
as
number
;
return
v
||
0
;
}
private
get
durationInSecond
()
{
return
Math
.
round
(
this
.
duration
/
1000
);
}
private
get
durationInSecond
()
{
return
Math
.
round
(
this
.
duration
/
1000
);
}
private
get
getVoiceMessageWidth
()
{
if
(
this
.
fileFailed2Load
)
{
return
35
;
private
get
getVoiceMessageWidth
()
{
if
(
this
.
fileFailed2Load
)
{
return
35
;
}
const
d
=
this
.
duration
/
1000
;
if
(
d
<=
3
)
{
return
60
;
}
if
(
d
>=
60
)
{
return
200
;
}
return
60
+
d
;
}
const
d
=
this
.
duration
/
1000
;
if
(
d
<=
3
)
{
return
60
;
private
play
()
{
if
(
this
.
audioRef
?.
paused
)
{
this
.
audioRef
?.
load
();
this
.
audioRef
?.
play
();
}
else
{
this
.
audioRef
?.
pause
();
}
}
if
(
d
>=
60
)
{
return
200
;
private
onPlay
(
)
{
this
.
playing
=
true
;
}
return
60
+
d
;
}
private
onPause
()
{
this
.
playing
=
false
;
}
private
play
()
{
if
(
this
.
audioRef
?.
paused
)
{
this
.
audioRef
?.
load
();
this
.
audioRef
?.
play
();
}
else
{
this
.
audioRef
?.
pause
();
mounted
()
{
this
.
buildMessageUrl
();
}
}
</
script
>
private
onPlay
()
{
this
.
playing
=
true
;
}
<
style
lang=
"less"
scoped
>
.voice-message
{
height
:
40px
;
width
:
200px
;
private
onPause
()
{
this
.
playing
=
false
;
}
&.can-play
{
cursor
:
pointer
;
}
mounted
()
{
this
.
buildMessageUrl
();
i
{
font-size
:
16px
;
}
}
}
</
script
>
.my-message
{
.voice-message
{
>
div
{
flex-flow
:
row-reverse
;
}
<
style
lang=
"less"
scoped
></
style
>
svg
{
transform
:
rotateY
(
180deg
);
}
}
}
</
style
>
components/message-item/file-message.vue
View file @
7c3fe629
...
...
@@ -30,60 +30,69 @@
</
template
>
<
script
lang=
"ts"
>
import
{
Component
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
FileIcon
from
"./file-icon.vue"
;
import
{
FileType
,
getFileType
}
from
"./file-controller"
;
import
{
Component
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
FileIcon
from
"./file-icon.vue"
;
import
{
FileType
,
getFileType
}
from
"./file-controller"
;
const
k
=
1024
,
m
=
1024
*
k
,
g
=
1024
*
m
,
t
=
1024
*
g
;
const
k
=
1024
,
m
=
1024
*
k
,
g
=
1024
*
m
,
t
=
1024
*
g
;
function
formatSize
(
size
:
number
)
{
if
(
size
===
undefined
||
size
===
null
)
{
return
""
;
}
if
(
size
<
k
)
{
return
size
+
" B"
;
}
if
(
size
<
m
)
{
return
Number
((
size
/
k
).
toFixed
(
2
))
+
" KB"
;
}
if
(
size
<
g
)
{
return
Number
((
size
/
m
).
toFixed
(
2
))
+
" MB"
;
}
if
(
size
<
t
)
{
return
Number
((
size
/
g
).
toFixed
(
2
))
+
" GB"
;
}
return
Number
((
size
/
t
).
toFixed
(
2
))
+
" TB"
;
}
@
Component
({
components
:
{
FileIcon
}
})
export
default
class
Index
extends
BaseMessage
{
private
get
getAttachment
()
{
if
(
this
.
messageBody
)
{
return
this
.
messageBody
.
msg
.
name
;
function
formatSize
(
size
:
number
)
{
if
(
size
===
undefined
||
size
===
null
)
{
return
""
;
}
if
(
size
<
k
)
{
return
size
+
" B"
;
}
if
(
size
<
m
)
{
return
Number
((
size
/
k
).
toFixed
(
2
))
+
" KB"
;
}
if
(
size
<
g
)
{
return
Number
((
size
/
m
).
toFixed
(
2
))
+
" MB"
;
}
return
"文件下载"
;
if
(
size
<
t
)
{
return
Number
((
size
/
g
).
toFixed
(
2
))
+
" GB"
;
}
return
Number
((
size
/
t
).
toFixed
(
2
))
+
" TB"
;
}
private
get
fileIcon
()
{
if
(
this
.
value
)
{
return
getFileType
(
this
.
messageBody
.
msg
.
name
);
@
Component
({
components
:
{
FileIcon
}
})
export
default
class
Index
extends
BaseMessage
{
private
get
getAttachment
()
{
if
(
this
.
messageBody
)
{
return
this
.
messageBody
.
msg
.
name
;
}
return
"文件下载"
;
}
return
FileType
.
Others
;
}
private
get
fileIcon
()
{
if
(
this
.
value
)
{
return
getFileType
(
this
.
messageBody
.
msg
.
name
);
}
private
format
(
v
:
number
)
{
return
formatSize
(
v
);
}
return
FileType
.
Others
;
}
mounted
()
{
this
.
buildMessageUrl
();
private
format
(
v
:
number
)
{
return
formatSize
(
v
);
}
mounted
()
{
this
.
buildMessageUrl
();
}
}
}
</
script
>
<
style
lang=
"less"
scoped
></
style
>
<
style
lang=
"less"
scoped
>
.file-message
{
background-color
:
transparent
!important
;
border-radius
:
4px
!important
;
border
:
1px
solid
#c5d4e5
;
.file-message-name
{
max-width
:
130px
;
}
}
</
style
>
components/message-item/image-message.vue
View file @
7c3fe629
...
...
@@ -16,24 +16,57 @@
</
template
>
<
script
lang=
"ts"
>
import
{
Component
}
from
"vue-property-decorator"
;
import
{
FileType
}
from
"./file-controller"
;
import
BaseMessage
from
"./index"
;
import
FileIcon
from
"./file-icon.vue"
;
import
{
Component
}
from
"vue-property-decorator"
;
import
{
FileType
}
from
"./file-controller"
;
import
BaseMessage
from
"./index"
;
import
FileIcon
from
"./file-icon.vue"
;
@
Component
({
components
:
{
FileIcon
}
})
export
default
class
Index
extends
BaseMessage
{
private
readonly
image404
=
FileType
.
Image_404
;
@
Component
({
components
:
{
FileIcon
}
})
export
default
class
Index
extends
BaseMessage
{
private
readonly
image404
=
FileType
.
Image_404
;
private
onImageError
()
{
this
.
fileFailed2Load
=
true
;
this
.
messageRealUrl
=
""
;
}
private
onImageError
()
{
this
.
fileFailed2Load
=
true
;
this
.
messageRealUrl
=
""
;
}
mounted
()
{
this
.
buildMessageUrl
();
mounted
()
{
this
.
buildMessageUrl
();
}
}
}
</
script
>
<
style
lang=
"less"
scoped
></
style
>
<
style
lang=
"less"
scoped
>
.image-message
{
background-color
:
transparent
!important
;
border-radius
:
4px
!important
;
border
:
1px
solid
#c5d4e5
;
line-height
:
1
;
max-width
:
300px
;
box-sizing
:
content-box
;
img
{
width
:
100%
;
}
&
.image-404
{
background
:
#f7f8fa
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
.file-icon
{
margin
:
0
;
}
}
/
deep
/
.file-icon
{
margin-left
:
0
;
}
}
.my-message
{
&.
image-message
:
not
(.
image-404
)
{
background-color
:
transparent
!important
;
border-radius
:
4px
!important
;
border
:
1px
solid
#c5d4e5
;
}
}
</
style
>
components/message-item/text-message.vue
View file @
7c3fe629
...
...
@@ -6,31 +6,34 @@
</
template
>
<
script
lang=
"ts"
>
import
{
replaceText2Link
}
from
"@/customer-service/utils"
;
import
xim
from
"@/customer-service/xim"
;
import
{
Component
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
{
replaceText2Link
}
from
"@/customer-service/utils"
;
import
xim
from
"@/customer-service/xim"
;
import
{
Component
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
@
Component
({
components
:
{}
})
export
default
class
Index
extends
BaseMessage
{
private
readonly
emptyText
=
" "
;
@
Component
({
components
:
{}
})
export
default
class
Index
extends
BaseMessage
{
private
readonly
emptyText
=
" "
;
private
format2Link
(
text
:
string
)
{
let
t
=
replaceText2Link
(
text
);
const
keywords
=
xim
.
getMatchedTextKeywords
();
for
(
const
item
of
keywords
)
{
const
r
=
new
RegExp
(
item
,
"g"
);
t
=
t
.
replace
(
r
,
`<span class="highlight">
${
item
}
</span>`
);
private
format2Link
(
text
:
string
)
{
let
t
=
replaceText2Link
(
text
);
const
keywords
=
xim
.
getMatchedTextKeywords
();
for
(
const
item
of
keywords
)
{
const
r
=
new
RegExp
(
item
,
"g"
);
t
=
t
.
replace
(
r
,
`<span class="highlight">
${
item
}
</span>`
);
}
return
t
;
}
return
t
;
}
}
</
script
>
<
style
lang=
"less"
scoped
>
.inline-text
{
/deep/
.highlight
{
color
:
#e87005
;
.inline-text
{
display
:
inline-block
;
white-space
:
pre-wrap
;
text-align
:
left
;
/deep/
.highlight
{
color
:
#e87005
;
}
}
}
</
style
>
</
style
>
\ No newline at end of file
components/message-item/video-message.vue
View file @
7c3fe629
...
...
@@ -25,4 +25,15 @@ export default class Index extends BaseMessage {
}
</
script
>
<
style
lang=
"less"
scoped
></
style
>
<
style
lang=
"less"
scoped
>
.video-message
{
height
:
160px
;
width
:
200px
;
background-color
:
#000
!important
;
border-radius
:
0
!important
;
svg
{
cursor
:
pointer
;
}
}
</
style
>
components/message-item/withdraw-message.vue
View file @
7c3fe629
...
...
@@ -3,11 +3,20 @@
</
template
>
<
script
lang=
"ts"
>
import
{
Component
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
{
Component
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
@
Component
({
components
:
{}
})
export
default
class
Index
extends
BaseMessage
{}
@
Component
({
components
:
{}
})
export
default
class
Index
extends
BaseMessage
{}
</
script
>
<
style
lang=
"less"
scoped
></
style
>
<
style
lang=
"less"
scoped
>
.my-message
{
.withdraw-message
{
background-color
:
transparent
!important
;
padding
:
0
4px
;
font-size
:
12px
;
color
:
#999
;
}
}
</
style
>
components/message.vue
View file @
7c3fe629
This diff is collapsed.
Click to expand it.
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