Commit b820bdb3 authored by rockyl's avatar rockyl

增加env编辑

parent 7756514c
...@@ -11,6 +11,10 @@ if (process.env.NODE_ENV === 'development') { ...@@ -11,6 +11,10 @@ if (process.env.NODE_ENV === 'development') {
API_HOST = window.__data.apiHost; API_HOST = window.__data.apiHost;
} }
if (API_HOST[API_HOST.length - 1] === '/') {
API_HOST = API_HOST.substr(0, API_HOST.length - 1);
}
export const UPLOAD_FILE_URL = API_HOST + '/api/uploadFile'; export const UPLOAD_FILE_URL = API_HOST + '/api/uploadFile';
export const PARSE_BUNDLE_URL = API_HOST + '/api/parsePSD'; export const PARSE_BUNDLE_URL = API_HOST + '/api/parsePSD';
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"Export": "Export", "Export": "Export",
"Upload": "Upload", "Upload": "Upload",
"Edit": "Edit", "Edit": "Edit",
"Env": "Env",
"ID": "ID", "ID": "ID",
"Name": "Name", "Name": "Name",
"Alias": "Alias", "Alias": "Alias",
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
"Props Editor": "Props Editor", "Props Editor": "Props Editor",
"Trigger once": "Trigger once", "Trigger once": "Trigger once",
"Meta Editor": "Meta Editor", "Meta Editor": "Meta Editor",
"Env editor": "Env editor",
"As inline": "As inline", "As inline": "As inline",
"Link to parent": "Link to parent", "Link to parent": "Link to parent",
"Input project name": "Input project name", "Input project name": "Input project name",
...@@ -96,7 +98,7 @@ ...@@ -96,7 +98,7 @@
"Confirm to exit the editor": "Confirm to exit the editor?", "Confirm to exit the editor": "Confirm to exit the editor?",
"Confirm to publish": "Confirm to publish?", "Confirm to publish": "Confirm to publish?",
"Are you sure to delete this asset": "Are you sure to delete this asset", "Are you sure to delete this asset": "Are you sure to delete this asset",
"Are you sure to delete this link": "Are you sure to delete this link", "Are you sure to delete this item": "Are you sure to delete this item",
"Rename asset": "Rename asset", "Rename asset": "Rename asset",
"Input asset name": "Input asset name", "Input asset name": "Input asset name",
"Invalid asset name": "Invalid asset name", "Invalid asset name": "Invalid asset name",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"Export": "导出", "Export": "导出",
"Upload": "上传", "Upload": "上传",
"Edit": "编辑", "Edit": "编辑",
"Env": "环境",
"ID": "ID", "ID": "ID",
"Name": "名字", "Name": "名字",
"Alias": "别名", "Alias": "别名",
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
"Props Editor": "属性编辑器", "Props Editor": "属性编辑器",
"Trigger once": "触发一次", "Trigger once": "触发一次",
"Meta Editor": "过程元配置", "Meta Editor": "过程元配置",
"Env editor": "环境编辑器",
"As inline": "作为内联", "As inline": "作为内联",
"Link to parent": "连接到父节点", "Link to parent": "连接到父节点",
"Input project name": "输入项目名", "Input project name": "输入项目名",
...@@ -96,7 +98,7 @@ ...@@ -96,7 +98,7 @@
"Confirm to exit the editor": "确定退出编辑器吗?", "Confirm to exit the editor": "确定退出编辑器吗?",
"Confirm to publish": "确定发布吗?", "Confirm to publish": "确定发布吗?",
"Are you sure to delete this asset": "确定删除素材吗", "Are you sure to delete this asset": "确定删除素材吗",
"Are you sure to delete this link": "确定删除映射吗", "Are you sure to delete this item": "确定删除这一项吗",
"Rename asset": "重命名素材", "Rename asset": "重命名素材",
"Input asset name": "输入素材名", "Input asset name": "输入素材名",
"Invalid asset name": "无效的素材名", "Invalid asset name": "无效的素材名",
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
*/ */
import Vue from "vue"; import Vue from "vue";
import JSZip from "jszip"; import JSZip from "jszip";
import { projectApi } from "../../api"; import {projectApi} from "../../api";
import path from "path"; import path from "path";
import generateUUID from "uuid/v4"; import generateUUID from "uuid/v4";
import { getCmpProps, flattenViews, getCmpByUUID } from '../../utils/common'; import {getCmpProps, flattenViews, getCmpByUUID} from '../../utils/common';
import {clonePureObj, saveAs} from "../../utils"; import {clonePureObj, saveAs} from "../../utils";
import { template } from "../../template"; import {template} from "../../template";
const defaultOptions = { const defaultOptions = {
pageTitle: 'no title', pageTitle: 'no title',
...@@ -20,6 +20,10 @@ const defaultOptions = { ...@@ -20,6 +20,10 @@ const defaultOptions = {
scaleMode: 'fixedWidth', scaleMode: 'fixedWidth',
rendererType: 'webgl', rendererType: 'webgl',
tpl: template, tpl: template,
env: {
appID: '',
projectID: '',
},
}; };
const OPERATE_MAX_LENGTH = 200; // 撤销重做栈最大值 const OPERATE_MAX_LENGTH = 200; // 撤销重做栈最大值
...@@ -54,14 +58,14 @@ export const projectStore = { ...@@ -54,14 +58,14 @@ export const projectStore = {
state.dirty = dirty; state.dirty = dirty;
}, },
updateProject(state, project) { updateProject(state, project) {
const { id, name, creator, data } = project; const {id, name, creator, data} = project;
state.id = id; state.id = id;
state.name = name; state.name = name;
state.creator = creator; state.creator = creator;
const localData = state.data; const localData = state.data;
if (data) { if (data) {
const { views, assets, dataMapping, processes, options, } = JSON.parse(data); const {views, assets, dataMapping, processes, options, } = JSON.parse(data);
Vue.set(localData, 'options', options || getDefaultOptions()); Vue.set(localData, 'options', options || getDefaultOptions());
Vue.set(localData, 'views', views || []); Vue.set(localData, 'views', views || []);
...@@ -249,7 +253,7 @@ export const projectStore = { ...@@ -249,7 +253,7 @@ export const projectStore = {
modifyProject(state) { modifyProject(state) {
}, },
addNode(state, { node, name, type }) { addNode(state, {node, name, type}) {
const child = { const child = {
name, name,
type, type,
...@@ -269,7 +273,7 @@ export const projectStore = { ...@@ -269,7 +273,7 @@ export const projectStore = {
importView(state, view) { importView(state, view) {
state.data.views.push(view); state.data.views.push(view);
}, },
deleteNode(state, { node, parentNode }) { deleteNode(state, {node, parentNode}) {
const parentChildren = parentNode.children || parentNode; const parentChildren = parentNode.children || parentNode;
const index = parentChildren.indexOf(node); const index = parentChildren.indexOf(node);
parentChildren.splice(index, 1); parentChildren.splice(index, 1);
...@@ -277,7 +281,7 @@ export const projectStore = { ...@@ -277,7 +281,7 @@ export const projectStore = {
importAssets(state, assets) { importAssets(state, assets) {
state.data.assets.push(...assets); state.data.assets.push(...assets);
}, },
addAsset(state, { url, file }) { addAsset(state, {url, file}) {
const ext = path.extname(file.name); const ext = path.extname(file.name);
state.data.assets.push({ state.data.assets.push({
name: path.basename(file.name, ext), name: path.basename(file.name, ext),
...@@ -287,7 +291,7 @@ export const projectStore = { ...@@ -287,7 +291,7 @@ export const projectStore = {
}) })
}, },
deleteAsset(state, uuid) { deleteAsset(state, uuid) {
const { assets } = state.data; const {assets} = state.data;
for (let i = 0, li = assets.length; i < li; i++) { for (let i = 0, li = assets.length; i < li; i++) {
const asset = state.data.assets[i]; const asset = state.data.assets[i];
if (asset.uuid === uuid) { if (asset.uuid === uuid) {
...@@ -318,10 +322,32 @@ export const projectStore = { ...@@ -318,10 +322,32 @@ export const projectStore = {
modifyDataMapping(state) { modifyDataMapping(state) {
}, },
addEnvMapping(state, link) {
if(!state.data.options.env){
Vue.set(state.data.options, 'env', []);
}
if (link) {
state.data.options.env.push(link);
} else {
state.data.options.env.push({
name: '',
value: '',
});
}
},
deleteEnvMapping(state, index) {
state.data.options.env.splice(index, 1);
},
modifyEnvMapping(state) {
},
}, },
getters: { getters: {
project(state) { project(state) {
const { id, name, creator, data } = state; const {id, name, creator, data} = state;
return { return {
id, name, creator, id, name, creator,
data: JSON.stringify(data), data: JSON.stringify(data),
...@@ -386,17 +412,17 @@ export const projectStore = { ...@@ -386,17 +412,17 @@ export const projectStore = {
} }
}, },
actions: { actions: {
saveToLocal({ getters, commit }) { saveToLocal({getters, commit}) {
const { project } = getters; const {project} = getters;
localStorage.setItem('project-' + project.id, JSON.stringify(project)); localStorage.setItem('project-' + project.id, JSON.stringify(project));
commit('setDirty', true); commit('setDirty', true);
}, },
localVersionExist({ commit }, projectID) { localVersionExist({commit}, projectID) {
let json = localStorage.getItem('project-' + projectID); let json = localStorage.getItem('project-' + projectID);
return !!json; return !!json;
}, },
loadFromLocal({ commit }, projectID) { loadFromLocal({commit}, projectID) {
let json = localStorage.getItem('project-' + projectID); let json = localStorage.getItem('project-' + projectID);
if (json) { if (json) {
const project = JSON.parse(json); const project = JSON.parse(json);
...@@ -404,11 +430,11 @@ export const projectStore = { ...@@ -404,11 +430,11 @@ export const projectStore = {
commit('setDirty', true); commit('setDirty', true);
} }
}, },
deleteLocalVersion({ state, commit }, projectID) { deleteLocalVersion({state, commit}, projectID) {
localStorage.removeItem('project-' + projectID); localStorage.removeItem('project-' + projectID);
commit('setDirty', false); commit('setDirty', false);
}, },
async loadFromRemote({ commit, dispatch }, projectID) { async loadFromRemote({commit, dispatch}, projectID) {
const project = await projectApi.fetchOne(projectID); const project = await projectApi.fetchOne(projectID);
if (project) { if (project) {
dispatch('deleteLocalVersion', projectID); dispatch('deleteLocalVersion', projectID);
...@@ -417,11 +443,11 @@ export const projectStore = { ...@@ -417,11 +443,11 @@ export const projectStore = {
throw new Error('Project does not exist') throw new Error('Project does not exist')
} }
}, },
async saveToRemote({ state, dispatch, getters }) { async saveToRemote({state, dispatch, getters}) {
await projectApi.saveOne(getters.project); await projectApi.saveOne(getters.project);
dispatch('deleteLocalVersion', state.id); dispatch('deleteLocalVersion', state.id);
}, },
async updateProject({ commit }, projectID) { async updateProject({commit}, projectID) {
const project = await projectApi.getData(projectID); const project = await projectApi.getData(projectID);
commit('updateProject', project); commit('updateProject', project);
}, },
...@@ -450,7 +476,7 @@ export const projectStore = { ...@@ -450,7 +476,7 @@ export const projectStore = {
/** /**
* 修改属性 * 修改属性
*/ */
modifyProperties({ commit, state, getters }, props) { modifyProperties({commit, state, getters}, props) {
// debugger; // debugger;
// 如果当前修改的是“来源”属性,节点又没有高度宽度,则取图片的高度宽度 // 如果当前修改的是“来源”属性,节点又没有高度宽度,则取图片的高度宽度
let _props = _.cloneDeep(state.activeComponent.properties); let _props = _.cloneDeep(state.activeComponent.properties);
...@@ -487,13 +513,13 @@ export const projectStore = { ...@@ -487,13 +513,13 @@ export const projectStore = {
* @param {*} param0 * @param {*} param0
* @param {*} props * @param {*} props
*/ */
modifyCopyProperties({ commit }, props) { modifyCopyProperties({commit}, props) {
commit('modifyCopyProperties', props) commit('modifyCopyProperties', props)
}, },
/** /**
* 修改当前选中的节点 * 修改当前选中的节点
*/ */
modifyActiveView({ commit }, view) { modifyActiveView({commit}, view) {
commit('modifyActiveView', view) commit('modifyActiveView', view)
}, },
...@@ -502,7 +528,7 @@ export const projectStore = { ...@@ -502,7 +528,7 @@ export const projectStore = {
* @param {*} param0 * @param {*} param0
* @param {*} data * @param {*} data
*/ */
addNodeScript({ commit, state }, script) { addNodeScript({commit, state}, script) {
let _scripts = _.cloneDeep(state.activeComponent.scripts || []); let _scripts = _.cloneDeep(state.activeComponent.scripts || []);
_scripts.push({ _scripts.push({
script: script, script: script,
...@@ -513,15 +539,15 @@ export const projectStore = { ...@@ -513,15 +539,15 @@ export const projectStore = {
}) })
}, },
exportView({ state }, view) { exportView({state}, view) {
let zip = new JSZip(); let zip = new JSZip();
zip.file('view.json', JSON.stringify(view)); zip.file('view.json', JSON.stringify(view));
zip.generateAsync({ type: "blob" }).then(function (content) { zip.generateAsync({type: "blob"}).then(function (content) {
saveAs(content, `view-${view.name}.zrv`); saveAs(content, `view-${view.name}.zrv`);
}); });
}, },
async packProject({ state }) { async packProject({state}) {
const result = await projectApi.pack(state.id); const result = await projectApi.pack(state.id);
console.log(result) console.log(result)
return result; return result;
......
...@@ -90,6 +90,21 @@ export function metaInUse(process, targetMetaID) { ...@@ -90,6 +90,21 @@ export function metaInUse(process, targetMetaID) {
return result; return result;
} }
export function clonePureObj(obj){ export function clonePureObj(obj) {
return JSON.parse(JSON.stringify(obj)); return JSON.parse(JSON.stringify(obj));
} }
export function readTextFile(file) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.readAsText(file);
fileReader.addEventListener('load', function (e) {
resolve(this.result);
}, false);
fileReader.addEventListener('error', function (e) {
reject(e);
}, false);
})
}
...@@ -191,7 +191,7 @@ export default { ...@@ -191,7 +191,7 @@ export default {
strokeWidth: { strokeWidth: {
title: '边框宽度', title: '边框宽度',
type: 'inputNumber', type: 'inputNumber',
value: 1, value: 0,
props: { props: {
min: 0 min: 0
} }
......
...@@ -70,8 +70,6 @@ const componentMapper = { ...@@ -70,8 +70,6 @@ const componentMapper = {
switch: { switch: {
component: 'el-switch', component: 'el-switch',
props: { props: {
activeColor: '#13ce66',
inactiveColor: '#eee',
width: 100 width: 100
} }
}, },
...@@ -121,8 +119,6 @@ const scriptTypeMap = { ...@@ -121,8 +119,6 @@ const scriptTypeMap = {
boolean: { boolean: {
component: 'el-switch', component: 'el-switch',
props: { props: {
activeColor: '#13ce66',
inactiveColor: '#eee',
width: 40 width: 40
} }
}, },
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
this.modifyDataMapping(); this.modifyDataMapping();
}, },
toDeleteItem(link, index){ toDeleteItem(link, index){
this.$confirm(this.$t('Are you sure to delete this link'), this.$t('Alert'), { this.$confirm(this.$t('Are you sure to delete this item'), this.$t('Alert'), {
confirmButtonText: this.$t('Confirm'), confirmButtonText: this.$t('Confirm'),
cancelButtonText: this.$t('Cancel'), cancelButtonText: this.$t('Cancel'),
type: 'warning' type: 'warning'
......
<template>
<el-dialog :title="$t('Env editor')" width="70%" :visible.sync="visible" @open="onOpen"
:append-to-body="true" :close-on-click-modal="false">
<div class="data-mapping-dialog">
<el-scrollbar class="scrollbar" wrap-class="wrap-x-hidden" view-class="view">
<div class="item" v-for="(link, index) in env">
<el-input size="mini" style="width: 30%" v-model="link.name" @change="onChange"/>
<el-icon class="el-icon-connection"/>
<el-input size="mini" v-model="link.value" @change="onChange"/>
<el-button icon="el-icon-minus" circle size="mini" @click="toDeleteItem(link, index)"/>
</div>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="onAdd">{{$t('Add')}}</el-button>
<el-button size="mini" type="primary" @click="onConfirm">{{$t('Confirm')}}</el-button>
</div>
</el-dialog>
</template>
<script>
import {mapState, mapMutations} from 'vuex'
export default {
name: "EnvEditorDialog",
data() {
return {
visible: false,
}
},
computed: {
...mapState({
env: state=> state.project.data.options.env,
}),
},
methods: {
show() {
this.visible = true;
},
onAdd() {
this.addEnvMapping();
},
onChange(){
this.modifyEnvMapping();
},
toDeleteItem(link, index){
this.$confirm(this.$t('Are you sure to delete this item'), this.$t('Alert'), {
confirmButtonText: this.$t('Confirm'),
cancelButtonText: this.$t('Cancel'),
type: 'warning'
}).then(() => {
this.deleteEnvMapping(index);
}).catch((e) => {
});
},
onConfirm() {
this.visible = false;
},
onOpen() {
},
...mapMutations([
'addDataMapping',
'deleteDataMapping',
'modifyDataMapping',
'addEnvMapping',
'deleteEnvMapping',
'modifyEnvMapping',
]),
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
...@@ -55,19 +55,21 @@ ...@@ -55,19 +55,21 @@
</el-form> </el-form>
</div> </div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button size="mini" @click="onEditEnv">{{$t('Env')}}</el-button>
<el-button size="mini" @click="onCancel">{{$t('Cancel')}}</el-button> <el-button size="mini" @click="onCancel">{{$t('Cancel')}}</el-button>
<el-button size="mini" type="primary" @click="onConfirm">{{$t('Save')}}</el-button> <el-button size="mini" type="primary" @click="onConfirm">{{$t('Save')}}</el-button>
</div> </div>
<env-editor-dialog ref="envEditorDialog"/>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import {mapState, mapGetters, mapMutations} from 'vuex'; import {mapState, mapGetters, mapMutations} from 'vuex';
import {RENDERER_TYPES, SCALE_MODES} from "../../../utils"; import EnvEditorDialog from "./EnvEditorDialog";
export default { export default {
name: "ProjectDetailsDialog", name: "ProjectDetailsDialog",
components: {EnvEditorDialog},
data() { data() {
const scaleMode = this.$t('scaleMode'); const scaleMode = this.$t('scaleMode');
const rendererType = this.$t('rendererType'); const rendererType = this.$t('rendererType');
...@@ -89,6 +91,9 @@ ...@@ -89,6 +91,9 @@
show() { show() {
this.visible = true; this.visible = true;
}, },
onEditEnv() {
this.$refs.envEditorDialog.show();
},
onCancel() { onCancel() {
this.$refs.form.resetFields(); this.$refs.form.resetFields();
this.visible = false; this.visible = false;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<el-form-item :label="$t('Project name')" prop="name"> <el-form-item :label="$t('Project name')" prop="name">
<el-input v-model="project.name" :maxlength="64"></el-input> <el-input v-model="project.name" :maxlength="64"></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('Template')"> <!--<el-form-item :label="$t('Template')">
<el-select v-model="template" placeholder="Select a template" no-data-text="No templates"> <el-select v-model="template" placeholder="Select a template" no-data-text="No templates">
<el-option-group <el-option-group
v-for="(group, groupName) in env.templates" v-if="Object.keys(group).length > 0" v-for="(group, groupName) in env.templates" v-if="Object.keys(group).length > 0"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
</el-select> </el-select>
</el-form-item> </el-form-item>-->
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button size="mini" @click="visible=false">{{$t('Cancel')}}</el-button> <el-button size="mini" @click="visible=false">{{$t('Cancel')}}</el-button>
......
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