mirror of
https://github.com/potato47/ccc-devtools.git
synced 2024-12-26 11:49:11 +00:00
node draggable,switch
This commit is contained in:
parent
4e924d996b
commit
6beff39c3d
@ -1,11 +1,13 @@
|
|||||||
# ccc-devtools v1.0
|
# ccc-devtools v1.1.0
|
||||||
Cocos Creator 网页调试器,运行时查看、修改节点树,实时更新节点属性。
|
Cocos Creator 网页调试器,运行时查看、修改节点树,实时更新节点属性。
|
||||||
|
|
||||||
## 功能
|
## TODO
|
||||||
|
|
||||||
- [x] 拖拽布局
|
- [x] 拖拽布局
|
||||||
- [x] 节点搜索
|
- [x] 节点搜索
|
||||||
- [x] 实时刷新节点信息
|
- [x] 实时刷新节点信息
|
||||||
|
- [x] 拖动节点更改层级
|
||||||
|
- [x] 开关
|
||||||
- [ ] 自定义布局等配置
|
- [ ] 自定义布局等配置
|
||||||
- [ ] 组件信息
|
- [ ] 组件信息
|
||||||
|
|
||||||
|
56
index.html
56
index.html
@ -30,17 +30,17 @@
|
|||||||
</style>
|
</style>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div class="demo-split">
|
<div class="demo-split">
|
||||||
<Split v-model="splitLeft">
|
<Split v-model="splitLeft" v-if="isDevMode">
|
||||||
<div slot="left" class="demo-split-pane" id="game_panel" style="display:flex;justify-content:left;align-items:center;height: 100vh;">
|
<div slot="left" class="demo-split-pane" id="game_panel" style="display:flex;justify-content:left;align-items:center;height: 100vh;">
|
||||||
<div id="top" style="position: absolute;top:0;"></div>
|
<div id="top" style="position: absolute;top:0;"></div>
|
||||||
</div>
|
</div>
|
||||||
<div slot="right" class="demo-split-pane no-padding">
|
<div slot="right" class="demo-split-pane no-padding" v-if="isDevMode">
|
||||||
<Split v-model="splitRight" mode="vertical">
|
<Split v-model="splitRight" mode="vertical">
|
||||||
<div slot="top" class="demo-split-pane" style="padding-left: 5px;">
|
<div slot="top" class="demo-split-pane" style="padding-left: 5px;">
|
||||||
<el-input placeholder="搜索节点" v-model="filterText" size="mini" id="searchInput"></el-input>
|
<el-input placeholder="搜索节点" v-model="filterText" size="mini" id="searchInput"></el-input>
|
||||||
<el-tree :data="sceneTreeData" :props="nodeProps" :default-expanded-keys="defaultExpandedKeys" empty-text="加载场景..."
|
<el-tree :data="sceneTreeData" :draggable="true" :props="nodeProps" :default-expanded-keys="defaultExpandedKeys"
|
||||||
:node-key="'_id'" :expand-on-click-node="false" :filter-node-method="filterNode" ref="sceneTree" @node-click="handleNodeClick"
|
empty-text="加载场景..." :node-key="'_id'" :expand-on-click-node="false" :filter-node-method="filterNode" ref="sceneTree"
|
||||||
style="min-width: 250px;height: 100%;overflow-x:hidden;overflow-y:auto;">
|
@node-click="handleNodeClick" style="min-width: 250px;height: 100%;overflow-x:hidden;overflow-y:auto;">
|
||||||
<span class="custom-tree-node" slot-scope="{ node, data }">
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
||||||
<span v-bind:style="{color: data.activeInHierarchy?'#606266':'#C0C4CC'}">{{ node.label }}</span>
|
<span v-bind:style="{color: data.activeInHierarchy?'#606266':'#C0C4CC'}">{{ node.label }}</span>
|
||||||
</span>
|
</span>
|
||||||
@ -152,6 +152,14 @@
|
|||||||
</Split>
|
</Split>
|
||||||
</div>
|
</div>
|
||||||
</Split>
|
</Split>
|
||||||
|
<el-tooltip :content="'ccc-devtools@Next v1.1.0 https://github.com/potato47/ccc-devtools'" placement="top" style="position: absolute;bottom:10px;left:10px;width: 100;background:#333333;">
|
||||||
|
<el-switch
|
||||||
|
v-model="isDevMode"
|
||||||
|
@change="handleChangeMode"
|
||||||
|
active-color="#13ce66"
|
||||||
|
inactive-color="gray">
|
||||||
|
</el-switch>
|
||||||
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -167,6 +175,7 @@
|
|||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
|
isDevMode: false,
|
||||||
filterText: '',
|
filterText: '',
|
||||||
splitLeft: 0.7,
|
splitLeft: 0.7,
|
||||||
splitRight: 0.5,
|
splitRight: 0.5,
|
||||||
@ -178,6 +187,7 @@
|
|||||||
},
|
},
|
||||||
node: null,
|
node: null,
|
||||||
nodeColor: '#ffffff',
|
nodeColor: '#ffffff',
|
||||||
|
intervalId: -1
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -205,23 +215,16 @@
|
|||||||
filterNode(value, node) {
|
filterNode(value, node) {
|
||||||
if (!value) return true;
|
if (!value) return true;
|
||||||
return node.name.toLowerCase().indexOf(value.toLowerCase()) !== -1;
|
return node.name.toLowerCase().indexOf(value.toLowerCase()) !== -1;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
watch: {
|
openDevMode() {
|
||||||
filterText(val) {
|
let initWin = () => {
|
||||||
this.$refs.sceneTree.filter(val);
|
if (window.cc) {
|
||||||
}
|
|
||||||
},
|
|
||||||
created: function () {
|
|
||||||
let top = document.getElementById('top')
|
let top = document.getElementById('top')
|
||||||
// top.insertBefore(document.getElementsByClassName('toolbar')[0], top.firstChild);
|
// top.insertBefore(document.getElementsByClassName('toolbar')[0], top.firstChild);
|
||||||
top.appendChild(document.getElementsByClassName('toolbar')[0]);
|
top.appendChild(document.getElementsByClassName('toolbar')[0]);
|
||||||
document.getElementById('game_panel').appendChild(document.getElementById('content'));
|
document.getElementById('game_panel').appendChild(document.getElementById('content'));
|
||||||
// let content = document.getElementById('content');
|
// let content = document.getElementById('content');
|
||||||
// content.insertBefore(document.getElementById('searchInput'), content.firstChild);
|
// content.insertBefore(document.getElementById('searchInput'), content.firstChild);
|
||||||
|
|
||||||
intervalId = setInterval(() => {
|
|
||||||
if (window.cc) {
|
|
||||||
let scene = cc.director.getScene();
|
let scene = cc.director.getScene();
|
||||||
if (scene) {
|
if (scene) {
|
||||||
this.$data.sceneTreeData = scene.children;
|
this.$data.sceneTreeData = scene.children;
|
||||||
@ -235,11 +238,30 @@
|
|||||||
this.$data.sceneTreeData = [];
|
this.$data.sceneTreeData = [];
|
||||||
this.$data.node = null;
|
this.$data.node = null;
|
||||||
});
|
});
|
||||||
clearInterval(intervalId);
|
clearInterval(this.$data.intervalId);
|
||||||
} else {
|
} else {
|
||||||
console.log('cc is not init');
|
console.log('cc is not init');
|
||||||
}
|
}
|
||||||
}, 1000);
|
}
|
||||||
|
this.$data.intervalId = setInterval(initWin, 500);
|
||||||
|
setTimeout(initWin, 0);
|
||||||
|
},
|
||||||
|
closeDevMode() {
|
||||||
|
clearInterval(this.$data.intervalId);
|
||||||
|
document.body.appendChild(document.getElementsByClassName('toolbar')[0]);
|
||||||
|
document.body.appendChild(document.getElementById('content'));
|
||||||
|
},
|
||||||
|
handleChangeMode(data) {
|
||||||
|
data?this.openDevMode():this.closeDevMode();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
filterText(val) {
|
||||||
|
this.$refs.sceneTree.filter(val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created: function() {
|
||||||
|
document.body.insertBefore(document.getElementById('app'), document.body.firstChild);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
BIN
screenshots/t4.gif
Normal file
BIN
screenshots/t4.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 390 KiB |
Loading…
Reference in New Issue
Block a user