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
ef9e00da
Commit
ef9e00da
authored
Apr 30, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存一波
parent
5df2db02
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
45 deletions
+99
-45
zh-CN.json
src/locales/zh-CN.json
+1
-0
project.js
src/store/modules/project.js
+5
-17
assets-pack.js
src/utils/assets-pack.js
+80
-28
ProjectEditor.vue
src/views/Editor/dialogs/editors/ProjectEditor.vue
+13
-0
No files found.
src/locales/zh-CN.json
View file @
ef9e00da
...
...
@@ -101,6 +101,7 @@
"Create project"
:
"创建项目"
,
"Rename project"
:
"重命名项目"
,
"Entry scene view"
:
"入口场景视图"
,
"Loading view"
:
"加载视图"
,
"Page title"
:
"页面标题"
,
"Container ID"
:
"容器ID"
,
"Design width"
:
"设计宽度"
,
...
...
src/store/modules/project.js
View file @
ef9e00da
...
...
@@ -18,14 +18,12 @@ import {
}
from
"../../utils"
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"
import
{
preprocess
}
from
"../../views/Preview/preview-preprocess"
import
{
packageStore
}
from
"./package"
import
{
fetchApi
}
from
"../../api/common"
import
{
toZeroing
}
from
"psd-parse-web"
import
{
arrayFind
}
from
"element-ui/src/utils/util"
;
...
...
@@ -35,6 +33,7 @@ const psStoreName = 'pack-history';
const
defaultOptions
=
{
pageTitle
:
'no title'
,
entrySceneView
:
''
,
loadingView
:
''
,
containerId
:
'game-container'
,
designWidth
:
750
,
designHeight
:
1334
,
...
...
@@ -143,9 +142,7 @@ export const projectStore = {
let
explicitDepAssets
;
for
(
let
view
of
state
.
data
.
views
)
{
if
(
view
.
implicitDepAssets
)
{
view
.
implicitDepAssets
.
splice
(
0
);
}
else
{
if
(
!
view
.
implicitDepAssets
)
{
Vue
.
set
(
view
,
'implicitDepAssets'
,
[]);
}
if
(
view
.
explicitDepAssets
)
{
...
...
@@ -165,7 +162,6 @@ export const projectStore = {
let
uuid
=
prop
.
replace
(
assetScheme
,
''
);
let
asset
=
assets
.
find
(
asset
=>
asset
.
uuid
===
uuid
);
if
(
asset
)
{
//Vue.set(asset.dep, view.uuid, view.implicitAsset.includes(uuid) ? 2 : 1);
if
(
!
explicitDepAssets
.
includes
(
asset
.
uuid
)){
explicitDepAssets
.
push
(
asset
.
uuid
);
}
...
...
@@ -915,7 +911,8 @@ export const projectStore = {
//if (!debug) {
packedAssets
=
await
packAssetsGroups
(
state
.
data
.
views
,
state
.
data
.
assets
);
//}
/*const packResult = await projectApi.pack(state.id, debug, packedAssets);
console
.
log
(
packedAssets
);
const
packResult
=
await
projectApi
.
pack
(
state
.
id
,
debug
,
packedAssets
);
console
.
log
(
packResult
);
...
...
@@ -927,7 +924,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
();
...
...
@@ -989,15 +986,6 @@ async function uploadFiles(files) {
}
}
async
function
getSheetUrlByUUID
(
uuid
)
{
const
response
=
await
fetchApi
(
'/api/uuid2url'
,
{
params
:
{
uuid
},
errMessage
:
'Failed to get url'
,
});
return
response
.
url
}
export
async
function
updateMock
(
mocks
)
{
await
db
.
clear
(
'mock'
);
for
(
let
mock
of
mocks
)
{
...
...
src/utils/assets-pack.js
View file @
ef9e00da
...
...
@@ -5,37 +5,101 @@
import
{
packImages
}
from
"./sheet-pack"
;
import
{
editorApi
}
from
"../api"
;
import
generateUUID
from
"uuid/v4"
;
import
{
fetchApi
}
from
"../api/common"
;
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
;
for
(
let
depAsset
of
depAssets
)
{
if
(
!
depCountingMap
.
hasOwnProperty
(
depAsset
))
{
depCountingMap
[
depAsset
]
=
[];
}
depCountingMap
[
depAsset
].
push
(
view
.
uuid
);
}
}
let
assetsGroups
=
{
common
:
[],
};
for
(
let
asset
of
assets
)
{
let
depCountingViews
=
depCountingMap
[
asset
.
uuid
];
if
(
!
depCountingViews
)
{
continue
;
}
let
depCounting
=
depCountingViews
.
length
;
if
(
depCounting
>
0
)
{
if
(
depCounting
>
1
)
{
//依赖引用数大于1则放入通用分组
assetsGroups
.
common
.
push
(
asset
);
}
else
{
let
depView
=
depCountingViews
[
0
];
if
(
!
assetsGroups
.
hasOwnProperty
(
depView
))
{
assetsGroups
[
depView
]
=
[];
}
assetsGroups
[
depView
].
push
(
asset
);
}
}
}
depCountingMap
[
depAsset
]
++
;
let
ps
=
[];
for
(
let
key
in
assetsGroups
)
{
let
group
=
assetsGroups
[
key
];
ps
.
push
(
packAssets
(
key
,
group
));
}
const
groups
=
await
Promise
.
all
(
ps
);
for
(
let
group
of
groups
)
{
assetsGroups
[
group
.
key
]
=
group
.
assets
;
}
console
.
log
(
depCountingMap
);
return
assetsGroups
;
}
async
function
packAssets
(
assets
)
{
let
failedList
=
[];
async
function
getSheetUrlByUUID
(
uuid
)
{
const
response
=
await
fetchApi
(
'/api/uuid2url'
,
{
params
:
{
uuid
},
errMessage
:
'Failed to get url'
,
});
return
response
.
url
}
async
function
packAssets
(
key
,
assets
)
{
let
newAssets
=
assets
.
concat
();
if
(
assets
.
length
===
0
)
{
return
{
key
,
assets
,
};
}
let
failedList
=
[];
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
=>
{
uploadSheet
(
asset
).
catch
(
e
=>
{
failedList
.
push
(
asset
);
});
}
resolve
();
}
catch
(
e
)
{
reject
(
e
);
}
})
}));
return
{
key
,
assets
:
newAssets
,
};
}
async
function
uploadSheet
(
asset
)
{
const
{
url
}
=
await
editorApi
.
uploadFile
(
asset
.
file
,
true
);
let
sheetConfig
=
{
file
:
url
,
type
:
'sheet'
,
...
...
@@ -43,23 +107,11 @@ async function packAssets(assets) {
};
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
)
});
const
{
url
:
sheetConfigUrl
}
=
await
editorApi
.
uploadFile
(
sheetConfigFile
,
false
,
asset
.
sheetUUID
);
asset
.
url
=
sheetConfigUrl
;
asset
.
uuid
=
generateUUID
();
delete
asset
.
file
;
delete
asset
.
frames
;
delete
asset
.
sheetUUID
;
}
resolve
();
}
catch
(
e
)
{
reject
(
e
);
}
})
}));
return
newAssets
;
}
src/views/Editor/dialogs/editors/ProjectEditor.vue
View file @
ef9e00da
...
...
@@ -14,6 +14,19 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item
prop=
"loadingView"
:label=
"$t('Loading view')"
>
<el-select
v-model=
"editData.loadingView"
>
<el-option
:value=
"''"
:label=
"'空'"
></el-option>
<el-option
v-for=
"(view, index) in project.data.views"
:key=
"index"
:value=
"view.name"
:label=
"view.name"
></el-option>
</el-select>
</el-form-item>
<el-form-item
prop=
"containerId"
:label=
"$t('Container ID')"
>
<el-input
v-model=
"editData.containerId"
/>
</el-form-item>
...
...
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