Commit c2dd872a authored by bianlongting's avatar bianlongting 💬

merge lqf

parents 10173245 1e272d27
...@@ -91,11 +91,14 @@ export async function importView(file) { ...@@ -91,11 +91,14 @@ export async function importView(file) {
return response; return response;
} }
export async function uploadFile(file, compress = false) { export async function uploadFile(file, compress = false, uuid) {
let params = {file}; let params = {file};
if (compress) { if (compress) {
params.compress = true; params.compress = true;
} }
if (uuid) {
params.uuid = uuid;
}
const response = await fetchApi('/api/uploadFile', { const response = await fetchApi('/api/uploadFile', {
params, params,
method: 'post', method: 'post',
......
<template>
<el-form class="props-editor" v-if="data&&meta" v-model="data.props" size="mini" label-width="100px" label-position="left" @submit.native.prevent>
<component v-for="(property, key) in meta.props"
:is="getInput(property)"
:container="data.props"
:value="data.props[key]"
:propertyName="key"
:property="property"
:key="key"
:editable="editable"
:linkable="linkable"
@input="onInput"
/>
</el-form>
</template>
<script>
import {
NumberInput,
StringInput,
EnumInput,
BooleanInput,
ColorInput,
AssetInput,
NodeSelectInput,
MapInput,
DynamicInput,
} from "./inputs";
const inputMapping = {
number: 'NumberInput',
string: 'StringInput',
enum: 'EnumInput',
boolean: 'BooleanInput',
color: 'ColorInput',
asset: 'AssetInput',
node: 'NodeSelectInput',
dynamic: 'DynamicInput',
map: 'MapInput',
};
export default {
name: "PropsEditor",
components: {
DynamicInput, MapInput, NodeSelectInput, AssetInput, ColorInput, BooleanInput, EnumInput, NumberInput, StringInput},
data() {
return {
}
},
props: {
editable: {
type: Boolean,
default: true
},
linkable: {
type: Boolean,
default: false
},
data: {
type: Object,
},
meta: {
type: Object,
},
},
methods: {
getInput(property) {
return inputMapping[property.type];
},
onInput(value, container, propName, oldValue){
if(value === undefined){
this.$delete(container ,propName);
}else{
this.$set(container, propName, value);
}
},
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName"> <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property" :propertyName="propertyName">
<el-select :disabled="!editable" :value="editValue" filterable @input="onInput" :placeholder="property.default" class="el-select"> <el-select :disabled="!editable" :value="editValue" filterable @input="onInput" :placeholder="property.default" class="el-select">
<el-option <el-option
v-for="(item, key) in assets" v-for="(item, key) in assets"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
export default { export default {
name: "AssetInput", name: "AssetInput",
components: {InputWrapper,}, components: {InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
computed: { computed: {
editValue() { editValue() {
return this.value === undefined ? this.property.default : this.value; return this.value === undefined ? this.property.default : this.value;
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName"> <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property" :propertyName="propertyName">
<el-switch :disabled="!editable" :value="editValue" @input="onInput" <el-switch :disabled="!editable" :value="editValue" @input="onInput"
class="picker"></el-switch> class="picker"></el-switch>
</input-wrapper> </input-wrapper>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
export default { export default {
name: "BooleanInput", name: "BooleanInput",
components: {InputWrapper}, components: {InputWrapper},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
data() { data() {
return {} return {}
}, },
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName" class="color-input-container"> <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property" :propertyName="propertyName" class="color-input-container">
<el-color-picker <el-color-picker
:disabled="!editable" :disabled="!editable"
class="picker" class="picker"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
export default { export default {
name: "ColorInput", name: "ColorInput",
components: {InputWrapper,}, components: {InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
data() { data() {
return { return {
predefineColors: [ predefineColors: [
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property"
:propertyName="propertyName"> :propertyName="propertyName">
<dynamic-selector style="flex: 1;" :value="value" @input="onChange" <dynamic-selector style="flex: 1;" :value="value" @input="onChange"
:editable="editable" :editable="editable"
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
export default { export default {
name: "DynamicInput", name: "DynamicInput",
components: {DynamicSelector, InputWrapper,}, components: {DynamicSelector, InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
methods: { methods: {
onChange(v){ onChange(v){
this.$emit('input', v, this.container, this.propertyName, this.value); this.$emit('input', v, this.container, this.propertyName, this.value);
......
...@@ -16,19 +16,19 @@ ...@@ -16,19 +16,19 @@
:placeholder="defaultValue"/> :placeholder="defaultValue"/>
</el-popover> </el-popover>
<el-button-group> <el-button-group>
<el-button @click="onClickEdit" :disabled="!editable">{{editValue.type[0].toUpperCase()}}</el-button> <el-button @click="onClickEdit" :disabled="!editable">{{dynamicIconMapping[editValue.type]}}</el-button>
<el-button icon="el-icon-delete" @click="onClickClean" :disabled="!editable"></el-button> <el-button icon="el-icon-delete" @click="onClickClean" :disabled="!editable"></el-button>
</el-button-group> </el-button-group>
</div> </div>
</template> </template>
<script> <script>
import {clonePureObj, getInputDefaultValue} from "../../../../utils"; import {clonePureObj, dynamicIconMapping, getInputDefaultValue} from "../../utils";
export default { export default {
name: "DynamicSelector", name: "DynamicSelector",
components: {}, components: {},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
data() { data() {
let dataTypes = this.$t('dataTypes'); let dataTypes = this.$t('dataTypes');
return { return {
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
popoverEditValue: this.value, popoverEditValue: this.value,
popoverVisible: false, popoverVisible: false,
dataTypes, dataTypes,
dynamicIconMapping,
} }
}, },
computed: { computed: {
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName"> <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property" :propertyName="propertyName">
<el-select :disabled="!editable" :value="editValue" @input="onInput" :placeholder="property.default" class="el-select"> <el-select :disabled="!editable" :value="editValue" @input="onInput" :placeholder="property.default" class="el-select">
<el-option <el-option
v-for="(item, key) in property.enum" v-for="(item, key) in property.enum"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
export default { export default {
name: "EnumInput", name: "EnumInput",
components: {InputWrapper,}, components: {InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
computed: { computed: {
editValue() { editValue() {
return this.value === undefined ? this.property.default : this.value; return this.value === undefined ? this.property.default : this.value;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<slot></slot> <slot></slot>
</template> </template>
<el-popover <el-popover
v-if="linkable"
trigger="click" trigger="click"
:disabled="!editable" :disabled="!editable"
> >
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
container: {}, container: {},
propertyName: String, propertyName: String,
editable: Boolean, editable: Boolean,
linkable: Boolean,
contentWidth: { contentWidth: {
type: String, type: String,
default: '65%', default: '65%',
...@@ -74,12 +76,12 @@ ...@@ -74,12 +76,12 @@
methods: { methods: {
onChange(v) { onChange(v) {
if (v) { if (v) {
this.$set(this.container.data.props, this.propertyName, { this.$set(this.container, this.propertyName, {
type: 'link', type: 'link',
alias: undefined, alias: undefined,
}); });
} else { } else {
this.$delete(this.container.data.props, this.propertyName); this.$delete(this.container, this.propertyName);
} }
} }
} }
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property"
:propertyName="propertyName"> :propertyName="propertyName">
<div style="display: flex;flex: 1;"> <div style="display: flex;flex: 1;">
<el-popover <el-popover
...@@ -38,13 +38,13 @@ ...@@ -38,13 +38,13 @@
<script> <script>
import InputWrapper from "./InputWrapper"; import InputWrapper from "./InputWrapper";
import {getInputDefaultValue} from "../../../../utils"; import {getInputDefaultValue} from "../../utils";
import DynamicSelector from "./DynamicSelector"; import DynamicSelector from "./DynamicSelector";
export default { export default {
name: "MapInput", name: "MapInput",
components: {DynamicSelector, InputWrapper,}, components: {DynamicSelector, InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
data() { data() {
let dataTypes = this.$t('dataTypes'); let dataTypes = this.$t('dataTypes');
return { return {
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property"
:propertyName="propertyName"> :propertyName="propertyName">
<div style="display: flex;flex: 1;"> <div style="display: flex;flex: 1;">
<el-popover <el-popover
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
export default { export default {
name: "NodeSelectInput", name: "NodeSelectInput",
components: {InputWrapper,}, components: {InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
data() { data() {
return { return {
editValueOrigin: this.value, editValueOrigin: this.value,
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName"> <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property" :propertyName="propertyName">
<el-input-number :disabled="!editable" :value="editValue" @input="onInput" controls-position="right" <el-input-number :disabled="!editable" :value="editValue" @input="onInput" controls-position="right"
:placeholder="defaultValue"></el-input-number> :placeholder="defaultValue"></el-input-number>
</input-wrapper> </input-wrapper>
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<script> <script>
import InputWrapper from "./InputWrapper"; import InputWrapper from "./InputWrapper";
import {getInputDefaultValue} from "../../../../utils"; import {getInputDefaultValue} from "../../utils";
export default { export default {
name: "NumberInput", name: "NumberInput",
components: {InputWrapper,}, components: {InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
computed: { computed: {
editValue() { editValue() {
return this.value === undefined ? this.property.default : this.value; return this.value === undefined ? this.property.default : this.value;
......
<template> <template>
<input-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName"> <input-wrapper :editable="editable" :linkable="linkable" :value="value" :container="container" :property="property" :propertyName="propertyName">
<div style="display: flex;flex: 1;"> <div style="display: flex;flex: 1;">
<el-popover <el-popover
placement="top" placement="top"
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
<script> <script>
import InputWrapper from "./InputWrapper"; import InputWrapper from "./InputWrapper";
import {getInputDefaultValue} from "../../../../utils"; import {getInputDefaultValue} from "../../utils";
export default { export default {
name: "StringInput", name: "StringInput",
components: {InputWrapper,}, components: {InputWrapper,},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'linkable'],
data() { data() {
return { return {
editValueOrigin: this.value, editValueOrigin: this.value,
......
/**
* Created by rockyl on 2020-01-08.
*/
export {default as NumberInput} from './NumberInput';
export {default as StringInput} from './StringInput';
export {default as EnumInput} from './EnumInput';
export {default as BooleanInput} from './BooleanInput';
export {default as ColorInput} from './ColorInput';
export {default as AssetInput} from './AssetInput';
export {default as NodeSelectInput} from './NodeSelectInput';
export {default as MapInput} from './MapInput';
export {default as DynamicInput} from './DynamicInput';
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"Save And Close": "Save And Close", "Save And Close": "Save And Close",
"Reset": "Reset", "Reset": "Reset",
"Copy": "Copy", "Copy": "Copy",
"Assets config": "Assets config", "Assets": "Assets",
"Paste same level":"Paste(same level)", "Paste same level":"Paste(same level)",
"Paste child":"Paste(child)", "Paste child":"Paste(child)",
"Exit": "Exit", "Exit": "Exit",
...@@ -203,6 +203,7 @@ ...@@ -203,6 +203,7 @@
"static": "Static", "static": "Static",
"arguments": "Arguments", "arguments": "Arguments",
"data-center": "DataCenter", "data-center": "DataCenter",
"scope": "Scope",
"env": "Env" "env": "Env"
}, },
"prosTypes": { "prosTypes": {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"Save And Close": "保存并关闭", "Save And Close": "保存并关闭",
"Reset": "重置", "Reset": "重置",
"Copy": "复制", "Copy": "复制",
"Assets config": "素材配置", "Assets": "素材",
"Paste same level":"粘贴(同级)", "Paste same level":"粘贴(同级)",
"Paste child":"粘贴(子级)", "Paste child":"粘贴(子级)",
"Exit": "退出", "Exit": "退出",
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
"textinput": "输入框", "textinput": "输入框",
"scrollView": "滚动视图", "scrollView": "滚动视图",
"scrollList": "滚动列表", "scrollList": "滚动列表",
"htmlView": "HTML视图",
"svga": "SVGA" "svga": "SVGA"
}, },
"panes": { "panes": {
...@@ -209,6 +210,7 @@ ...@@ -209,6 +210,7 @@
"static": "静态", "static": "静态",
"arguments": "入参", "arguments": "入参",
"data-center": "数据中心", "data-center": "数据中心",
"scope": "当前域",
"env": "自定义" "env": "自定义"
}, },
"prosTypes": { "prosTypes": {
......
...@@ -16,6 +16,7 @@ import {addBehavior, deleteProcessMeta, findProcess} from "./behavior"; ...@@ -16,6 +16,7 @@ import {addBehavior, deleteProcessMeta, findProcess} from "./behavior";
import db from "../../utils/db-storage"; import db from "../../utils/db-storage";
import {preprocess} from "../../views/Preview/preview-preprocess"; import {preprocess} from "../../views/Preview/preview-preprocess";
import {fetchApi} from "../../api/common";
const storeName = 'project'; const storeName = 'project';
...@@ -769,10 +770,19 @@ async function uploadFiles(files) { ...@@ -769,10 +770,19 @@ async function uploadFiles(files) {
}; };
} }
async function getSheetUrlByUUID(uuid) {
const response = await fetchApi('/api/uuid2url', {
params: {uuid},
errMessage: 'Failed to get url',
});
return response.url;
}
async function packAssets(assets) { async function packAssets(assets) {
let failedList = []; let failedList = [];
let newAssets = assets.concat(); let newAssets = assets.concat();
await packImages(newAssets); await packImages(newAssets, {getSheetUrlByUUID});
for (let asset of newAssets) { for (let asset of newAssets) {
if (asset.file) { if (asset.file) {
...@@ -786,7 +796,7 @@ async function packAssets(assets) { ...@@ -786,7 +796,7 @@ async function packAssets(assets) {
}; };
let sheetConfigFile = new File([JSON.stringify(sheetConfig)], 'sheet.json', {type: 'plain/text'}); let sheetConfigFile = new File([JSON.stringify(sheetConfig)], 'sheet.json', {type: 'plain/text'});
const {url: sheetConfigUrl} = await uploadFile(sheetConfigFile).catch(e => { const {url: sheetConfigUrl} = await uploadFile(sheetConfigFile, false, asset.sheetUUID).catch(e => {
failedList.push(asset); failedList.push(asset);
}); });
asset.url = sheetConfigUrl; asset.url = sheetConfigUrl;
...@@ -794,6 +804,7 @@ async function packAssets(assets) { ...@@ -794,6 +804,7 @@ async function packAssets(assets) {
delete asset.file; delete asset.file;
delete asset.frames; delete asset.frames;
delete asset.sheetUUID;
} }
} }
......
...@@ -34,7 +34,7 @@ content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, u ...@@ -34,7 +34,7 @@ content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, u
<body> <body>
<div id="$CONTAINER_ID$" style="line-height:0;font-size:0"></div> <div id="$CONTAINER_ID$" style="line-height:0;font-size:0"></div>
<script src="${process.env.NODE_ENV === 'development' ? 'http://10.10.92.100:4002/debug/engine.js' : 'http://yun.duiba.com.cn/editor/zeroing/libs/engine.269ce0ee2f951a11e004eee2df2fa1d875fa0b62.js'}"></script> <script src="${process.env.NODE_ENV === 'development' ? 'http://10.10.92.100:4002/debug/engine.js' : 'http://yun.duiba.com.cn/editor/zeroing/libs/engine.4db1f30a604493bbb87d4966af54cdd10840047a.js'}"></script>
$SCRIPTS$ $SCRIPTS$
<script> <script>
engine.launch('//yun.duiba.com.cn/aurora/$VERSION$-data.json'); engine.launch('//yun.duiba.com.cn/aurora/$VERSION$-data.json');
......
...@@ -280,25 +280,7 @@ $dock-pin-width: 9px; ...@@ -280,25 +280,7 @@ $dock-pin-width: 9px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.linked {
display: block;
height: 26px;
overflow: hidden;
border: 1px solid $--border-color-base;
border-radius: 4px;
background-color: $--background-color-base;
flex: 1;
padding: 0 5px;
color: $--color-text-secondary;
}
.el-input-group__prepend {
padding: 0 5px;
}
.el-select {
width: 100%;
}
.wrapper { .wrapper {
padding: 5px; padding: 5px;
...@@ -318,41 +300,6 @@ $dock-pin-width: 9px; ...@@ -318,41 +300,6 @@ $dock-pin-width: 9px;
.scrollbar-view { .scrollbar-view {
padding-right: 10px; padding-right: 10px;
.input-wrapper {
.label {
p {
margin: 0;
//text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.alias {
line-height: 16px;
font-size: 14px;
}
.property-name {
line-height: 12px;
font-size: 12px;
color: $--color-text-secondary;
}
}
}
}
.el-form-item__content {
display: flex;
justify-content: flex-end;
.el-input-number--mini {
flex: 1;
}
}
.node-select-container {
flex: 1;
} }
} }
} }
...@@ -460,3 +407,60 @@ $dock-pin-width: 9px; ...@@ -460,3 +407,60 @@ $dock-pin-width: 9px;
color: $--color-text-secondary; color: $--color-text-secondary;
} }
} }
.props-editor{
.linked {
display: block;
height: 26px;
overflow: hidden;
border: 1px solid $--border-color-base;
border-radius: 4px;
background-color: $--background-color-base;
flex: 1;
padding: 0 5px;
color: $--color-text-secondary;
}
.el-input-group__prepend {
padding: 0 5px;
}
.el-select {
width: 100%;
}
.input-wrapper {
.label {
p {
margin: 0;
//text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.alias {
line-height: 16px;
font-size: 14px;
}
.property-name {
line-height: 12px;
font-size: 12px;
color: $--color-text-secondary;
}
}
}
.el-form-item__content {
display: flex;
justify-content: flex-end;
.el-input-number--mini {
flex: 1;
}
}
.node-select-container {
flex: 1;
}
}
...@@ -6,6 +6,14 @@ import {Message, Loading} from "element-ui"; ...@@ -6,6 +6,14 @@ import {Message, Loading} from "element-ui";
import i18n from '../i18n' import i18n from '../i18n'
import generateUUID from "uuid/v4"; import generateUUID from "uuid/v4";
export const dynamicIconMapping = {
'static': 'S',
'arguments': 'A',
'data-center': 'D',
'scope': 'O',
'env': 'E',
};
export function messageError(e) { export function messageError(e) {
Message({ Message({
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
......
...@@ -138,7 +138,10 @@ export default { ...@@ -138,7 +138,10 @@ export default {
htmlText: { htmlText: {
title: 'HTML内容', title: 'HTML内容',
type: 'input', type: 'input',
value: '' value: '',
props: {
clearable: true,
},
}, },
bold: { bold: {
title: '粗体', title: '粗体',
...@@ -194,7 +197,7 @@ export default { ...@@ -194,7 +197,7 @@ export default {
{ label: '居中', value: 'middle' }, { label: '居中', value: 'middle' },
{ label: '靠下', value: 'down' } { label: '靠下', value: 'down' }
], ],
value: 'top' value: 'up'
}, },
}, },
bitmapText: { bitmapText: {
...@@ -203,12 +206,18 @@ export default { ...@@ -203,12 +206,18 @@ export default {
text: { text: {
title: '文本内容', title: '文本内容',
type: 'input', type: 'input',
value: '' value: '',
props: {
clearable: true,
},
}, },
font: { font: {
title: '字体名', title: '字体名',
type: 'input', type: 'input',
value: '' value: '',
props: {
clearable: true,
},
}, },
letterSpacing: { letterSpacing: {
title: '字间距', title: '字间距',
...@@ -241,7 +250,10 @@ export default { ...@@ -241,7 +250,10 @@ export default {
pattern: { pattern: {
title: '输入模式', title: '输入模式',
type: 'input', type: 'input',
value: '' value: '',
props: {
clearable: true,
},
}, },
maxLength: { maxLength: {
title: '最大长度', title: '最大长度',
...@@ -251,7 +263,10 @@ export default { ...@@ -251,7 +263,10 @@ export default {
placeholder: { placeholder: {
title: '提示文字', title: '提示文字',
type: 'input', type: 'input',
value: '' value: '',
props: {
clearable: true,
},
}, },
placeholderColor: { placeholderColor: {
title: '提示颜色', title: '提示颜色',
...@@ -414,11 +429,15 @@ export default { ...@@ -414,11 +429,15 @@ export default {
value: true, value: true,
}, },
}, },
/*htmlView: { htmlView: {
base: 'node',
groupName: 'HTML视图', groupName: 'HTML视图',
htmlElement: { htmlElement: {
title: 'HTML内容', title: 'HTML内容',
type: 'input', type: 'input',
props: {
clearable: true,
},
}, },
}*/ },
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import MaxRectsBinPack from "./MaxRectsBinPack"; import MaxRectsBinPack from "./MaxRectsBinPack";
import {clonePureObj} from "./index"; import {clonePureObj} from "./index";
import sha256 from "crypto-js/sha256";
import generateUUID from "uuid/v4";
const packExts = ['.png']; //, '.jpg', '.jpeg', '.bmp' const packExts = ['.png']; //, '.jpg', '.jpeg', '.bmp'
...@@ -14,6 +16,8 @@ export async function packImages(asssts, options = {}) { ...@@ -14,6 +16,8 @@ export async function packImages(asssts, options = {}) {
const maxSize = options.maxSize || 2048; const maxSize = options.maxSize || 2048;
const mode = options.mode || 0; const mode = options.mode || 0;
const {getSheetUrlByUUID} = options;
const images = await preProcessing(asssts); const images = await preProcessing(asssts);
let rects = [], singles = []; let rects = [], singles = [];
...@@ -70,7 +74,7 @@ export async function packImages(asssts, options = {}) { ...@@ -70,7 +74,7 @@ export async function packImages(asssts, options = {}) {
}); });
let frames = {}; let frames = {};
let i = 0; let i = 0, urls = [];
for (let rect of packedRects) { for (let rect of packedRects) {
let sprite = { let sprite = {
x: rect.x + padding, x: rect.x + padding,
...@@ -83,17 +87,36 @@ export async function packImages(asssts, options = {}) { ...@@ -83,17 +87,36 @@ export async function packImages(asssts, options = {}) {
sh: rect.sourceH, sh: rect.sourceH,
}; };
urls.push(rect.assets[0].url);
for (let asset of rect.assets) { for (let asset of rect.assets) {
frames[asset.uuid] = Object.assign({}, sprite, {name: asset.name}); frames[asset.uuid] = Object.assign({}, sprite, {name: asset.name});
i++; i++;
} }
} }
asssts.push({ const sheetUUID = sha256(urls.sort().join()).toString();
ext: '.sht',
file: new File([blob], name + '.png'), let url;
frames, if (getSheetUrlByUUID) {
}); url = await getSheetUrlByUUID(sheetUUID);
}
if(url){
asssts.push({
ext: '.sht',
url,
uuid: generateUUID(),
});
}else{
asssts.push({
ext: '.sht',
file: new File([blob], name + '.png'),
frames,
sheetUUID,
});
}
index++; index++;
} }
} }
...@@ -113,7 +136,7 @@ function loadImage(url, assets) { ...@@ -113,7 +136,7 @@ function loadImage(url, assets) {
}) })
} }
async function preProcessing(assets) { export async function preProcessing(assets) {
let targetAssets = []; let targetAssets = [];
for (let i = 0, li = assets.length; i < li; i++) { for (let i = 0, li = assets.length; i < li; i++) {
const asset = assets[i]; const asset = assets[i];
...@@ -134,6 +157,7 @@ async function preProcessing(assets) { ...@@ -134,6 +157,7 @@ async function preProcessing(assets) {
} }
let ps = []; let ps = [];
for (let url in groups) { for (let url in groups) {
ps.push(loadImage(url, groups[url])) ps.push(loadImage(url, groups[url]))
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</template> </template>
<template v-else> <template v-else>
{{objToString(data.props[key].value)}} {{objToString(data.props[key].value)}}
<i class="tag">{{data.props[key].type[0].toUpperCase()}}</i> <i class="tag">{{dynamicIconMapping[data.props[key].type]}}</i>
</template> </template>
</span> </span>
</span> </span>
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
import {mapState} from "vuex"; import {mapState} from "vuex";
import DockPin from "./DockPin"; import DockPin from "./DockPin";
import events from "../../../../global-events"; import events from "../../../../global-events";
import {dynamicIconMapping} from "../../../../utils";
export default { export default {
name: "ProcessNode", name: "ProcessNode",
...@@ -69,6 +70,7 @@ ...@@ -69,6 +70,7 @@
height: 100, height: 100,
inputMeta, inputMeta,
active: false, active: false,
dynamicIconMapping,
} }
}, },
mounted() { mounted() {
......
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
</template> </template>
<script> <script>
import ElFormItem from "./inputs/form-item";
import PropsEditorDialog from "./PropsEditorDialog"; import PropsEditorDialog from "./PropsEditorDialog";
import MonacoEditor from "../components/MonacoEditor"; import MonacoEditor from "../components/MonacoEditor";
import copy from "copy-to-clipboard"; import copy from "copy-to-clipboard";
...@@ -141,7 +140,15 @@ import events from "../../../global-events"; ...@@ -141,7 +140,15 @@ import events from "../../../global-events";
import CodeSyncIndicator from "../BottomBar/CodeSyncIndicator"; import CodeSyncIndicator from "../BottomBar/CodeSyncIndicator";
import CodeEditor from "./CodeEditor"; import CodeEditor from "./CodeEditor";
const exposeVariables = ["args", "props", "target", "global", "vm", "engine"]; const exposeVariables = [
"args",
"props",
"target",
"global",
"vm",
"engine",
"scope"
];
export default { export default {
name: "MetaEditorDialog", name: "MetaEditorDialog",
...@@ -149,8 +156,9 @@ export default { ...@@ -149,8 +156,9 @@ export default {
CodeEditor, CodeEditor,
CodeSyncIndicator, CodeSyncIndicator,
PropsEditorDialog, PropsEditorDialog,
ElFormItem, // ElFormItem,
"monaco-editor": MonacoEditor "monaco-editor": MonacoEditor
//"monaco-editor": MonacoEditor
}, },
data() { data() {
return { return {
...@@ -224,7 +232,7 @@ export default { ...@@ -224,7 +232,7 @@ export default {
this.$t("Alert") this.$t("Alert")
).catch(e => {}); ).catch(e => {});
} else { } else {
this.meta.script = this.$refs.codeEditor.editor.getValue(); //this.meta.script = this.$refs.codeEditor.editor.getValue();
this.$emit("input", this.meta, isPreview); this.$emit("input", this.meta, isPreview);
this.visible = false; this.visible = false;
this.meta = null; this.meta = null;
......
<template> <template>
<div class="wrapper" v-if="process"> <div class="wrapper" v-if="process">
<el-input :readonly="!editable" class="name-input" v-model="process.data.alias" clearable :placeholder="process.meta.name" size="mini"> <el-input :readonly="!editable" class="name-input" v-model="process.data.alias" clearable
:placeholder="process.meta.name" size="mini">
<template slot="prepend">{{$t('Name')}}</template> <template slot="prepend">{{$t('Name')}}</template>
</el-input> </el-input>
<el-scrollbar class="scrollbar" wrap-class="wrap-x-hidden" <el-scrollbar class="scrollbar" wrap-class="wrap-x-hidden"
view-class="scrollbar-view"> view-class="scrollbar-view">
<el-form v-model="process" size="mini" label-width="100px" label-position="left" @submit.native.prevent> <props-editor ref="propsEditor" :editable="editable" :linkable="true" :data="process.data" :meta="process.meta"/>
<component v-for="(property, key) in process.meta.props"
:is="getInput(property)"
v-model="process.data.props[key]"
:propertyName="key"
:property="property"
:container="process"
:key="key"
:editable="editable"
/>
</el-form>
</el-scrollbar> </el-scrollbar>
</div> </div>
</template> </template>
<script> <script>
import {mapState} from "vuex"; import {mapState} from "vuex";
import NumberInput from "./inputs/NumberInput"; import PropsEditor from "../../../components/PropsEditor";
import StringInput from "./inputs/StringInput";
import EnumInput from "./inputs/EnumInput";
import BooleanInput from "./inputs/BooleanInput";
import ColorInput from "./inputs/ColorInput";
import AssetInput from "./inputs/AssetInput";
import NodeSelectInput from "./inputs/NodeSelectInput";
import MapInput from "./inputs/MapInput";
import DynamicInput from "./inputs/DynamicInput";
const inputMapping = {
number: 'NumberInput',
string: 'StringInput',
enum: 'EnumInput',
boolean: 'BooleanInput',
color: 'ColorInput',
asset: 'AssetInput',
node: 'NodeSelectInput',
dynamic: 'DynamicInput',
map: 'MapInput',
};
export default { export default {
name: "PropertiesInput", name: "PropertiesInput",
components: { components: {
DynamicInput, PropsEditor,
MapInput, NodeSelectInput, AssetInput, ColorInput, BooleanInput, EnumInput, NumberInput, StringInput}, },
data() { data() {
return { return {
process: null, process: null,
......
...@@ -28,13 +28,12 @@ ...@@ -28,13 +28,12 @@
<script> <script>
import {mapMutations, mapState} from 'vuex' import {mapMutations, mapState} from 'vuex'
import EnabledSetter from "../components/EnabledSetter"; import EnabledSetter from "../components/EnabledSetter";
import ElFormItem from "../behavior-editor/inputs/form-item";
import {clonePureObj} from "../../../utils"; import {clonePureObj} from "../../../utils";
import {startCodeSyncServe} from "../../../code-sync-serve"; import {startCodeSyncServe} from "../../../code-sync-serve";
export default { export default {
name: "CodeSyncServeDialog", name: "CodeSyncServeDialog",
components: {ElFormItem, EnabledSetter,}, components: {EnabledSetter,},
data() { data() {
return { return {
visible: false, visible: false,
......
...@@ -19,12 +19,20 @@ ...@@ -19,12 +19,20 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="assets" prop="assets"
:label="$t('Assets config')" :label="$t('Assets')"
width="100"> width="60">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" icon="el-icon-edit" circle type="primary" plain @click="editAssetMapping(scope.row)"/> <el-button size="mini" icon="el-icon-edit" circle type="primary" plain @click="editAssetMapping(scope.row)"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="props"
:label="$t('Props')"
width="60">
<template slot-scope="scope">
<el-button size="mini" icon="el-icon-edit" circle type="primary" plain @click="editProps(scope.row)"/>
</template>
</el-table-column>
<!--<el-table-column <!--<el-table-column
label="Version" label="Version"
width="100" width="100"
...@@ -36,6 +44,7 @@ ...@@ -36,6 +44,7 @@
<el-table-column> <el-table-column>
</el-table-column> </el-table-column>
<asset-mapping-editor-dialog ref="assetMappingEditorDialog" @save="onSaveAssetMapping"/> <asset-mapping-editor-dialog ref="assetMappingEditorDialog" @save="onSaveAssetMapping"/>
<props-editor-dialog ref="propsEditorDialog"/>
</el-table> </el-table>
</template> </template>
...@@ -43,10 +52,11 @@ ...@@ -43,10 +52,11 @@
import {mapState, mapMutations} from 'vuex' import {mapState, mapMutations} from 'vuex'
import {clonePureObj} from "../../../../utils"; import {clonePureObj} from "../../../../utils";
import AssetMappingEditorDialog from "./AssetMappingEditorDialog"; import AssetMappingEditorDialog from "./AssetMappingEditorDialog";
import PropsEditorDialog from "./CustomModuleEditor/PropsEditorDialog";
export default { export default {
name: "CustomModuleEditor", name: "CustomModuleEditor",
components: {AssetMappingEditorDialog}, components: {PropsEditorDialog, AssetMappingEditorDialog},
data() { data() {
return { return {
visible: false, visible: false,
...@@ -64,12 +74,18 @@ ...@@ -64,12 +74,18 @@
this.editData = clonePureObj(this.customs); this.editData = clonePureObj(this.customs);
this.customMetas.splice(0); this.customMetas.splice(0);
for (let meta of this.$store.state.env.customs) { for (let meta of this.$store.state.env.customs) {
let data = this.editData.find(item => item.id === meta.id); let editData = this.editData.find(item => item.id === meta.id);
let data = editData ? editData : (editData || {});
if (!data.props) {
data.props = {};
}
this.customMetas.push({ this.customMetas.push({
id: meta.id, id: meta.id,
name: meta.name, name: meta.name,
assetMapping: data && (data.assetMapping || {}), meta,
selected: !!data, data,
assetMapping: editData && (editData.assetMapping || {}),
selected: !!editData,
}) })
} }
}, },
...@@ -81,16 +97,20 @@ ...@@ -81,16 +97,20 @@
editData.push({ editData.push({
id: meta.id, id: meta.id,
assetMapping: meta.assetMapping || {}, assetMapping: meta.assetMapping || {},
props: meta.data.props || {},
}); });
} }
} }
this.modifyCustoms(editData); this.modifyCustoms(editData);
}, },
editAssetMapping(data) { editAssetMapping(item) {
this.$refs.assetMappingEditorDialog.show(data); this.$refs.assetMappingEditorDialog.show(item);
},
editProps(item) {
this.$refs.propsEditorDialog.show(item.data, item.meta);
}, },
onSaveAssetMapping(mid, assetMapping) { onSaveAssetMapping(mid, assetMapping) {
this.customMetas.find(item=>item.id === mid).assetMapping = assetMapping; this.customMetas.find(item => item.id === mid).assetMapping = assetMapping;
}, },
...mapMutations([ ...mapMutations([
'modifyCustoms', 'modifyCustoms',
......
<template>
<el-dialog :title="$t('Props Editor')" width="70%" :visible.sync="visible" @opened="onOpen"
:close-on-click-modal="false"
:append-to-body="true"
:show-close="false"
>
<el-scrollbar class="scrollbar" wrap-class="wrap-x-hidden"
view-class="scrollbar-view">
<props-editor v-if="data" ref="propsEditor" :data="data" :meta="meta" :linkable="false"/>
</el-scrollbar>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="onClose">{{$t('Close')}}</el-button>
<el-button size="mini" @click="onSave" type="primary">{{$t('Save')}}</el-button>
</div>
</el-dialog>
</template>
<script>
import PropsEditor from "../../../../../components/PropsEditor";
export default {
name: "PropsEditorDialog",
components: {PropsEditor},
data() {
return {
visible: false,
data: null,
meta: null,
}
},
methods: {
show(data, meta) {
this.data = data;
this.meta = meta;
this.visible = true;
},
onSave() {
this.visible = false;
},
onClose() {
this.visible = false;
},
onOpen() {
},
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment