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
5df2db02
Commit
5df2db02
authored
Apr 29, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存一波
parent
4a590bd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
58 deletions
+75
-58
project.js
src/store/modules/project.js
+10
-58
assets-pack.js
src/utils/assets-pack.js
+65
-0
No files found.
src/store/modules/project.js
View file @
5df2db02
...
...
@@ -19,6 +19,7 @@ import {
import
{
template
}
from
"../../template"
import
events
from
"@/global-events"
import
{
packImages
}
from
"../../utils/sheet-pack"
import
{
packAssetsGroups
}
from
"../../utils/assets-pack"
import
{
addBehavior
,
deleteProcessMeta
,}
from
"./behavior"
import
db
from
"../../utils/db-storage"
...
...
@@ -138,27 +139,18 @@ export const projectStore = {
updateMock
(
localData
.
mock
);
},
updateAssetDep
(
state
)
{
console
.
log
(
'updateAssetDep'
);
let
assets
=
state
.
data
.
assets
;
let
explicitDepAssets
;
/*for (let asset of assets) {
if (asset.dep) {
let keys = Object.keys(asset.dep);
for (let key of keys) {
Vue.delete(asset.dep, key);
}
} else {
Vue.set(asset, 'dep', {});
}
}*/
for
(
let
view
of
state
.
data
.
views
)
{
if
(
!
view
.
implicitDepAssets
)
{
if
(
view
.
implicitDepAssets
)
{
view
.
implicitDepAssets
.
splice
(
0
);
}
else
{
Vue
.
set
(
view
,
'implicitDepAssets'
,
[]);
}
if
(
!
view
.
explicitDepAssets
)
{
if
(
view
.
explicitDepAssets
)
{
view
.
explicitDepAssets
.
splice
(
0
);
}
else
{
Vue
.
set
(
view
,
'explicitDepAssets'
,
[]);
}
explicitDepAssets
=
view
.
explicitDepAssets
;
...
...
@@ -921,9 +913,9 @@ export const projectStore = {
let
debug
=
params
.
debug
;
let
packedAssets
;
//if (!debug) {
packedAssets
=
await
packAssets
(
state
.
data
.
assets
);
packedAssets
=
await
packAssets
Groups
(
state
.
data
.
views
,
state
.
data
.
assets
);
//}
const
packResult
=
await
projectApi
.
pack
(
state
.
id
,
debug
,
packedAssets
);
/*
const packResult = await projectApi.pack(state.id, debug, packedAssets);
console.log(packResult);
...
...
@@ -935,7 +927,7 @@ export const projectStore = {
packResult: {tpl, tplUrl},
remark: params.remark,
});
return
packResult
;
return packResult;
*/
},
async
getPackHistory
({
state
})
{
return
(
await
db
.
getAll
(
psStoreName
,
state
.
id
,
'pid'
)).
reverse
();
...
...
@@ -1006,46 +998,6 @@ async function getSheetUrlByUUID(uuid) {
return
response
.
url
}
async
function
packAssets
(
assets
)
{
let
failedList
=
[];
let
newAssets
=
assets
.
concat
();
await
packImages
(
newAssets
,
{
getSheetUrlByUUID
});
await
Promise
.
all
(
newAssets
.
map
(
asset
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
if
(
asset
.
file
)
{
const
{
url
}
=
await
editorApi
.
uploadFile
(
asset
.
file
,
true
).
catch
(
e
=>
{
failedList
.
push
(
asset
);
});
let
sheetConfig
=
{
file
:
url
,
type
:
'sheet'
,
frames
:
asset
.
frames
,
};
let
sheetConfigFile
=
new
File
([
JSON
.
stringify
(
sheetConfig
)],
'sheet.json'
,
{
type
:
'plain/text'
});
const
{
url
:
sheetConfigUrl
}
=
await
editorApi
.
uploadFile
(
sheetConfigFile
,
false
,
asset
.
sheetUUID
).
catch
(
e
=>
{
failedList
.
push
(
asset
)
});
asset
.
url
=
sheetConfigUrl
;
asset
.
uuid
=
generateUUID
();
delete
asset
.
file
;
delete
asset
.
frames
;
delete
asset
.
sheetUUID
;
}
resolve
();
}
catch
(
e
)
{
reject
(
e
);
}
})
}));
return
newAssets
;
}
export
async
function
updateMock
(
mocks
)
{
await
db
.
clear
(
'mock'
);
for
(
let
mock
of
mocks
)
{
...
...
src/utils/assets-pack.js
0 → 100644
View file @
5df2db02
/**
* Created by rockyl on 2020-04-29.
*/
import
{
packImages
}
from
"./sheet-pack"
;
import
{
editorApi
}
from
"../api"
;
import
generateUUID
from
"uuid/v4"
;
export
async
function
packAssetsGroups
(
views
,
assets
)
{
for
(
let
asset
of
assets
){
}
let
depCountingMap
=
{};
for
(
let
view
of
views
)
{
const
{
explicitDepAssets
,
implicitDepAssets
}
=
view
;
let
depAssets
=
[...
explicitDepAssets
,
...
implicitDepAssets
];
for
(
let
depAsset
of
depAssets
){
if
(
!
depCountingMap
.
hasOwnProperty
(
depAsset
)){
depCountingMap
[
depAsset
]
=
0
;
}
depCountingMap
[
depAsset
]
++
;
}
}
console
.
log
(
depCountingMap
);
}
async
function
packAssets
(
assets
)
{
let
failedList
=
[];
let
newAssets
=
assets
.
concat
();
await
packImages
(
newAssets
,
{
getSheetUrlByUUID
});
await
Promise
.
all
(
newAssets
.
map
(
asset
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
if
(
asset
.
file
)
{
const
{
url
}
=
await
editorApi
.
uploadFile
(
asset
.
file
,
true
).
catch
(
e
=>
{
failedList
.
push
(
asset
);
});
let
sheetConfig
=
{
file
:
url
,
type
:
'sheet'
,
frames
:
asset
.
frames
,
};
let
sheetConfigFile
=
new
File
([
JSON
.
stringify
(
sheetConfig
)],
'sheet.json'
,
{
type
:
'plain/text'
});
const
{
url
:
sheetConfigUrl
}
=
await
editorApi
.
uploadFile
(
sheetConfigFile
,
false
,
asset
.
sheetUUID
).
catch
(
e
=>
{
failedList
.
push
(
asset
)
});
asset
.
url
=
sheetConfigUrl
;
asset
.
uuid
=
generateUUID
();
delete
asset
.
file
;
delete
asset
.
frames
;
delete
asset
.
sheetUUID
;
}
resolve
();
}
catch
(
e
)
{
reject
(
e
);
}
})
}));
return
newAssets
;
}
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