Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ai_web_page_prod
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
ai_web_page_prod
Commits
0747fc0d
Commit
0747fc0d
authored
May 10, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
57a7202c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
4 deletions
+45
-4
src/components/custom/CustomForm.vue
+5
-1
src/components/custom/upload/index.tsx
+40
-2
src/utils/api/Task.ts
+0
-1
No files found.
src/components/custom/CustomForm.vue
View file @
0747fc0d
...
...
@@ -68,7 +68,11 @@
></LocalUpload>
</
template
>
<
template
v-else-if=
"it.component_type == 'upload'"
>
<CustomUpload
v-model=
"it.value"
:config=
"config"
></CustomUpload>
<CustomUpload
v-model=
"it.value"
:config=
"config"
:rules=
"it.rules"
></CustomUpload>
</
template
>
<
template
v-else-if=
"it.component_type == 'label'"
>
<CustomAddTag
...
...
src/components/custom/upload/index.tsx
View file @
0747fc0d
...
...
@@ -17,6 +17,7 @@ export default defineComponent({
props
:
{
modelValue
:
String
,
config
:
Object
as
any
,
rules
:
Array
,
},
emits
:
[
'update:modelValue'
],
setup
(
props
,
{
emit
})
{
...
...
@@ -44,13 +45,50 @@ export default defineComponent({
percentage
.
value
+=
1
;
},
100
);
};
const
beforeUpload
=
(
file
:
File
)
=>
{
// 获取文件尺寸
const
getFileSize
=
async
(
file
:
any
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// 获取文件尺寸
let
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
reader
.
onload
=
async
(
e
:
any
)
=>
{
let
data
=
e
.
target
.
result
;
let
image
=
new
Image
();
image
.
src
=
data
;
image
.
onload
=
()
=>
{
resolve
(
`
${
image
.
width
}
,
${
image
.
height
}
`
);
};
image
.
onerror
=
()
=>
{
reject
(
''
);
};
};
});
};
const
beforeUpload
=
async
(
file
:
any
)
=>
{
try
{
const
{
config
}
=
props
;
const
{
config
,
rules
}
=
props
;
const
config_len
=
Object
.
keys
(
config
).
length
;
if
(
!
config_len
)
{
show_message
(
'无法上传,请尝试刷新页面'
);
return
false
;
}
else
if
(
rules
&&
rules
.
length
)
{
// 判断是否存在 image_size 规则
const
rule_data
:
any
=
rules
.
find
(
(
item
:
any
)
=>
item
.
type
==
'image_size'
);
if
(
rule_data
&&
rule_data
!==
-
1
)
{
// 格式 1024,1024
const
image_size
=
rule_data
.
value
??
''
;
if
(
!
image_size
)
{
show_message
(
'缺少图片尺寸校验'
);
return
false
;
}
const
size
=
await
getFileSize
(
file
.
raw
);
if
(
size
!==
image_size
)
{
show_message
(
rule_data
.
message
);
return
false
;
}
}
}
return
true
;
}
catch
(
e
)
{
...
...
src/utils/api/Task.ts
View file @
0747fc0d
...
...
@@ -131,7 +131,6 @@ export const FormExample = [
],
},
{
// 继续聊天
type
:
'gpt_continues_chat'
,
name
:
'category_5'
,
label
:
'继续聊天'
,
...
...
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