Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-editor
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-editor
Commits
d64a4c0f
Commit
d64a4c0f
authored
Sep 23, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
无效路由处理
parent
46b9ebf1
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
189 additions
and
36 deletions
+189
-36
拆分.png
docs/拆分.png
+0
-0
项目拆分.xmind
docs/项目拆分.xmind
+0
-0
info.json
mock/api/editor/info.json
+0
-0
index.js
mock/api/project/query/data/index.js
+86
-0
data1.json
mock/api/project/query/data1.json
+0
-0
App.vue
src/App.vue
+45
-4
common.js
src/api/common.js
+4
-1
env.js
src/api/env.js
+1
-1
project.js
src/api/project.js
+2
-5
config.js
src/config.js
+2
-2
en.json
src/locales/en.json
+1
-0
project.js
src/store/modules/project.js
+13
-10
projects.js
src/store/modules/projects.js
+17
-2
Editor.vue
src/views/Editor.vue
+5
-1
Home.vue
src/views/Home.vue
+13
-10
No files found.
docs/拆分.png
0 → 100644
View file @
d64a4c0f
935 KB
docs/项目拆分.xmind
View file @
d64a4c0f
No preview for this file type
mock/api/
project/env
.json
→
mock/api/
editor/info
.json
View file @
d64a4c0f
File moved
mock/api/project/data/index.js
→
mock/api/project/
query/
data/index.js
View file @
d64a4c0f
...
@@ -8,11 +8,46 @@ const data = {
...
@@ -8,11 +8,46 @@ const data = {
"name"
:
"view1"
,
"name"
:
"view1"
,
"children"
:
[
"children"
:
[
{
{
"name"
:
"label"
name
:
'node1'
,
type
:
'node'
,
properties
:
{
x
:
0
,
y
:
0
,
width
:
0
,
height
:
0
,
rotation
:
0
,
scaleX
:
1
,
scaleY
:
1
,
alpha
:
1
,
visible
:
true
,
}
},
},
{
{
"name"
:
"image"
name
:
'node2'
,
}
type
:
'label'
,
properties
:
{
text
:
''
,
color
:
'black'
,
size
:
12
,
align
:
'left'
,
}
},
{
"name"
:
"node3"
,
type
:
'image'
,
properties
:
{
source
:
''
,
}
},
{
"name"
:
"node4"
,
type
:
'rect'
,
properties
:
{
fillColor
:
'white'
,
strokeColor
:
'black'
,
strokeWidth
:
1
,
}
},
]
]
},
},
{
{
...
@@ -22,10 +57,12 @@ const data = {
...
@@ -22,10 +57,12 @@ const data = {
"assets"
:
[
"assets"
:
[
{
{
"name"
:
"bg.jpg"
,
"name"
:
"bg.jpg"
,
uuid
:
"a1"
,
"url"
:
"/bg.jpg"
"url"
:
"/bg.jpg"
},
},
{
{
"name"
:
"btn-join.png"
,
"name"
:
"btn-join.png"
,
uuid
:
"a2"
,
"url"
:
"/btn-join.png"
"url"
:
"/btn-join.png"
}
}
]
]
...
@@ -46,4 +83,4 @@ const resp = {
...
@@ -46,4 +83,4 @@ const resp = {
module
.
exports
=
function
(){
module
.
exports
=
function
(){
return
resp
;
return
resp
;
}
}
;
mock/api/project/
data
.json
→
mock/api/project/
query/data1
.json
View file @
d64a4c0f
File moved
src/App.vue
View file @
d64a4c0f
<
template
>
<
template
>
<div
id=
"app"
class=
"theme-light"
>
<div
id=
"app"
class=
"theme-light"
>
<router-view/>
<router-view/>
<div
class=
"invalid-route"
v-if=
"invalidRoute"
>
<p>
无效的页面
{{
cd
}}
秒后跳转
</p>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
events
from
'./global-events'
export
default
{
export
default
{
name
:
"App"
,
name
:
"App"
,
data
()
{
return
{
cd
:
5
,
}
},
computed
:
{
invalidRoute
()
{
return
!
this
.
$route
.
matched
||
this
.
$route
.
matched
.
length
===
0
;
}
},
watch
:
{
$route
:
{
handler
:
function
(
val
,
oldVal
){
this
.
dealInvalidRoute
();
},
deep
:
true
}
},
mounted
()
{
mounted
()
{
this
.
dealInvalidRoute
();
},
},
methods
:
{
methods
:
{
dealInvalidRoute
(){
if
(
this
.
invalidRoute
)
{
this
.
cd
=
5
;
this
.
startCD
();
}
},
startCD
()
{
this
.
timer
=
setInterval
(()
=>
{
if
(
this
.
cd
<=
0
)
{
clearInterval
(
this
.
timer
);
this
.
$router
.
push
({
name
:
'home'
});
return
;
}
this
.
cd
--
;
},
1000
)
}
},
},
}
}
</
script
>
</
script
>
<
style
>
<
style
>
.invalid-route
{
width
:
100%
;
height
:
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
</
style
>
</
style
>
src/api/common.js
View file @
d64a4c0f
...
@@ -24,7 +24,10 @@ class ApiError extends Error {
...
@@ -24,7 +24,10 @@ class ApiError extends Error {
}
}
}
}
export
async
function
fetchApi
(
uri
,
{
params
,
method
,
contentType
,
errMessage
}
=
{
method
:
'get'
,
contentType
:
'form'
})
{
export
async
function
fetchApi
(
uri
,
{
params
,
method
=
'get'
,
contentType
=
'json'
,
errMessage
}
=
{
method
:
'get'
,
contentType
:
'json'
})
{
let
url
=
API_HOST
+
uri
;
let
url
=
API_HOST
+
uri
;
const
options
=
{
const
options
=
{
...
...
src/api/env.js
View file @
d64a4c0f
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
import
{
fetchApi
}
from
"./common"
;
import
{
fetchApi
}
from
"./common"
;
export
async
function
fetchEnv
()
{
export
async
function
fetchEnv
()
{
return
await
fetchApi
(
'/api/
project/env
'
,
{
return
await
fetchApi
(
'/api/
editor/info
'
,
{
errMessage
:
'Failed to fetch env'
,
errMessage
:
'Failed to fetch env'
,
})
})
}
}
src/api/project.js
View file @
d64a4c0f
...
@@ -16,7 +16,6 @@ export async function createOne(project) {
...
@@ -16,7 +16,6 @@ export async function createOne(project) {
return
await
fetchApi
(
'/api/project/create'
,
{
return
await
fetchApi
(
'/api/project/create'
,
{
params
:
project
,
params
:
project
,
method
:
'post'
,
method
:
'post'
,
contentType
:
'json'
,
errMessage
:
'Failed to create project'
,
errMessage
:
'Failed to create project'
,
})
})
}
}
...
@@ -25,7 +24,6 @@ export async function duplicateOne(project) {
...
@@ -25,7 +24,6 @@ export async function duplicateOne(project) {
return
await
fetchApi
(
'/api/project/duplicate'
,
{
return
await
fetchApi
(
'/api/project/duplicate'
,
{
params
:
project
,
params
:
project
,
method
:
'post'
,
method
:
'post'
,
contentType
:
'json'
,
errMessage
:
'Failed to duplicate project'
,
errMessage
:
'Failed to duplicate project'
,
})
})
}
}
...
@@ -33,13 +31,13 @@ export async function duplicateOne(project) {
...
@@ -33,13 +31,13 @@ export async function duplicateOne(project) {
export
async
function
deleteOne
(
id
)
{
export
async
function
deleteOne
(
id
)
{
return
await
fetchApi
(
'/api/project/delete'
,
{
return
await
fetchApi
(
'/api/project/delete'
,
{
params
:
{
id
},
params
:
{
id
},
method
:
'
delete
'
,
method
:
'
post
'
,
errMessage
:
'Failed to delete project'
,
errMessage
:
'Failed to delete project'
,
})
})
}
}
export
async
function
getData
(
id
)
{
export
async
function
getData
(
id
)
{
return
await
fetchApi
(
'/api/project/data'
,
{
return
await
fetchApi
(
'/api/project/
query/
data'
,
{
params
:
{
id
},
params
:
{
id
},
method
:
'get'
,
method
:
'get'
,
errMessage
:
'Failed to get project'
,
errMessage
:
'Failed to get project'
,
...
@@ -50,7 +48,6 @@ export async function updateOne(project) {
...
@@ -50,7 +48,6 @@ export async function updateOne(project) {
return
await
fetchApi
(
'/api/project/update'
,
{
return
await
fetchApi
(
'/api/project/update'
,
{
params
:
project
,
params
:
project
,
method
:
'post'
,
method
:
'post'
,
contentType
:
'json'
,
errMessage
:
'Failed to save project'
,
errMessage
:
'Failed to save project'
,
})
})
}
}
src/config.js
View file @
d64a4c0f
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
* Created by rockyl on 2019-09-19.
* Created by rockyl on 2019-09-19.
*/
*/
//
export const API_HOST = 'http://10.10.94.31:7777';
export
const
API_HOST
=
'http://10.10.94.31:7777'
;
export
const
API_HOST
=
'http://localhost:3002'
;
//
export const API_HOST = 'http://localhost:3002';
export
const
ASSETS_BASE
=
'http://0.0.0.0:4002/assets'
;
export
const
ASSETS_BASE
=
'http://0.0.0.0:4002/assets'
;
//文件类型图标 t表示展示缩略图
//文件类型图标 t表示展示缩略图
...
...
src/locales/en.json
View file @
d64a4c0f
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
"Data mapping"
:
"Data mapping"
,
"Data mapping"
:
"Data mapping"
,
"Template"
:
"Template"
,
"Template"
:
"Template"
,
"Preparing"
:
"Preparing…"
,
"Preparing"
:
"Preparing…"
,
"Deleting"
:
"Deleting…"
,
"Create project"
:
"Create project"
,
"Create project"
:
"Create project"
,
"Creating project"
:
"Creating project…"
,
"Creating project"
:
"Creating project…"
,
"Create project success"
:
"Create project success"
,
"Create project success"
:
"Create project success"
,
...
...
src/store/modules/project.js
View file @
d64a4c0f
...
@@ -22,16 +22,19 @@ export const projectStore = {
...
@@ -22,16 +22,19 @@ export const projectStore = {
state
.
name
=
name
;
state
.
name
=
name
;
state
.
creator
=
creator
;
state
.
creator
=
creator
;
const
localData
=
state
.
data
;
if
(
data
){
const
{
views
,
assets
,
dataMapping
}
=
JSON
.
parse
(
data
);
const
localData
=
state
.
data
;
if
(
!
localData
.
views
||
localData
.
views
.
length
===
0
){
const
{
views
,
assets
,
dataMapping
}
=
JSON
.
parse
(
data
);
localData
.
views
=
views
||
[];
if
(
!
localData
.
views
||
localData
.
views
.
length
===
0
){
}
localData
.
views
=
views
||
[];
if
(
!
localData
.
assets
||
localData
.
assets
.
length
===
0
){
}
localData
.
assets
=
assets
||
[];
if
(
!
localData
.
assets
||
localData
.
assets
.
length
===
0
){
}
localData
.
assets
=
assets
||
[];
if
(
!
localData
.
dataMapping
||
localData
.
dataMapping
.
length
===
0
){
}
localData
.
dataMapping
=
dataMapping
||
[];
if
(
!
localData
.
dataMapping
||
localData
.
dataMapping
.
length
===
0
){
localData
.
dataMapping
=
dataMapping
||
[];
};
}
}
},
},
},
},
...
...
src/store/modules/projects.js
View file @
d64a4c0f
...
@@ -10,8 +10,18 @@ export const projectsStore = {
...
@@ -10,8 +10,18 @@ export const projectsStore = {
state
.
splice
(
0
);
state
.
splice
(
0
);
state
.
push
(...
projects
);
state
.
push
(...
projects
);
},
},
addProject
(
state
,
project
){
addProject
(
state
,
project
)
{
state
.
push
(
project
);
state
.
unshift
(
project
);
},
deleteProject
(
state
,
projectID
)
{
for
(
let
i
=
0
,
li
=
state
.
length
;
i
<
li
;
i
++
)
{
const
item
=
state
[
i
];
if
(
item
.
id
===
projectID
)
{
state
.
splice
(
i
,
1
);
break
;
}
}
},
},
},
},
actions
:
{
actions
:
{
...
@@ -29,5 +39,10 @@ export const projectsStore = {
...
@@ -29,5 +39,10 @@ export const projectsStore = {
commit
(
'addProject'
,
project
);
commit
(
'addProject'
,
project
);
return
project
;
return
project
;
},
},
async
deleteProject
({
commit
},
projectID
)
{
await
projectApi
.
deleteOne
(
projectID
);
commit
(
'deleteProject'
,
projectID
);
return
projectID
;
},
},
},
};
};
\ No newline at end of file
src/views/Editor.vue
View file @
d64a4c0f
...
@@ -48,7 +48,11 @@
...
@@ -48,7 +48,11 @@
},
},
mounted
()
{
mounted
()
{
const
{
projectID
}
=
this
.
$route
.
params
;
const
{
projectID
}
=
this
.
$route
.
params
;
playWaiting
(
this
.
updateProject
(
projectID
),
this
.
$t
(
'Preparing'
)).
catch
(
e
=>
{});
if
(
projectID
){
playWaiting
(
this
.
updateProject
(
projectID
),
this
.
$t
(
'Preparing'
)).
catch
(
e
=>
{});
}
else
{
this
.
$router
.
push
({
name
:
'home'
})
}
},
},
methods
:
{
methods
:
{
getSize
(
id
,
side
)
{
getSize
(
id
,
side
)
{
...
...
src/views/Home.vue
View file @
d64a4c0f
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
size=
"small"
circle
plain
>
size=
"small"
circle
plain
>
</el-button>
</el-button>
<el-button
<el-button
@
click
.
native
.
prevent=
"
d
eleteProject(scope.row)"
@
click
.
native
.
prevent=
"
onD
eleteProject(scope.row)"
type=
"danger"
icon=
"el-icon-delete"
type=
"danger"
icon=
"el-icon-delete"
size=
"small"
circle
plain
>
size=
"small"
circle
plain
>
</el-button>
</el-button>
...
@@ -94,8 +94,17 @@
...
@@ -94,8 +94,17 @@
selectProject
(
row
,
event
)
{
selectProject
(
row
,
event
)
{
this
.
editProject
(
row
.
id
);
this
.
editProject
(
row
.
id
);
},
},
async
deleteProject
(
row
,
event
)
{
async
onDeleteProject
(
project
,
event
)
{
this
.
deleteAlert
(
row
);
this
.
$confirm
(
this
.
$t
(
'This action will permanently delete project'
,
{
projectName
:
project
.
name
}),
this
.
$t
(
'Alert'
),
{
confirmButtonText
:
this
.
$t
(
'Confirm'
),
cancelButtonText
:
this
.
$t
(
'Cancel'
),
type
:
'warning'
}).
then
(
()
=>
{
playWaiting
(
this
.
deleteProject
(
project
.
id
),
this
.
$t
(
'Deleting'
)).
catch
(
e
=>
{});
},
()
=>
{}
)
},
},
onCreateProject
(
projectID
)
{
onCreateProject
(
projectID
)
{
this
.
editProject
(
projectID
);
this
.
editProject
(
projectID
);
...
@@ -106,16 +115,10 @@
...
@@ -106,16 +115,10 @@
editProject
(
projectID
)
{
editProject
(
projectID
)
{
this
.
$router
.
push
({
name
:
'editor'
,
params
:
{
projectID
}});
this
.
$router
.
push
({
name
:
'editor'
,
params
:
{
projectID
}});
},
},
deleteAlert
(
project
)
{
return
this
.
$confirm
(
this
.
$t
(
'This action will permanently delete project'
,
{
projectName
:
project
.
name
}),
this
.
$t
(
'Alert'
),
{
confirmButtonText
:
this
.
$t
(
'Confirm'
),
cancelButtonText
:
this
.
$t
(
'Cancel'
),
type
:
'warning'
})
},
...
mapActions
([
...
mapActions
([
'updateProjects'
,
'updateProjects'
,
'updateEnv'
,
'updateEnv'
,
'deleteProject'
]),
]),
},
},
}
}
...
...
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