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
700872b0
Commit
700872b0
authored
Jan 05, 2021
by
郝聪敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: 添加根据背景图调整尺寸功能;添加样式转rem功能;暴露delete方法
parent
e21bcd67
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
70 additions
and
18 deletions
+70
-18
index.vue
app/web/lib/DownloadGuide/index.vue
+5
-5
index.ts
app/web/page/activity/component/FreedomContainer/index.ts
+21
-3
index.ts
app/web/page/activity/view/activity/index.ts
+3
-2
index.vue
app/web/page/activity/view/activity/index.vue
+1
-1
index.ts
app/web/page/editor/component/DynamicForm/index.ts
+9
-3
index.vue
app/web/page/editor/component/DynamicForm/index.vue
+4
-1
index.ts
app/web/page/editor/component/FreedomContainer/index.ts
+5
-1
index.ts
app/web/page/store/modules/editor/index.ts
+6
-1
state.ts
app/web/page/store/modules/editor/state.ts
+1
-1
type.ts
app/web/page/store/modules/editor/type.ts
+1
-0
utils.service.ts
app/web/service/utils.service.ts
+14
-0
No files found.
app/web/lib/DownloadGuide/index.vue
View file @
700872b0
<
template
>
<div
class=
"top-bar"
v-if=
"isShowTopBar"
>
<div
class=
"top-bar"
>
<img
class=
"top-bar-left"
:src=
"leftImg"
/>
<div
class=
"top-bar-right"
>
<a
:href=
"href"
>
<button
class=
"top-bar-button"
>
打开APP
</button>
</a>
<img
@
click=
"isShowTopBar = false"
class=
"top-bar-
close"
src=
"./images/close@2x.png"
/>
<img
class=
"top-bar-close"
@
click=
"
close"
src=
"./images/close@2x.png"
/>
</div>
</div>
</
template
>
...
...
@@ -16,9 +16,9 @@
href
:
String
,
leftImg
:
String
},
data
()
{
return
{
isShowTopBar
:
true
,
methods
:
{
close
()
{
this
.
$emit
(
'
delete
'
);
}
}
}
...
...
app/web/page/activity/component/FreedomContainer/index.ts
View file @
700872b0
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
Component
,
Prop
,
Vue
}
from
'
vue-property-decorator
'
;
import
{
Action
,
Mutation
,
State
,
Getter
}
from
'
vuex-class
'
;
import
LoginForm
from
'
@/lib/Form/index.vue
'
;
import
{
ContextMenu
}
from
'
@editor/mixins/contextMenu.mixin
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
Action
,
Mutation
,
State
}
from
'
vuex-class
'
;
import
{
resizeDiv
}
from
'
@/service/utils.service
'
;
@
Component
({
components
:
{
LoginForm
},
name
:
'
FreedomContainer
'
})
export
default
class
FreedomContainer
extends
Vue
{
@
Getter
(
'
pageData
'
)
pageData
;
@
State
(
state
=>
state
.
editor
.
curChildIndex
)
curChildIndex
;
@
Mutation
(
'
UPDATE_PAGE_INFO
'
)
updatePageInfo
;
@
Prop
({
type
:
Object
,
default
:
()
=>
({
child
:
[]
})})
childItem
;
@
Prop
(
String
)
backgroundImage
;
...
...
@@ -14,11 +17,26 @@ export default class FreedomContainer extends Vue {
transformStyle
(
styleObj
)
{
const
style
=
{};
for
(
const
key
of
Object
.
keys
(
styleObj
))
{
style
[
key
]
=
typeof
styleObj
[
key
]
!==
'
string
'
?
`
${
styleObj
[
key
]}
px`
:
styleObj
[
key
];
if
(
typeof
styleObj
[
key
]
===
'
number
'
)
{
style
[
key
]
=
`
${(
styleObj
[
key
]
/
37.5
).
toFixed
(
2
)}
rem`
;
}
else
{
style
[
key
]
=
styleObj
[
key
].
includes
(
'
px
'
)
?
`
${(
+
(
styleObj
[
key
].
slice
(
0
,
-
2
))
/
37.5
).
toFixed
(
2
)}
rem`
:
styleObj
[
key
];
}
if
(
key
===
'
backgroundImage
'
)
{
style
.
backgroundImage
=
`url(
${
style
.
backgroundImage
}
)`
;
}
}
return
style
;
}
mounted
()
{
// 根据背景图设置元素高度
const
index
=
this
.
pageData
?.
elements
?.
findIndex
(
v
=>
v
.
point
?.
responsive
);
const
{
props
:
{
backgroundImage
},
point
}
=
this
.
pageData
?.
elements
[
index
]
||
{
props
:
{}};
if
(
backgroundImage
)
{
resizeDiv
(
backgroundImage
,
null
,
null
,
(
height
)
=>
{
this
.
updatePageInfo
({
containerIndex
:
index
,
data
:
{
...
this
.
pageData
?.
elements
[
index
],
point
:
{
...
point
,
h
:
height
??
point
.
h
}
}
});
});
}
}
}
\ No newline at end of file
app/web/page/activity/view/activity/index.ts
View file @
700872b0
...
...
@@ -6,13 +6,14 @@ import GridLayout from '../../component/VueGridLayout/GridLayout.vue';
import
GridItem
from
'
../../component/VueGridLayout/GridItem.vue
'
;
import
LoginForm
from
'
@/lib/Form/index.vue
'
;
import
DownloadGuide
from
'
@/lib/DownloadGuide/index.vue
'
;
import
{
Getter
,
State
}
from
'
vuex-class
'
;
import
{
Getter
,
State
,
Mutation
}
from
'
vuex-class
'
;
@
Component
({
components
:
{
FreedomContainer
,
GridLayout
,
GridItem
,
LoginForm
,
DownloadGuide
},
name
:
'
Activity
'
})
export
default
class
Activity
extends
Vue
{
@
Getter
(
'
pageData
'
)
pageData
;
@
State
(
state
=>
state
.
editor
.
pageInfo
.
pageName
)
pageName
;
@
State
(
state
=>
state
.
editor
.
gridLayout
.
rowHeight
)
rowHeight
;
@
Mutation
(
'
DEL_ELEMENTS
'
)
delPageInfo
;
isLayoutComReady
=
false
;
...
...
@@ -45,7 +46,7 @@ export default class Activity extends Vue {
createStyle
({
h
})
{
return
EASY_ENV_IS_NODE
?
{
height
:
`
${
h
*
50
+
Math
.
max
(
0
,
h
-
1
)
*
10
}
px`
,
height
:
`
${
h
*
this
.
rowHeight
}
px`
,
}
:
{};
}
}
\ No newline at end of file
app/web/page/activity/view/activity/index.vue
View file @
700872b0
...
...
@@ -20,7 +20,7 @@
:h=
"item.point.h"
:i=
"item.point.i"
:key=
"item.point.i"
>
<component
class=
"Dcmc-panel-com"
:data-index=
"index"
:containerIndex=
"index"
:childItem=
"item"
:is=
"item.name"
:key=
"index"
v-bind=
"item.props"
></component>
<component
class=
"Dcmc-panel-com"
:data-index=
"index"
:containerIndex=
"index"
:childItem=
"item"
:is=
"item.name"
:key=
"index"
@
delete=
"delPageInfo(index)"
v-bind=
"item.props"
></component>
</grid-item>
</grid-layout>
</div>
...
...
app/web/page/editor/component/DynamicForm/index.ts
View file @
700872b0
...
...
@@ -4,6 +4,7 @@ import { reduce, ceil, subtract, divide } from 'lodash';
import
{
ContextMenu
}
from
'
@editor/mixins/contextMenu.mixin
'
;
import
Upload
from
'
./component/Upload/index.vue
'
;
import
ColorSelector
from
'
./component/ColorSelector/index.vue
'
;
import
{
resizeDiv
}
from
'
@/service/utils.service
'
;
@
Component
({
components
:
{
Upload
,
ColorSelector
},
name
:
'
DynamicForm
'
})
export
default
class
DynamicForm
extends
Mixins
(
ContextMenu
)
{
...
...
@@ -17,7 +18,6 @@ export default class DynamicForm extends Mixins(ContextMenu) {
@
Watch
(
'
curElement
'
,
{
immediate
:
true
,
deep
:
true
})
onElementChange
(
newVal
)
{
console
.
log
(
'
newVal
'
,
newVal
);
newVal
?.
schame
?.
forEach
(
schame
=>
{
this
.
$set
(
this
.
form
,
schame
.
key
,
newVal
.
props
[
schame
.
key
]);
});
...
...
@@ -36,10 +36,16 @@ export default class DynamicForm extends Mixins(ContextMenu) {
return
result
;
}
resizedEvent
(
h
,
w
)
{
resizedEvent
(
h
,
w
,
responsive
)
{
const
elements
=
this
.
pageData
.
elements
[
this
.
curEleIndex
];
if
(
responsive
)
{
resizeDiv
(
this
.
form
.
backgroundImage
,
667
,
375
,
(
imgHeight
)
=>
{
this
.
updatePageInfo
({
containerIndex
:
this
.
curEleIndex
,
data
:
{
...
elements
,
point
:
{
...
elements
.
point
,
w
:
w
??
elements
.
point
.
w
,
h
:
imgHeight
??
elements
.
point
.
h
,
responsive
:
true
}
}
});
});
}
else
{
this
.
updatePageInfo
({
containerIndex
:
this
.
curEleIndex
,
data
:
{
...
elements
,
point
:
{
...
elements
.
point
,
w
:
w
??
elements
.
point
.
w
,
h
:
h
??
elements
.
point
.
h
}
}
});
}
}
getStyle
(
oElement
,
sName
)
{
const
result
=
oElement
.
currentStyle
?
oElement
.
currentStyle
[
sName
]
:
getComputedStyle
(
oElement
,
null
)[
sName
];
...
...
app/web/page/editor/component/DynamicForm/index.vue
View file @
700872b0
...
...
@@ -15,8 +15,11 @@
<Tooltip
placement=
"top"
content=
"全屏"
>
<Button
type=
"ghost"
icon=
"arrow-resize"
@
click=
"resizedEvent(667, 667)"
></Button>
</Tooltip>
<Tooltip
placement=
"top"
content=
"根据背景图片自动调整宽高"
>
<Button
type=
"ghost"
icon=
"image"
@
click=
"resizedEvent(667, 375, true)"
></Button>
</Tooltip>
<Tooltip
placement=
"top"
content=
"宽100%"
>
<Button
type=
"ghost"
icon=
"arrow-swap"
@
click=
"resizedEvent(null,
667
)"
></Button>
<Button
type=
"ghost"
icon=
"arrow-swap"
@
click=
"resizedEvent(null,
375
)"
></Button>
</Tooltip>
<Tooltip
placement=
"top"
content=
"高100%"
>
<Button
type=
"ghost"
icon=
"arrow-swap"
@
click=
"resizedEvent(667, null)"
></Button>
...
...
app/web/page/editor/component/FreedomContainer/index.ts
View file @
700872b0
...
...
@@ -41,7 +41,11 @@ export default class FreedomContainer extends Mixins(ContextMenu) {
transformStyle
(
styleObj
)
{
const
style
=
{};
for
(
const
key
of
Object
.
keys
(
styleObj
))
{
style
[
key
]
=
typeof
styleObj
[
key
]
!==
'
string
'
?
`
${
styleObj
[
key
]}
px`
:
styleObj
[
key
];
if
(
typeof
styleObj
[
key
]
===
'
number
'
)
{
style
[
key
]
=
`
${(
styleObj
[
key
]
/
37.5
).
toFixed
(
2
)}
rem`
;
}
else
{
style
[
key
]
=
styleObj
[
key
].
includes
(
'
px
'
)
?
`
${(
+
(
styleObj
[
key
].
slice
(
0
,
-
2
))
/
37.5
).
toFixed
(
2
)}
rem`
:
styleObj
[
key
];
}
if
(
key
===
'
backgroundImage
'
)
{
style
.
backgroundImage
=
`url(
${
style
.
backgroundImage
}
)`
;
}
...
...
app/web/page/store/modules/editor/index.ts
View file @
700872b0
...
...
@@ -6,7 +6,8 @@ import {
SET_DRAGABLE
,
COPY_OR_DELETE_PAGE_INFO
,
UPDATE_PAGE_INFO
,
ADD_ELEMENTS
,
ADD_ELEMENTS
,
DEL_ELEMENTS
,
SET_CUR_ELE_INDEX
,
SET_CUR_CHILD_INDEX
,
RESET_PAGE_DATA
,
...
...
@@ -126,6 +127,10 @@ export default class EditorModule implements Module<EditorState, RootState> {
page
.
push
(
data
);
}
},
[
DEL_ELEMENTS
](
state
,
{
containerIndex
})
{
const
page
=
(
state
.
pageInfo
.
page
as
Page
).
elements
;
page
.
splice
(
containerIndex
,
1
);
},
};
constructor
(
initState
:
EditorState
=
cloneDeep
(
defaultState
))
{
...
...
app/web/page/store/modules/editor/state.ts
View file @
700872b0
...
...
@@ -8,9 +8,9 @@ interface Point {
x
:
number
;
y
:
number
;
w
:
number
;
moved
:
boolean
;
h
:
number
;
i
:
number
|
string
;
responsive
:
boolean
;
// 自定义属性, 表示是否根据背景图片调整宽高
}
interface
CommonStyle
{
...
...
app/web/page/store/modules/editor/type.ts
View file @
700872b0
...
...
@@ -4,6 +4,7 @@ export const SET_DRAGABLE = 'SET_DRAGABLE';
export
const
COPY_OR_DELETE_PAGE_INFO
=
'
COPY_OR_DELETE_PAGE_INFO
'
;
export
const
UPDATE_PAGE_INFO
=
'
UPDATE_PAGE_INFO
'
;
export
const
ADD_ELEMENTS
=
'
ADD_ELEMENTS
'
;
export
const
DEL_ELEMENTS
=
'
DEL_ELEMENTS
'
;
export
const
SET_CUR_ELE_INDEX
=
'
SET_CUR_ELE_INDEX
'
;
export
const
SET_CUR_CHILD_INDEX
=
'
SET_CUR_CHILD_INDEX
'
;
export
const
RESET_PAGE_DATA
=
'
RESET_PAGE_DATA
'
;
...
...
app/web/service/utils.service.ts
View file @
700872b0
...
...
@@ -38,3 +38,17 @@ export function isPhone(str) {
}
return
false
;
}
export
function
resizeDiv
(
imgUrl
,
clientHeight
=
0
,
clientWidth
=
0
,
callback
)
{
const
img
=
new
Image
();
clientHeight
=
clientHeight
||
document
.
body
.
clientHeight
;
clientWidth
=
clientWidth
||
document
.
body
.
clientWidth
;
img
.
onload
=
function
()
{
const
imgRealHeight
=
clientWidth
*
img
.
height
/
img
.
width
;
console
.
log
(
img
.
width
,
img
.
height
,
imgRealHeight
,
clientHeight
);
if
(
imgRealHeight
>
clientWidth
)
{
callback
(
imgRealHeight
);
}
};
img
.
src
=
imgUrl
;
}
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