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
3a7d925d
authored
Nov 23, 2021
by
zhousil
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://gitlab.corp.qinqinxiaobao.com:9880/uniplat/customer-service
parents
cd93c141
ae5dedf7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
27 deletions
hybrid-input/index.vue
hybrid-input/index.vue
View file @
3a7d925d
...
...
@@ -22,7 +22,6 @@
for=
"chat-upload-file"
:title=
"tip4File"
@
click=
"allowLoadFile"
v-if=
"enableFileSelection"
>
<img
class=
"tool-bar-icon"
...
...
@@ -36,7 +35,6 @@
id=
"chat-upload-file"
type=
"file"
:accept=
"acceptType"
multiple
/>
</div>
...
...
@@ -121,6 +119,16 @@
);
}
const
limitedFileExtension
=
[
"ppt"
,
"pptx"
,
"doc"
,
"docx"
,
"xls"
,
"xlsx"
,
"pdf"
,
];
@
Component
({
components
:
{}
})
export
default
class
Input
extends
Vue
{
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
...
...
@@ -139,9 +147,6 @@
private
tip4Image
=
`发送图片(最大
${
MAX_IMAGE_SIZE_STRING
}
)`
;
private
tip4File
=
`发送文件(最大
${
MAX_FILE_SIZE_STRING
}
)`
;
private
readonly
enableFileSelection
=
window
.
location
.
host
.
includes
(
"localhost"
);
private
emoji
:
EmojiItem
[]
=
[];
@
Watch
(
"chatId"
)
...
...
@@ -202,7 +207,8 @@
}
private
allowLoadFile
()
{
this
.
acceptType
=
"*"
;
this
.
acceptType
=
limitedFileExtension
.
map
((
i
)
=>
`.
${
i
}
`
).
join
(
","
)
+
",image/*"
;
}
private
async
handlePasteEvent
(
event
:
ClipboardEvent
)
{
...
...
@@ -222,19 +228,22 @@
const
file
=
items
[
i
].
getAsFile
();
if
(
file
)
{
if
(
file
.
size
<=
0
)
{
this
.
$emit
(
"error"
,
MESSAGE_FILE_EMPTY
);
return
;
return
this
.
$emit
(
"error"
,
MESSAGE_FILE_EMPTY
);
}
if
(
this
.
isImage
(
file
))
{
if
(
file
.
size
>=
MAX_IMAGE_SIZE
)
{
this
.
$emit
(
"error"
,
MESSAGE_IMAGE_TOO_LARGE
);
return
;
return
this
.
$emit
(
"error"
,
MESSAGE_IMAGE_TOO_LARGE
);
}
html
+=
this
.
buildImageHtml
(
file
);
}
else
{
if
(
file
.
size
>=
MAX_FILE_SIZE
)
{
this
.
$emit
(
"error"
,
MESSAGE_FILE_TOO_LARGE
);
return
;
return
this
.
$emit
(
"error"
,
MESSAGE_FILE_TOO_LARGE
);
}
html
+=
this
.
buildFileHtml
(
file
);
}
...
...
@@ -498,30 +507,23 @@
for
(
let
index
=
0
;
index
<
files
.
length
;
index
++
)
{
const
file
=
files
[
index
];
if
(
file
.
size
<=
0
)
{
this
.
$emit
(
"error"
,
MESSAGE_FILE_EMPTY
);
return
;
return
this
.
$emit
(
"error"
,
MESSAGE_FILE_EMPTY
);
}
if
(
this
.
enableFileSelection
&&
file
.
size
>=
MAX_FILE_SIZE
)
{
this
.
$emit
(
"error"
,
MESSAGE_FILE_TOO_LARGE
);
return
;
if
(
file
.
size
>=
MAX_FILE_SIZE
)
{
return
this
.
$emit
(
"error"
,
MESSAGE_FILE_TOO_LARGE
);
}
if
(
this
.
isImage
(
file
))
{
if
(
file
.
size
>=
MAX_IMAGE_SIZE
)
{
this
.
$emit
(
"error"
,
MESSAGE_IMAGE_TOO_LARGE
);
return
;
return
this
.
$emit
(
"error"
,
MESSAGE_IMAGE_TOO_LARGE
);
}
html
+=
this
.
buildImageHtml
(
file
);
}
else
{
if
(
this
.
enableFileSelection
)
{
html
+=
this
.
buildFileHtml
(
file
);
}
else
{
return
this
.
$emit
(
"error"
,
ERROR_IMAGE
);
}
html
+=
this
.
buildFileHtml
(
file
);
}
}
...
...
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