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
f05589e1
Commit
f05589e1
authored
Apr 16, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉压缩
parent
d53c7757
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
144 additions
and
62 deletions
+144
-62
common.js
src/api/common.js
+3
-6
project.js
src/api/project.js
+1
-1
config.js
src/config.js
+1
-1
router.js
src/router.js
+5
-0
project.js
src/store/modules/project.js
+59
-49
index.js
src/utils/index.js
+24
-0
preview-preprocess.js
src/views/Preview/preview-preprocess.js
+5
-5
ProjectDiff.vue
src/views/ProjectDiff.vue
+46
-0
No files found.
src/api/common.js
View file @
f05589e1
...
@@ -24,11 +24,8 @@ class ApiError extends Error {
...
@@ -24,11 +24,8 @@ class ApiError extends Error {
}
}
}
}
export
async
function
fetchApi
(
uri
,
{
params
,
method
=
'get'
,
auth
=
true
,
judgeSuccess
=
true
,
contentType
=
'json'
,
errMessage
}
=
{
export
async
function
fetchApi
(
uri
,
{
host
=
''
,
params
,
method
=
'get'
,
auth
=
true
,
judgeSuccess
=
true
,
contentType
=
'json'
,
dataField
=
'data'
,
errMessage
})
{
method
:
'get'
,
let
url
=
host
+
(
uri
.
startsWith
(
'http'
)
||
uri
.
startsWith
(
'//'
)
?
uri
:
API_HOST
+
uri
);
contentType
:
'json'
})
{
let
url
=
uri
.
startsWith
(
'http'
)
||
uri
.
startsWith
(
'//'
)
?
uri
:
API_HOST
+
uri
;
const
options
=
{
const
options
=
{
method
,
method
,
...
@@ -77,7 +74,7 @@ export async function fetchApi(uri, {params, method = 'get', auth = true, judgeS
...
@@ -77,7 +74,7 @@ export async function fetchApi(uri, {params, method = 'get', auth = true, judgeS
if
(
judgeSuccess
)
{
if
(
judgeSuccess
)
{
if
(
jsonObj
.
success
)
{
if
(
jsonObj
.
success
)
{
return
jsonObj
.
data
;
return
jsonObj
[
dataField
]
;
}
}
}
else
{
}
else
{
return
jsonObj
;
return
jsonObj
;
...
...
src/api/project.js
View file @
f05589e1
...
@@ -63,7 +63,7 @@ export async function fetchHistory(id, currentPage, pageSize) {
...
@@ -63,7 +63,7 @@ export async function fetchHistory(id, currentPage, pageSize) {
}
}
export
async
function
saveOne
(
project
,
remark
)
{
export
async
function
saveOne
(
project
,
remark
)
{
project
.
remark
=
remark
project
.
remark
=
remark
;
return
await
fetchApi
(
'/api/project/update'
,
{
return
await
fetchApi
(
'/api/project/update'
,
{
params
:
project
,
params
:
project
,
method
:
'post'
,
method
:
'post'
,
...
...
src/config.js
View file @
f05589e1
...
@@ -6,7 +6,7 @@ export let API_HOST;
...
@@ -6,7 +6,7 @@ export let API_HOST;
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
//API_HOST = '//10.10.95.74:7777';
//API_HOST = '//10.10.95.74:7777';
//API_HOST = '//192.168.1.16:7777';
//API_HOST = '//192.168.1.16:7777';
//API_HOST = '//10.10.9
3.88:7777
';
//API_HOST = '//10.10.9
4.107:3000
';
//API_HOST = '//192.168.0.105:7777';
//API_HOST = '//192.168.0.105:7777';
//API_HOST = '//localhost:3002';
//API_HOST = '//localhost:3002';
//API_HOST = window.__data.apiHost;
//API_HOST = window.__data.apiHost;
...
...
src/router.js
View file @
f05589e1
...
@@ -23,5 +23,10 @@ export default new Router({
...
@@ -23,5 +23,10 @@ export default new Router({
name
:
'preview'
,
name
:
'preview'
,
component
:
()
=>
import
(
'./views/Preview.vue'
)
component
:
()
=>
import
(
'./views/Preview.vue'
)
},
},
{
path
:
'/diff'
,
name
:
'diff'
,
component
:
()
=>
import
(
'./views/ProjectDiff.vue'
)
},
]
]
})
})
src/store/modules/project.js
View file @
f05589e1
...
@@ -7,7 +7,15 @@ import {editorApi, projectApi} from "../../api"
...
@@ -7,7 +7,15 @@ import {editorApi, projectApi} from "../../api"
import
path
from
"path"
import
path
from
"path"
import
generateUUID
from
"uuid/v4"
import
generateUUID
from
"uuid/v4"
import
{
flattenViews
,
getCmpByUUID
,
getCmpProps
}
from
'../../utils/common'
import
{
flattenViews
,
getCmpByUUID
,
getCmpProps
}
from
'../../utils/common'
import
{
assetScheme
,
clonePureObj
,
findProcess
,
getMockServeEnabled
,
saveAs
,
traverseViewNode
}
from
"../../utils"
import
{
assetScheme
,
clonePureObj
,
deleteAssetsDepConfig
,
deleteDesignConfig
,
findProcess
,
getMockServeEnabled
,
saveAs
,
traverseViewNode
}
from
"../../utils"
import
{
template
}
from
"../../template"
import
{
template
}
from
"../../template"
import
events
from
"@/global-events"
import
events
from
"@/global-events"
import
{
packImages
}
from
"../../utils/sheet-pack"
import
{
packImages
}
from
"../../utils/sheet-pack"
...
@@ -20,7 +28,6 @@ import {fetchApi} from "../../api/common"
...
@@ -20,7 +28,6 @@ import {fetchApi} from "../../api/common"
import
{
toZeroing
}
from
"psd-parse-web"
import
{
toZeroing
}
from
"psd-parse-web"
import
{
arrayFind
}
from
"element-ui/src/utils/util"
;
import
{
arrayFind
}
from
"element-ui/src/utils/util"
;
const
storeName
=
'project'
;
const
storeName
=
'project'
;
const
psStoreName
=
'pack-history'
;
const
psStoreName
=
'pack-history'
;
...
@@ -47,47 +54,6 @@ const defaultOptions = {
...
@@ -47,47 +54,6 @@ const defaultOptions = {
const
OPERATE_MAX_LENGTH
=
200
;
// 撤销重做栈最大值
const
OPERATE_MAX_LENGTH
=
200
;
// 撤销重做栈最大值
function
getDefaultOptions
()
{
return
clonePureObj
(
defaultOptions
)
}
function
setUUIDForAllChildren
(
node
)
{
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
node
.
children
.
length
;
i
++
)
{
node
.
children
[
i
]
=
copyBaseRoot
(
node
.
children
[
i
]);
setUUIDForAllChildren
(
node
.
children
[
i
])
}
}
}
let
copyNodeCatch
=
null
;
function
copyBaseRoot
(
node
)
{
let
_node
=
JSON
.
parse
(
JSON
.
stringify
(
node
));
let
data
;
if
(
_node
.
children
&&
_node
.
children
.
length
>
0
)
{
data
=
{
name
:
_node
.
name
,
type
:
_node
.
type
,
properties
:
_node
.
properties
,
events
:
_node
.
events
,
uuid
:
generateUUID
(),
children
:
_node
.
children
};
}
else
{
data
=
{
name
:
_node
.
name
,
type
:
_node
.
type
,
properties
:
_node
.
properties
,
events
:
_node
.
events
,
uuid
:
generateUUID
(),
};
}
return
data
}
export
const
projectStore
=
{
export
const
projectStore
=
{
modules
:
{
modules
:
{
package
:
packageStore
,
package
:
packageStore
,
...
@@ -378,8 +344,7 @@ export const projectStore = {
...
@@ -378,8 +344,7 @@ export const projectStore = {
parentChildren
.
splice
(
index
,
1
);
parentChildren
.
splice
(
index
,
1
);
},
},
copyNode
(
state
,
{
node
,
parentNode
,
copyState
})
{
copyNode
(
state
,
{
node
,
parentNode
,
copyState
})
{
let
_node1
=
node
;
let
_node1
=
node
;
console
.
log
(
_node1
)
console
.
log
(
_node1
)
copyNodeCatch
=
clonePureObj
(
_node1
)
copyNodeCatch
=
clonePureObj
(
_node1
)
...
@@ -501,9 +466,12 @@ export const projectStore = {
...
@@ -501,9 +466,12 @@ export const projectStore = {
getters
:
{
getters
:
{
project
(
state
)
{
project
(
state
)
{
const
{
id
,
name
,
creator
,
data
}
=
state
;
const
{
id
,
name
,
creator
,
data
}
=
state
;
let
newData
=
clonePureObj
(
data
);
deleteDesignConfig
(
newData
.
processes
);
deleteAssetsDepConfig
(
newData
);
return
{
return
{
id
,
name
,
creator
,
id
,
name
,
creator
,
data
:
JSON
.
stringify
(
d
ata
),
data
:
JSON
.
stringify
(
newD
ata
),
};
};
},
},
menuBadge
:
(
state
)
=>
(
key
)
=>
{
menuBadge
:
(
state
)
=>
(
key
)
=>
{
...
@@ -621,7 +589,7 @@ export const projectStore = {
...
@@ -621,7 +589,7 @@ export const projectStore = {
},
},
actions
:
{
actions
:
{
async
saveToLocal
({
getters
,
commit
})
{
async
saveToLocal
({
getters
,
commit
})
{
const
{
project
}
=
getters
;
const
project
=
getters
.
project
;
await
db
.
set
(
storeName
,
{
id
:
project
.
id
,
data
:
JSON
.
stringify
(
project
)});
await
db
.
set
(
storeName
,
{
id
:
project
.
id
,
data
:
JSON
.
stringify
(
project
)});
//localStorage.setItem('project-' + project.id, JSON.stringify(project));
//localStorage.setItem('project-' + project.id, JSON.stringify(project));
...
@@ -860,7 +828,7 @@ export const projectStore = {
...
@@ -860,7 +828,7 @@ export const projectStore = {
await
db
.
remove
(
psStoreName
,
id
);
await
db
.
remove
(
psStoreName
,
id
);
},
},
savePreview
({
state
,
rootState
,
getters
})
{
savePreview
({
state
,
rootState
,
getters
})
{
const
{
project
}
=
getters
;
const
project
=
getters
.
project
;
const
packages
=
state
.
package
.
packages
;
const
packages
=
state
.
package
.
packages
;
/*const data = {
/*const data = {
...
@@ -870,7 +838,7 @@ export const projectStore = {
...
@@ -870,7 +838,7 @@ export const projectStore = {
localStorage.setItem('preview-project-' + project.id, JSON.stringify(data));
localStorage.setItem('preview-project-' + project.id, JSON.stringify(data));
localStorage.setItem('preview-ts', Date.now().toString());*/
localStorage.setItem('preview-ts', Date.now().toString());*/
preprocess
(
project
,
state
.
data
,
clonePureObj
(
packages
));
preprocess
(
project
,
clonePureObj
(
packages
));
},
},
addBehaviorDirect
({
state
},
{
behaviors
,
alias
})
{
addBehaviorDirect
({
state
},
{
behaviors
,
alias
})
{
...
@@ -960,3 +928,45 @@ export async function updateMock(mocks) {
...
@@ -960,3 +928,45 @@ export async function updateMock(mocks) {
db
.
set
(
'mock'
,
mock
);
db
.
set
(
'mock'
,
mock
);
}
}
}
}
function
getDefaultOptions
()
{
return
clonePureObj
(
defaultOptions
)
}
function
setUUIDForAllChildren
(
node
)
{
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
node
.
children
.
length
;
i
++
)
{
node
.
children
[
i
]
=
copyBaseRoot
(
node
.
children
[
i
]);
setUUIDForAllChildren
(
node
.
children
[
i
])
}
}
}
let
copyNodeCatch
=
null
;
function
copyBaseRoot
(
node
)
{
let
_node
=
JSON
.
parse
(
JSON
.
stringify
(
node
));
let
data
;
if
(
_node
.
children
&&
_node
.
children
.
length
>
0
)
{
data
=
{
name
:
_node
.
name
,
type
:
_node
.
type
,
properties
:
_node
.
properties
,
events
:
_node
.
events
,
uuid
:
generateUUID
(),
children
:
_node
.
children
};
}
else
{
data
=
{
name
:
_node
.
name
,
type
:
_node
.
type
,
properties
:
_node
.
properties
,
events
:
_node
.
events
,
uuid
:
generateUUID
(),
};
}
return
data
}
src/utils/index.js
View file @
f05589e1
...
@@ -93,6 +93,9 @@ export function guid() {
...
@@ -93,6 +93,9 @@ export function guid() {
* @param parent
* @param parent
*/
*/
export
function
traverseViewNode
(
nodes
,
callback
,
parent
)
{
export
function
traverseViewNode
(
nodes
,
callback
,
parent
)
{
if
(
!
nodes
)
{
return
;
}
for
(
let
node
of
nodes
)
{
for
(
let
node
of
nodes
)
{
callback
(
node
,
parent
);
callback
(
node
,
parent
);
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
...
@@ -400,3 +403,24 @@ export function getViewNodePath(node, sep = '/') {
...
@@ -400,3 +403,24 @@ export function getViewNodePath(node, sep = '/') {
export
function
timeFormat
(
time
,
format
=
'YYYY-MM-DD HH:mm:ss'
)
{
export
function
timeFormat
(
time
,
format
=
'YYYY-MM-DD HH:mm:ss'
)
{
return
moment
(
time
).
format
(
format
)
return
moment
(
time
).
format
(
format
)
}
}
export
function
deleteDesignConfig
(
processes
)
{
for
(
let
process
of
processes
)
{
if
(
process
.
sub
)
{
for
(
let
key
in
process
.
sub
)
{
let
p
=
process
.
sub
[
key
];
delete
p
.
design
[
'input'
];
delete
p
.
design
[
'output'
];
}
}
if
(
process
.
metas
)
{
deleteDesignConfig
(
process
.
metas
);
}
}
}
export
function
deleteAssetsDepConfig
(
data
)
{
for
(
let
asset
of
data
.
assets
)
{
delete
asset
[
'dep'
];
}
}
src/views/Preview/preview-preprocess.js
View file @
f05589e1
...
@@ -24,9 +24,9 @@ function getPackages(packages) {
...
@@ -24,9 +24,9 @@ function getPackages(packages) {
}
}
}
}
export
async
function
preprocess
(
project
,
data
,
packages
)
{
export
async
function
preprocess
(
project
,
packages
)
{
let
newData
=
clonePureObj
(
data
);
let
data
=
JSON
.
parse
(
project
.
data
);
const
codes
=
await
divideCode
(
newD
ata
,
{
const
codes
=
await
divideCode
(
d
ata
,
{
debug
:
true
,
debug
:
true
,
getPackages
:
getPackages
(
packages
),
getPackages
:
getPackages
(
packages
),
dependencies
:
data
.
dependencies
,
dependencies
:
data
.
dependencies
,
...
@@ -50,7 +50,7 @@ export async function preprocess(project, data, packages) {
...
@@ -50,7 +50,7 @@ export async function preprocess(project, data, packages) {
scripts
.
push
(
newScriptContent
(
'var proxy_mode=true;'
));
scripts
.
push
(
newScriptContent
(
'var proxy_mode=true;'
));
codesCache
=
codes
;
codesCache
=
codes
;
const
dataUrl
=
URL
.
createObjectURL
(
new
Blob
([
JSON
.
stringify
(
newD
ata
)]));
const
dataUrl
=
URL
.
createObjectURL
(
new
Blob
([
JSON
.
stringify
(
d
ata
)]));
const
{
libraryScriptElMap
,
analyseResult
}
=
await
generateLibraryScriptEl
(
tpl
,
dependencies
,
getPackages
(
packages
),
'//yun.duiba.com.cn/editor/zeroing/libs/'
);
const
{
libraryScriptElMap
,
analyseResult
}
=
await
generateLibraryScriptEl
(
tpl
,
dependencies
,
getPackages
(
packages
),
'//yun.duiba.com.cn/editor/zeroing/libs/'
);
...
@@ -65,7 +65,7 @@ export async function preprocess(project, data, packages) {
...
@@ -65,7 +65,7 @@ export async function preprocess(project, data, packages) {
db
.
set
(
storeName
,
{
db
.
set
(
storeName
,
{
id
:
project
.
id
,
id
:
project
.
id
,
data
:
newData
,
data
,
tpl
,
tpl
,
});
});
localStorage
.
setItem
(
'preview-ts'
,
Date
.
now
().
toString
());
localStorage
.
setItem
(
'preview-ts'
,
Date
.
now
().
toString
());
...
...
src/views/ProjectDiff.vue
0 → 100644
View file @
f05589e1
<
template
>
<monaco-editor
class=
"script-editor"
ref=
"editor"
v-model=
"code"
language=
"json"
:options=
"monacoEditorOptions"
diff-editor
:original=
"originalCode"
/>
</
template
>
<
script
>
import
MonacoEditor
from
"vue-monaco"
;
import
{
monacoEditorOptions
}
from
"../utils"
;
//import old from './old.json'
//let originalCode = JSON.stringify(old, null, '\t');
let
originalCode
=
`hello`
;
console
.
log
(
originalCode
);
export
default
{
name
:
"ProjectDiff"
,
components
:
{
MonacoEditor
},
data
()
{
return
{
monacoEditorOptions
,
code
:
''
,
originalCode
,
}
},
mounted
()
{
let
editor
=
this
.
$refs
.
editor
.
getEditor
();
editor
.
onDidUpdateDiff
(()
=>
{
let
m
=
editor
.
getLineChanges
();
console
.
log
(
m
);
})
}
}
</
script
>
<
style
scoped
>
.script-editor
{
width
:
100%
;
}
</
style
>
\ No newline at end of file
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