Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quantum-blocks
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
quantum-blocks
Commits
949533b3
Commit
949533b3
authored
Apr 25, 2022
by
Xuguangxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 对图片上传及redis缓存做优化
parent
0a3a87d3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
14 deletions
+46
-14
editor.ts
app/controller/editor.ts
+4
-3
index.vue
...e/editor/component/DynamicForm/component/Upload/index.vue
+19
-0
addOrEditNavigator.vue
...e/editor/view/navigator/components/addOrEditNavigator.vue
+23
-11
No files found.
app/controller/editor.ts
View file @
949533b3
...
@@ -18,6 +18,7 @@ export default class EditorController extends Controller {
...
@@ -18,6 +18,7 @@ export default class EditorController extends Controller {
const
result
=
await
ctx
.
model
.
PageInfo
.
create
({
...
pageInfo
,
uuid
:
uuidv1
().
replace
(
/-/g
,
''
),
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
const
result
=
await
ctx
.
model
.
PageInfo
.
create
({
...
pageInfo
,
uuid
:
uuidv1
().
replace
(
/-/g
,
''
),
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
await
ctx
.
service
.
redis
.
set
(
`pageInfo:
${
result
.
dataValues
.
uuid
}
`
,
result
.
dataValues
);
await
ctx
.
service
.
redis
.
set
(
`pageInfo:
${
result
.
dataValues
.
uuid
}
`
,
result
.
dataValues
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
result
.
dataValues
.
uuid
}
`
);
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
error
.
message
.
indexOf
(
'
Data too long
'
)
>
-
1
&&
error
.
message
.
indexOf
(
'
page_data
'
)
>
-
1
)
{
if
(
error
.
message
.
indexOf
(
'
Data too long
'
)
>
-
1
&&
error
.
message
.
indexOf
(
'
page_data
'
)
>
-
1
)
{
error
.
message
=
'
配置组件过多,请对组件进行删减
'
;
error
.
message
=
'
配置组件过多,请对组件进行删减
'
;
...
@@ -36,7 +37,7 @@ export default class EditorController extends Controller {
...
@@ -36,7 +37,7 @@ export default class EditorController extends Controller {
}
}
try
{
try
{
const
result
=
await
ctx
.
model
.
PageInfo
.
update
(
pageInfo
,
{
where
:
{
uuid
:
pageInfo
.
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
const
result
=
await
ctx
.
model
.
PageInfo
.
update
(
pageInfo
,
{
where
:
{
uuid
:
pageInfo
.
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
await
ctx
.
service
.
redis
.
set
(
`pageInfo:
${
pageInfo
.
uuid
}
`
,
pageInfo
);
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
pageInfo
.
uuid
}
`
,
pageInfo
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
pageInfo
.
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
pageInfo
.
uuid
}
`
);
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
app/web/page/editor/component/DynamicForm/component/Upload/index.vue
View file @
949533b3
...
@@ -103,6 +103,25 @@
...
@@ -103,6 +103,25 @@
}
}
},
},
BeforeUpload
:
(
up
,
file
)
=>
{
BeforeUpload
:
(
up
,
file
)
=>
{
const
{
type
,
size
}
=
file
;
let
limit
=
0
;
// 来自量子积木v1.5需求中的优化点
if
(
type
===
'
image/gif
'
)
{
// gif限制5M
limit
=
5
*
1024
*
1024
;
if
(
size
>
limit
)
{
this
.
$toast
(
'
gif图大小不允许超过5Mb
'
);
return
false
;
}
}
else
{
// 其他格式限制800KB
limit
=
800
*
1024
;
if
(
size
>
limit
)
{
this
.
$toast
(
'
文件大小不允许超过800Kb
'
);
return
false
;
}
}
// if ()
// var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
// var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
this
.
percent
=
0
;
this
.
percent
=
0
;
},
},
...
...
app/web/page/editor/view/navigator/components/addOrEditNavigator.vue
View file @
949533b3
...
@@ -9,14 +9,14 @@
...
@@ -9,14 +9,14 @@
<div
class=
"navigator-info"
>
<div
class=
"navigator-info"
>
<div
class=
"navigator-info-name"
>
导航背景色
</div>
<div
class=
"navigator-info-name"
>
导航背景色
</div>
<div
class=
"navigator-info-input color"
>
<div
class=
"navigator-info-input color"
>
<Input
class=
"color-input"
v-model=
"bgColor"
/>
<Input
class=
"color-input"
v-model=
"bgColor"
/>
<ColorPicker
v-model=
"bgColor"
/>
<ColorPicker
v-model=
"bgColor"
/>
</div>
</div>
</div>
</div>
<div
class=
"navigator-info"
>
<div
class=
"navigator-info"
>
<div
class=
"navigator-info-name"
>
导航背景图
</div>
<div
class=
"navigator-info-name"
>
导航背景图
</div>
<div
class=
"navigator-info-input"
>
<div
class=
"navigator-info-input"
>
<uploader
v-model=
"bgImg"
class=
"uploader"
/>
<uploader
v-model=
"bgImg"
class=
"uploader"
:showInput=
"false"
/>
</div>
</div>
</div>
</div>
<div
class=
"navigator-list"
>
<div
class=
"navigator-list"
>
...
@@ -52,26 +52,26 @@
...
@@ -52,26 +52,26 @@
<div
class=
"item"
>
<div
class=
"item"
>
<div
class=
"label"
><i>
*
</i>
选中图标
</div>
<div
class=
"label"
><i>
*
</i>
选中图标
</div>
<div
class=
"setting"
>
<div
class=
"setting"
>
<uploader
v-model=
"item.selectIcon"
class=
"uploader"
/>
<uploader
v-model=
"item.selectIcon"
class=
"uploader"
:showInput=
"false"
/>
</div>
</div>
</div>
</div>
<div
class=
"item"
>
<div
class=
"item"
>
<div
class=
"label"
><i>
*
</i>
未选中图标
</div>
<div
class=
"label"
><i>
*
</i>
未选中图标
</div>
<div
class=
"setting"
>
<div
class=
"setting"
>
<uploader
v-model=
"item.icon"
class=
"uploader"
/>
<uploader
v-model=
"item.icon"
class=
"uploader"
:showInput=
"false"
/>
</div>
</div>
</div>
</div>
<div
class=
"item"
v-if=
"item.type == 1"
>
<div
class=
"item"
v-if=
"item.type == 1"
>
<div
class=
"label"
><i>
*
</i>
选中文案颜色
</div>
<div
class=
"label"
><i>
*
</i>
选中文案颜色
</div>
<div
class=
"setting"
>
<div
class=
"setting"
>
<Input
class=
"color-input"
v-model=
"item.selectColor"
/>
<Input
class=
"color-input"
v-model=
"item.selectColor"
@
on-blur=
"changeColor"
/>
<ColorPicker
v-model=
"item.selectColor"
/>
<ColorPicker
v-model=
"item.selectColor"
/>
</div>
</div>
</div>
</div>
<div
class=
"item"
v-if=
"item.type == 1"
>
<div
class=
"item"
v-if=
"item.type == 1"
>
<div
class=
"label"
><i>
*
</i>
未选中文案颜色
</div>
<div
class=
"label"
><i>
*
</i>
未选中文案颜色
</div>
<div
class=
"setting"
>
<div
class=
"setting"
>
<Input
class=
"color-input"
v-model=
"item.color"
/>
<Input
class=
"color-input"
v-model=
"item.color"
@
on-blur=
"changeColor"
/>
<ColorPicker
v-model=
"item.color"
/>
<ColorPicker
v-model=
"item.color"
/>
</div>
</div>
</div>
</div>
...
@@ -245,15 +245,20 @@ export default {
...
@@ -245,15 +245,20 @@ export default {
this
.
navigatorData
.
splice
(
index
,
1
);
this
.
navigatorData
.
splice
(
index
,
1
);
},
},
validate
()
{
validate
()
{
const
reg
=
/^
(?:
#
[
A-Fa-f0-9
]{3}
|#
[
A-Fa-f0-9
]{6})
$/
;
// 校验值
// 校验值
if
(
!
this
.
name
)
{
if
(
!
this
.
name
)
{
this
.
$toast
(
'
请填写名称
'
);
this
.
$toast
(
'
请填写名称
'
);
return
false
;
return
false
;
}
}
if
(
!
this
.
navigatorData
)
{
if
(
!
this
.
navigatorData
.
length
)
{
this
.
$toast
(
'
请配置导航
'
);
this
.
$toast
(
'
请配置导航
'
);
return
false
;
return
false
;
}
}
if
(
this
.
bgColor
&&
!
reg
.
test
(
this
.
bgColor
))
{
this
.
$toast
(
'
导航背景色格式错误,请重新填写
'
);
return
false
;
}
const
arr
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
navigatorData
));
const
arr
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
navigatorData
));
let
navigatorNameExist
=
true
;
// 导航名称是否创建
let
navigatorNameExist
=
true
;
// 导航名称是否创建
let
typeExist
=
true
;
// 导航类型是否选择(目前默认选择了图文形式)
let
typeExist
=
true
;
// 导航类型是否选择(目前默认选择了图文形式)
...
@@ -272,6 +277,10 @@ export default {
...
@@ -272,6 +277,10 @@ export default {
this
.
$toast
(
'
图文形式配置缺失,请填写后重试
'
);
this
.
$toast
(
'
图文形式配置缺失,请填写后重试
'
);
return
false
;
return
false
;
}
}
if
(
arr
[
i
].
type
==
1
&&
(
!
reg
.
test
(
arr
[
i
].
color
)
||
!
reg
.
test
(
arr
[
i
].
selectColor
)))
{
this
.
$toast
(
'
导航文字颜色格式错误,请重新填写
'
);
return
false
;
}
if
(
if
(
arr
[
i
].
type
==
2
arr
[
i
].
type
==
2
&&
&&
...
@@ -300,17 +309,20 @@ export default {
...
@@ -300,17 +309,20 @@ export default {
// 首先要进行校验
// 首先要进行校验
if
(
!
this
.
validate
())
return
;
if
(
!
this
.
validate
())
return
;
const
params
=
{
const
params
=
{
name
:
this
.
name
,
name
:
this
.
name
.
trim
()
,
navigatorData
:
this
.
navigatorData
,
navigatorData
:
this
.
navigatorData
,
author
:
this
.
author
,
author
:
this
.
author
.
trim
()
,
id
:
this
.
id
,
id
:
this
.
id
,
bgColor
:
this
.
bgColor
,
bgColor
:
this
.
bgColor
.
trim
()
,
bgImg
:
this
.
bgImg
bgImg
:
this
.
bgImg
.
trim
()
};
};
await
navigatorApi
.
saveNavigator
(
params
);
await
navigatorApi
.
saveNavigator
(
params
);
this
.
$toast
(
'
保存成功
'
);
this
.
$toast
(
'
保存成功
'
);
this
.
$emit
(
'
close
'
,
1
);
this
.
$emit
(
'
close
'
,
1
);
this
.
resetData
();
this
.
resetData
();
},
changeColor
(
evnet
,
data
)
{
data
=
/^
(?:
#
[
A-Fa-f0-9
]{3}
|#
[
A-Fa-f0-9
]{6})
$/
.
test
(
evnet
.
target
.
value
)
?
evnet
.
target
.
value
:
""
}
}
},
},
}
}
...
...
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