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