Commit 13404bc7 authored by rockyl's avatar rockyl

素材面板拆分成左右,并加入属性子面板

parent 058d0999
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2019-09-23. * Created by rockyl on 2019-09-23.
*/ */
const data1 = { const data = {
"views": [ "views": [
{ {
"name": "view1", "name": "view1",
...@@ -71,7 +71,7 @@ const data1 = { ...@@ -71,7 +71,7 @@ const data1 = {
} }
] ]
}; };
const data = { const data1 = {
"views": [ "views": [
], ],
"assets": [ "assets": [
......
@import "var"; @import "var";
.assets { .assets {
.container { .wrapper {
display: flex; display: flex;
flex: 1; flex: 1;
flex-direction: column; flex-direction: column;
...@@ -19,6 +19,39 @@ ...@@ -19,6 +19,39 @@
} }
} }
.container{
display: flex;
flex: 1;
}
.properties{
width: 30%;
padding: 3px;
font-size: 12px;
line-height: 14px;
color: $--color-text-primary;
border-right: 1px solid $--border-color-base;
.item{
border-bottom: 1px solid $--border-color-base;
}
p{
word-break: break-all;
margin: 0;
}
.name{
font-size: 16px;
line-height: 22px;
width: 100%;
}
.ext{
color: $--color-text-regular;
}
}
.file-list { .file-list {
display: flex; display: flex;
flex: 1; flex: 1;
...@@ -104,7 +137,7 @@ ...@@ -104,7 +137,7 @@
.file-uploader { .file-uploader {
width: 60px; width: 60px;
height: 60px; height: 60px;
margin: 5px 5px 5px; margin: 4px;
border: 1px dashed $--color-text-secondary; border: 1px dashed $--color-text-secondary;
border-radius: 6px; border-radius: 6px;
cursor: pointer; cursor: pointer;
......
...@@ -20,5 +20,5 @@ html, body, #app { ...@@ -20,5 +20,5 @@ html, body, #app {
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: rgba(0,0,0,0.7); background-color: rgba(0,0,0,0.7);
z-index: 2; z-index: 2000;
} }
<template> <template>
<pane class="assets" icon="el-icon-s-shop" :title="$t('panes.Assets')"> <pane class="assets" icon="el-icon-s-shop" :title="$t('panes.Assets')">
<div class="container"> <div class="wrapper">
<!--<div class="header-bar"> <!--<div class="header-bar">
<el-link>{{$t('Upload')}}</el-link> <el-link>{{$t('Upload')}}</el-link>
</div>--> </div>-->
<el-scrollbar class="assets-scrollbar" wrap-class="wrap-x-hidden" view-class="scrollbar-view"> <div class="container">
<div class="properties">
<template v-if="currentItem">
<div class="item">
<p class="name">{{currentItem.name}}</p>
<p class="ext">{{currentItem.ext}}</p>
</div>
<div class="item">
<p v-for="(field, index) in showFields" :key="index">
<span>{{field}}</span>:
<span>{{currentItem[field]}}</span>
</p>
</div>
</template>
</div>
<el-scrollbar class="assets-scrollbar" wrap-class="wrap-x-hidden"
view-class="scrollbar-view">
<div class="file-list"> <div class="file-list">
<el-upload <el-upload
class="file-uploader" class="file-uploader"
...@@ -17,10 +34,12 @@ ...@@ -17,10 +34,12 @@
> >
<i class="el-icon-plus file-uploader-icon"></i> <i class="el-icon-plus file-uploader-icon"></i>
</el-upload> </el-upload>
<file-item v-for="(file, index) in assets" :data="file" :key="index" @show-file-details="showFileDetails"/> <file-item v-for="(asset, index) in assets" :data="asset" :key="index" @show-file-details="showFileDetails"
@click="onItemClick(asset)"/>
</div> </div>
</el-scrollbar> </el-scrollbar>
</div> </div>
</div>
<assets-show ref="assetsShow"/> <assets-show ref="assetsShow"/>
</pane> </pane>
</template> </template>
...@@ -31,40 +50,47 @@ ...@@ -31,40 +50,47 @@
import FileItem from "./Assets/FileItem"; import FileItem from "./Assets/FileItem";
import AssetsShow from "./Assets/AssetsShow"; import AssetsShow from "./Assets/AssetsShow";
import {UPLOAD_FILE_URL} from "../../config"; import {UPLOAD_FILE_URL} from "../../config";
import SplitPanes from 'splitpanes'
export default { export default {
name: "Assets", name: "Assets",
components: {AssetsShow, FileItem, Pane}, components: {AssetsShow, FileItem, Pane, SplitPanes},
data() { data() {
return {} return {
showFields: ['url', 'uuid'],
currentItem: null,
}
}, },
computed: { computed: {
uploadFileUrl(){ uploadFileUrl() {
return UPLOAD_FILE_URL; return UPLOAD_FILE_URL;
}, },
...mapState({ ...mapState({
assets: state => state.project.data.assets assets: state => state.project.data.assets
}), }),
}, },
mounted(){ mounted() {
this.currentItem = null;
}, },
methods: { methods: {
showFileDetails(file){ showFileDetails(file) {
this.$refs.assetsShow.show(file); this.$refs.assetsShow.show(file);
}, },
uploadFileSuccess(response, file){ onItemClick(asset) {
if(response.success){ this.currentItem = asset;
},
uploadFileSuccess(response, file) {
if (response.success) {
//console.log('upload success', response, file); //console.log('upload success', response, file);
this.addAsset({ this.addAsset({
url: response.url, url: response.url,
file, file,
}) })
}else{ } else {
this.uploadFileError(); this.uploadFileError();
} }
}, },
uploadFileError(){ uploadFileError() {
console.log('upload error') console.log('upload error')
}, },
...mapMutations([ ...mapMutations([
......
...@@ -12,13 +12,9 @@ ...@@ -12,13 +12,9 @@
<div class="wrapper"> <div class="wrapper">
<el-button class="close-button" size="mini" circle icon="el-icon-close" @click="hide"></el-button> <el-button class="close-button" size="mini" circle icon="el-icon-close" @click="hide"></el-button>
<div class="name-bar"> <div class="name-bar">
<el-input size="mini" class="item" v-model="file.name" readonly> <el-input v-for="(field, index) in showFields" :key="index" size="mini" class="item" v-model="file[field]" readonly>
<template slot="prepend"><span class="field">name</span></template> <template slot="prepend"><span class="field">{{field}}</span></template>
<el-button slot="append" icon="el-icon-document-copy" @click="copyValue('name')"></el-button> <el-button slot="append" icon="el-icon-document-copy" @click="copyValue(field)"></el-button>
</el-input>
<el-input size="mini" class="item" v-model="file.url" readonly>
<template slot="prepend"><span class="field">url</span></template>
<el-button slot="append" icon="el-icon-document-copy" @click="copyValue('url')"></el-button>
</el-input> </el-input>
</div> </div>
<el-image class="big-image" :src="imageUrl" fit="contain" @load="onImageLoaded"/> <el-image class="big-image" :src="imageUrl" fit="contain" @load="onImageLoaded"/>
...@@ -45,6 +41,7 @@ ...@@ -45,6 +41,7 @@
visible: false, visible: false,
file: null, file: null,
size: '', size: '',
showFields: ['name', 'url', 'uuid'],
} }
}, },
watch: { watch: {
......
<template> <template>
<div class="file-item"> <div class="file-item" @click="$emit('click', $event)">
<div class="icon"> <div class="icon">
<i v-if="!showThumbnail" draggable="true" class="file-icon" :class="fileIcon"></i> <i v-if="!showThumbnail" draggable="true" class="file-icon" :class="fileIcon"></i>
<img @dragstart="assetDragStart(data)" v-if="showThumbnail" draggable="true" class="thumbnail" :src="thumbnailUrl" alt="thumb" @dblclick="onDbclick()"> <img @dragstart="assetDragStart(data)" v-if="showThumbnail" draggable="true" class="thumbnail" :src="thumbnailUrl" alt="thumb" @dblclick="onDbclick()">
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
}, },
computed: { computed: {
fileIcon() { fileIcon() {
return 'icon-' + fileTypeIcon[this.data.ext]; let icon = fileTypeIcon[this.data.ext];
return 'icon-' + (icon ? fileTypeIcon[this.data.ext] : fileTypeIcon['']);
}, },
showThumbnail() { showThumbnail() {
return fileTypeIcon[this.data.ext] === 't'; return fileTypeIcon[this.data.ext] === 't';
......
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