Commit 2295c5c3 authored by rockyl's avatar rockyl

init

parent 2c352a61
{
"success": true,
"data": {
"id": "6e1c9eadf8e28",
"name": "测试",
"creator": "卞龙亭",
"operator": "卞龙亭",
"create_time": "2019-09-19T06:56:01.000Z",
"update_time": "2019-09-19T06:56:01.000Z",
"data": {
"views": [
{
"name": "view1",
"children": [
{
"name": "label"
},
{
"name": "image"
}
]
},
{
"name": "view2"
}
],
"assets": [
{
"name": "bg.jpg",
"url": "/bg.jpg"
},
{
"name": "btn-join.png",
"url": "/btn-join.png"
}
]
}
}
}
...@@ -49,7 +49,7 @@ export async function fetchApi(uri, {params, method, contentType, errMessage} = ...@@ -49,7 +49,7 @@ export async function fetchApi(uri, {params, method, contentType, errMessage} =
const response = await fetch(url, options); const response = await fetch(url, options);
const jsonObj = await response.json(); const jsonObj = await response.json();
console.log(jsonObj); //console.log(jsonObj);
if (jsonObj.success) { if (jsonObj.success) {
return jsonObj.data; return jsonObj.data;
......
...@@ -39,7 +39,7 @@ export async function deleteOne(id) { ...@@ -39,7 +39,7 @@ export async function deleteOne(id) {
} }
export async function getOne(id) { export async function getOne(id) {
return await fetchApi('/api/project/detail', { return await fetchApi('/api/project/details', {
params: {id}, params: {id},
method: 'get', method: 'get',
errMessage: 'Failed to get project', errMessage: 'Failed to get project',
......
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
"Alert": "Alert", "Alert": "Alert",
"Confirm": "Confirm", "Confirm": "Confirm",
"Cancel": "Cancel", "Cancel": "Cancel",
"Save": "Save",
"Failed to fetch": "Network error!",
"In processing": "In processing", "In processing": "In processing",
"Projects": "Projects", "Projects": "Projects",
"copy": "copy", "copy": "copy",
"No projects": "No projects", "No projects": "No projects",
"Create": "Create", "Create": "Create",
"Project details": "Project details",
"Project name": "Project name", "Project name": "Project name",
"Data mapping": "Data mapping",
"Template": "Template", "Template": "Template",
"Preparing": "Preparing…", "Preparing": "Preparing…",
"Create project": "Create project", "Create project": "Create project",
......
...@@ -5,7 +5,7 @@ import Home from './views/Home.vue' ...@@ -5,7 +5,7 @@ import Home from './views/Home.vue'
Vue.use(Router); Vue.use(Router);
export default new Router({ export default new Router({
mode: 'history', //mode: 'history',
base: process.env.BASE_URL, base: process.env.BASE_URL,
routes: [ routes: [
{ {
...@@ -14,7 +14,7 @@ export default new Router({ ...@@ -14,7 +14,7 @@ export default new Router({
component: Home component: Home
}, },
{ {
path: '/editor', path: '/editor/:projectID',
name: 'editor', name: 'editor',
// route level code-splitting // route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route // this generates a separate chunk (about.[hash].js) for this route
......
...@@ -9,15 +9,25 @@ export const projectStore = { ...@@ -9,15 +9,25 @@ export const projectStore = {
id: '', id: '',
name: '', name: '',
creator: '', creator: '',
data: {
views: [], views: [],
assets: [], assets: [],
dataMapping: [],
}
}, },
mutations: { mutations: {
updateProject(state, project) { updateProject(state, project) {
const {id, name, creator} = project; Object.assign(state, project);
state.id = id; const {data} = state;
state.name = name; if(!data.views){
state.creator = creator; data.views = [];
}
if(!data.assets){
data.assets = [];
}
if(!data.dataMapping){
data.dataMapping = [];
}
}, },
}, },
actions: { actions: {
......
...@@ -12,3 +12,13 @@ html, body, #app { ...@@ -12,3 +12,13 @@ html, body, #app {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
} }
.modal-layer{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.7);
z-index: 2;
}
@import "splitspanes"; @import "splitspanes";
@import "pane"; @import "pane";
@import "views";
@import "assets";
.editor { .editor {
display: flex; display: flex;
...@@ -7,12 +9,15 @@ ...@@ -7,12 +9,15 @@
flex-direction: column; flex-direction: column;
.tool-bar { .tool-bar {
display: flex;
align-items: center;
background-color: $--pane-background-color; background-color: $--pane-background-color;
margin-bottom: 1px; margin-bottom: 1px;
.menu{
padding: 5px 10px; padding: 5px 10px;
font-size: 13px;
.menu{
flex: 1;
a:not(:first-child){ a:not(:first-child){
margin-left: 10px; margin-left: 10px;
} }
...@@ -20,7 +25,7 @@ ...@@ -20,7 +25,7 @@
} }
.pane-container { .pane-container {
height: 100%; flex: 1;
} }
} }
......
...@@ -8,3 +8,20 @@ ...@@ -8,3 +8,20 @@
@import "./editor.scss"; @import "./editor.scss";
@import "~element-ui/packages/theme-chalk/src/index.scss"; @import "~element-ui/packages/theme-chalk/src/index.scss";
.el-tree {
background: transparent;
}
.wrap-x-hidden {
overflow-x: hidden;
}
.wrap-y-hidden {
overflow-y: hidden;
}
.el-tree-node__content > .el-tree-node__expand-icon{
padding: 6px 0;
}
...@@ -23,8 +23,8 @@ $--background-color-base: #F5F5F5; ...@@ -23,8 +23,8 @@ $--background-color-base: #F5F5F5;
$--font-path: '~element-ui/lib/theme-chalk/fonts'; $--font-path: '~element-ui/lib/theme-chalk/fonts';
//customs //customs
$--pane-background-color: mix($--background-color-base, $--color-black, 90%); $--pane-background-color: mix($--background-color-base, $--color-black, 95%);
$--pane-border-color: mix($--background-color-base, $--color-black, 80%); $--pane-border-color: mix($--background-color-base, $--color-black, 90%);
$main-border-color: mix($--background-color-base, $--color-white, 80%); $main-border-color: mix($--background-color-base, $--color-white, 80%);
......
@import "var";
.views{
.container{
display: flex;
flex: 1;
flex-direction: column;
.header-bar{
padding: 1px;
border-bottom: 1px solid $--pane-border-color;
a{
padding: 0 5px;
}
a:not(:first-child){
border-left: 2px solid $--pane-border-color;
}
}
.tree-scrollbar {
width: 100%;
flex: 1;
}
}
}
\ No newline at end of file
...@@ -11,20 +11,28 @@ ...@@ -11,20 +11,28 @@
</split-panes> </split-panes>
<inspector splitpanes-min="20" :splitpanes-size="getSize(0, 1)"></inspector> <inspector splitpanes-min="20" :splitpanes-size="getSize(0, 1)"></inspector>
</split-panes> </split-panes>
<project-details-dialog ref="projectDialogsDialog"/>
<data-mapping-dialog ref="dataMappingDialog"/>
</div> </div>
</template> </template>
<script> <script>
import {mapState, mapActions} from 'vuex'
import SplitPanes from 'splitpanes' import SplitPanes from 'splitpanes'
import ToolBar from "./Editor/ToolBar"; import ToolBar from "./Editor/ToolBar";
import Inspector from "./Editor/Inspector"; import Inspector from "./Editor/Inspector";
import Views from "./Editor/Views"; import Views from "./Editor/Views";
import Playground from "./Editor/Playground"; import Playground from "./Editor/Playground";
import Assets from "./Editor/Assets"; import Assets from "./Editor/Assets";
import ProjectDetailsDialog from "./Editor/dialogs/ProjectDetailsDialog";
import DataMappingDialog from "./Editor/dialogs/DataMappingDialog";
import {playWaiting} from "../utils";
export default { export default {
name: 'Editor', name: 'Editor',
components: { components: {
DataMappingDialog,
ProjectDetailsDialog,
Assets, Assets,
Playground, Playground,
Views, Views,
...@@ -39,6 +47,8 @@ ...@@ -39,6 +47,8 @@
} }
}, },
mounted() { mounted() {
const {projectID} = this.$route.params;
playWaiting(this.updateProject(projectID), this.$t('Preparing')).catch(e => {});
}, },
methods: { methods: {
getSize(id, side) { getSize(id, side) {
...@@ -51,7 +61,18 @@ ...@@ -51,7 +61,18 @@
}, },
clickMenu(menuItem){ clickMenu(menuItem){
console.log(menuItem); console.log(menuItem);
switch(menuItem){
case 'details':
this.$refs.projectDialogsDialog.show();
break;
case 'data-mapping':
this.$refs.dataMappingDialog.show();
break;
} }
},
...mapActions([
'updateProject'
])
} }
} }
</script> </script>
......
<template> <template>
<div class="tool-bar"> <div class="tool-bar">
<sample-menu :data="menu" @click-menu="clickMenu"/> <sample-menu :data="menu" @click-menu="clickMenu"/>
<div>
[{{project.name}}]
</div>
</div> </div>
</template> </template>
<script> <script>
import {mapState, mapActions} from 'vuex'
import SampleMenu from "../../components/SampleMenu"; import SampleMenu from "../../components/SampleMenu";
export default { export default {
...@@ -20,6 +24,11 @@ ...@@ -20,6 +24,11 @@
menu, menu,
} }
}, },
computed: {
...mapState([
'project'
])
},
methods: { methods: {
clickMenu(menuItem) { clickMenu(menuItem) {
this.$emit('click-menu', menuItem); this.$emit('click-menu', menuItem);
......
<template> <template>
<pane icon="el-icon-s-grid" :title="$t('panes.Views')"> <pane class="views" icon="el-icon-s-grid" :title="$t('panes.Views')">
<div class="container">
<div class="header-bar">
<el-link>导入</el-link>
<el-link>导出</el-link>
</div>
<el-scrollbar class="tree-scrollbar" wrap-class="wrap-x-hidden">
<el-tree
:data="views"
:props="defaultProps"
:expand-on-click-node="false"
highlight-current
empty-text=""
/>
</el-scrollbar>
</div>
</pane> </pane>
</template> </template>
<script> <script>
import {mapState, mapActions} from 'vuex'
import Pane from "../../components/Pane"; import Pane from "../../components/Pane";
export default { export default {
name: "Views", name: "Views",
components: {Pane} components: {Pane},
data() {
return {
defaultProps: {
children: 'children',
label: 'name'
},
}
},
computed: {
...mapState({
views: state => state.project.data.views
}),
}
} }
</script> </script>
......
<template>
<el-dialog :title="$t('Data mapping')" width="70%" :visible.sync="visible" @open="onOpen"
:append-to-body="true">
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="visible=false">{{$t('Cancel')}}</el-button>
<el-button size="mini" type="primary" @click="onConfirm">{{$t('Save')}}</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: "DataMappingDialog",
data() {
return {
visible: false,
}
},
methods: {
show(){
this.visible = true;
},
onConfirm(){
},
onOpen(){
},
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
<template>
<el-dialog :title="$t('Project details')" width="70%" :visible.sync="visible" @open="onOpen"
:append-to-body="true">
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="visible=false">{{$t('Cancel')}}</el-button>
<el-button size="mini" type="primary" @click="onConfirm">{{$t('Save')}}</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: "ProjectDetailsDialog",
data() {
return {
visible: false,
}
},
methods: {
show(){
this.visible = true;
},
onConfirm(){
},
onOpen(){
},
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
this.editProject(projectID); this.editProject(projectID);
}, },
editProject(projectID) { editProject(projectID) {
this.$router.push({name: 'editor', projectID}); this.$router.push({name: 'editor', params: {projectID}});
}, },
deleteAlert(project) { deleteAlert(project) {
return this.$confirm(this.$t('This action will permanently delete project', {projectName: project.name}), this.$t('Alert'), { return this.$confirm(this.$t('This action will permanently delete project', {projectName: project.name}), this.$t('Alert'), {
......
<template> <template>
<el-dialog :title="$t('Create project')" width="70%" :visible.sync="createDialogVisible" @open="onOpen" <el-dialog :title="$t('Create project')" width="70%" :visible.sync="visible" @open="onOpen"
:append-to-body="true"> :append-to-body="true">
<el-form ref="form" :model="project" :rules="rules" size="mini" label-position="right" label-width="110px" @submit.native.prevent> <el-form ref="form" :model="project" :rules="rules" size="mini" label-position="right" label-width="110px" @submit.native.prevent>
<el-form-item :label="$t('Project name')" prop="name"> <el-form-item :label="$t('Project name')" prop="name">
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</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="createDialogVisible=false">{{$t('Cancel')}}</el-button> <el-button size="mini" @click="visible=false">{{$t('Cancel')}}</el-button>
<el-button size="mini" type="primary" @click="doCreateProject">{{$t('Create')}}</el-button> <el-button size="mini" type="primary" @click="doCreateProject">{{$t('Create')}}</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
name: "CreateProjectDialog", name: "CreateProjectDialog",
data() { data() {
return { return {
createDialogVisible: false, visible: false,
project: { project: {
name: '' name: ''
}, },
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
watch: {}, watch: {},
methods: { methods: {
async show() { async show() {
this.createDialogVisible = true; this.visible = true;
}, },
doCreateProject() { doCreateProject() {
this.$refs.form.validate(async (valid) => { this.$refs.form.validate(async (valid) => {
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
try { try {
const project = await playWaiting(this.createProject(this.project), this.$t('Creating project')); const project = await playWaiting(this.createProject(this.project), this.$t('Creating project'));
this.createDialogVisible = false; this.visible = false;
this.$message({ this.$message({
message: this.$t('Create project success'), message: this.$t('Create project success'),
type: 'success' type: 'success'
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</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="createDialogVisible=false">{{$t('Cancel')}}</el-button> <el-button size="mini" @click="visible=false">{{$t('Cancel')}}</el-button>
<el-button size="mini" type="primary" @click="doCreateProject">{{$t('Create')}}</el-button> <el-button size="mini" type="primary" @click="doCreateProject">{{$t('Create')}}</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
name: "DuplicateProjectDialog", name: "DuplicateProjectDialog",
data() { data() {
return { return {
createDialogVisible: false, visible: false,
project: { project: {
name: '' name: ''
}, },
......
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