[add] Vue版本
This commit is contained in:
parent
12e3282760
commit
0fb4ba3740
10073
lib/vue.js
Normal file
10073
lib/vue.js
Normal file
File diff suppressed because it is too large
Load Diff
108
main.js
108
main.js
@ -21,63 +21,63 @@ const Indices = UuidTemplate.map((x, i) => x === '-' ? NaN : i).filter(isFinite)
|
||||
|
||||
let HexMap = {}
|
||||
{
|
||||
for (let i = 0; i < HexChars.length; i++) {
|
||||
let char = HexChars[i]
|
||||
HexMap[char] = i
|
||||
}
|
||||
for (let i = 0; i < HexChars.length; i++) {
|
||||
let char = HexChars[i]
|
||||
HexMap[char] = i
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
load() {
|
||||
this.init();
|
||||
},
|
||||
unload() {
|
||||
// Editor.log("卸載執行");
|
||||
},
|
||||
/** 初始化 */
|
||||
init() {
|
||||
// this.createDirectory();
|
||||
},
|
||||
/** 創建Spine節點 */
|
||||
uuidconvert(...args) {
|
||||
let self = this;
|
||||
try {
|
||||
let needconvertuuid = args[0];
|
||||
let uuid;
|
||||
if (needconvertuuid.indexOf("-") === -1) {
|
||||
// let convertuuid = this.decodeUuid(needconvertuuid);
|
||||
let convertuuid = EditorAPI.decompressUuid(needconvertuuid);
|
||||
Editor.log('convertuuid', convertuuid);
|
||||
uuid = convertuuid;
|
||||
} else {
|
||||
// let convertuuid = this.compressUuid(needconvertuuid);
|
||||
let convertuuid = EditorAPI.compressUuid(needconvertuuid);
|
||||
Editor.log('convertuuid', convertuuid);
|
||||
uuid = needconvertuuid;
|
||||
}
|
||||
Editor.Ipc.sendToAll('assets:hint', uuid);
|
||||
Editor.log('path: ', Editor.assetdb.uuidToUrl(uuid));
|
||||
} catch (error) {
|
||||
Editor.log(`uuidconvert error: ${error}`);
|
||||
}
|
||||
},
|
||||
load() {
|
||||
this.init();
|
||||
},
|
||||
unload() {
|
||||
// Editor.log("卸載執行");
|
||||
},
|
||||
/** 初始化 */
|
||||
init() {
|
||||
// this.createDirectory();
|
||||
},
|
||||
/** 創建Spine節點 */
|
||||
uuidconvert(...args) {
|
||||
let self = this;
|
||||
try {
|
||||
let needconvertuuid = args[0];
|
||||
let uuid;
|
||||
if (needconvertuuid.indexOf("-") === -1) {
|
||||
// let convertuuid = this.decodeUuid(needconvertuuid);
|
||||
let convertuuid = EditorAPI.decompressUuid(needconvertuuid);
|
||||
Editor.log('convertuuid', convertuuid);
|
||||
uuid = convertuuid;
|
||||
} else {
|
||||
// let convertuuid = this.compressUuid(needconvertuuid);
|
||||
let convertuuid = EditorAPI.compressUuid(needconvertuuid);
|
||||
Editor.log('convertuuid', convertuuid);
|
||||
uuid = needconvertuuid;
|
||||
}
|
||||
Editor.Ipc.sendToAll('assets:hint', uuid);
|
||||
Editor.log('path: ', Editor.assetdb.uuidToUrl(uuid));
|
||||
} catch (error) {
|
||||
Editor.log(`uuidconvert error: ${error}`);
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
/** 打開面板 */
|
||||
"open-panel"() {
|
||||
Editor.Panel.open("uuidconvert");
|
||||
},
|
||||
/** 保存按鈕點擊 */
|
||||
"run-click"(event, ...args) {
|
||||
this.uuidconvert(...args);
|
||||
},
|
||||
// /** 面板加載完成 */
|
||||
// "panel-load-finish"(evnet, ...args) {
|
||||
// Editor.Scene.callSceneScript("uuidconvert", "get-default-info", { args: args }, function (err, response) {
|
||||
// // Editor.log("callSceneScript: " + response);
|
||||
// Editor.Ipc.sendToPanel("uuidconvert", "setDefault", response);
|
||||
// });
|
||||
// },
|
||||
},
|
||||
messages: {
|
||||
/** 打開面板 */
|
||||
"open-panel"() {
|
||||
Editor.Panel.open("uuidconvert");
|
||||
},
|
||||
/** 保存按鈕點擊 */
|
||||
"run-click"(event, ...args) {
|
||||
this.uuidconvert(...args);
|
||||
},
|
||||
// /** 面板加載完成 */
|
||||
// "panel-load-finish"(evnet, ...args) {
|
||||
// Editor.Scene.callSceneScript("uuidconvert", "get-default-info", { args: args }, function (err, response) {
|
||||
// // Editor.log("callSceneScript: " + response);
|
||||
// Editor.Ipc.sendToPanel("uuidconvert", "setDefault", response);
|
||||
// });
|
||||
// },
|
||||
},
|
||||
|
||||
}
|
38
package.json
38
package.json
@ -1,21 +1,21 @@
|
||||
{
|
||||
"name": "uuidconvert",
|
||||
"version": "0.0.1",
|
||||
"description": "Sample-Package",
|
||||
"author": "Sample",
|
||||
"main": "main.js",
|
||||
"scene-script": "scene-obtain.js",
|
||||
"engineSupport": true,
|
||||
"main-menu": {
|
||||
"扩展/Uuid Convert": {
|
||||
"message": "uuidconvert:open-panel"
|
||||
}
|
||||
},
|
||||
"panel": {
|
||||
"main": "panel/index.js",
|
||||
"type": "dockable",
|
||||
"title": "Uuid Convert",
|
||||
"width": 400,
|
||||
"height": 350
|
||||
}
|
||||
"name": "uuidconvert",
|
||||
"version": "0.0.1",
|
||||
"description": "Sample-Package",
|
||||
"author": "Sample",
|
||||
"main": "main.js",
|
||||
"scene-script": "scene-obtain.js",
|
||||
"engineSupport": true,
|
||||
"main-menu": {
|
||||
"扩展/Uuid Convert": {
|
||||
"message": "uuidconvert:open-panel"
|
||||
}
|
||||
},
|
||||
"panel": {
|
||||
"main": "panel/index.js",
|
||||
"type": "dockable",
|
||||
"title": "Uuid Convert",
|
||||
"width": 400,
|
||||
"height": 350
|
||||
}
|
||||
}
|
@ -1,57 +1,45 @@
|
||||
const PACKAGE_NAME = "uuidconvert";
|
||||
const fs = require("fs");
|
||||
|
||||
Editor.Panel.extend({
|
||||
style: `
|
||||
:host { margin: 5px; }
|
||||
h2 { color: #f90; }
|
||||
.bottom {
|
||||
height: 30px;
|
||||
style: fs.readFileSync(Editor.url(`packages://${PACKAGE_NAME}/static/style/default/index.css`), 'utf-8')
|
||||
.concat(fs.readFileSync(Editor.url(`packages://${PACKAGE_NAME}/static/style/default/bootstrap.min.css`), 'utf-8')),
|
||||
|
||||
template: fs.readFileSync(
|
||||
Editor.url(`packages://${PACKAGE_NAME}/static/template/default/index.html`), 'utf-8'),
|
||||
|
||||
$: {
|
||||
app: '#app',
|
||||
},
|
||||
|
||||
ready() {
|
||||
this.app = new Vue({
|
||||
el: this.$app,
|
||||
created: function () {
|
||||
|
||||
},
|
||||
|
||||
components: {
|
||||
"counter": Editor.require(`packages://${PACKAGE_NAME}/static/template/vue/counter.js`)
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
},
|
||||
|
||||
messages: {
|
||||
}
|
||||
`,
|
||||
|
||||
template: `
|
||||
<h2 style="text-align:center">Uuid Convert</h2>
|
||||
<hr />
|
||||
<div>
|
||||
1. 填入要轉換的UUID<br>
|
||||
</div>
|
||||
<hr />
|
||||
<div>
|
||||
要轉換的UUID
|
||||
<ui-input placeholder="UUID" id="uuid"></ui-input>
|
||||
</div>
|
||||
<hr />
|
||||
<div style="text-align:right">
|
||||
<ui-button id="run" class="blue">執行</ui-button>
|
||||
</div>
|
||||
`,
|
||||
|
||||
$: {
|
||||
/** uuid */
|
||||
uuid: "#uuid",
|
||||
/** 生成按鈕 */
|
||||
run: "#run",
|
||||
},
|
||||
|
||||
ready() {
|
||||
// Editor.Ipc.sendToMain("uuidconvert:panel-load-finish");
|
||||
this.onClickRun();
|
||||
|
||||
},
|
||||
/** 保存按鈕點擊事件 */
|
||||
onClickRun() {
|
||||
this.$run.addEventListener("confirm", () => {
|
||||
if (!this.$uuid._value) {
|
||||
Editor.error("請輸入要轉換的UUID");
|
||||
return;
|
||||
}
|
||||
Editor.Ipc.sendToMain("uuidconvert:run-click", this.$uuid._value);
|
||||
});
|
||||
},
|
||||
messages: {
|
||||
// "setDefault": function (event, ...agrs) {
|
||||
// if (event.reply) {
|
||||
// //if no error, the first argument should be null
|
||||
// event.reply(null, "Fine, thank you!");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
});
|
7
static/style/default/bootstrap.min.css
vendored
Normal file
7
static/style/default/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
8
static/style/default/index.css
Normal file
8
static/style/default/index.css
Normal file
@ -0,0 +1,8 @@
|
||||
#text {
|
||||
color: var(--color-normal-contrast-weakest);
|
||||
margin: auto;
|
||||
width: 180px;
|
||||
}
|
||||
.counter {
|
||||
text-align: center;
|
||||
}
|
6
static/template/default/index.html
Normal file
6
static/template/default/index.html
Normal file
@ -0,0 +1,6 @@
|
||||
<div>
|
||||
<link href="style/default/bootstrap.min.css" rel="stylesheet">
|
||||
<div id="app">
|
||||
<counter></counter>
|
||||
</div>
|
||||
</div>
|
18
static/template/vue/counter.html
Normal file
18
static/template/vue/counter.html
Normal file
@ -0,0 +1,18 @@
|
||||
<div class="counter">
|
||||
<h1 style="text-align:center">Uuid Convert</h1>
|
||||
<hr />
|
||||
<div>
|
||||
<h2 style="text-align:left">1. 填入要轉換的UUID</h2>
|
||||
</div>
|
||||
<hr />
|
||||
<div>
|
||||
<h1 style="text-align:left">要轉換的UUID</h1>
|
||||
<div class="input-group input-group-lg">
|
||||
<input id="uuid" v-model="uuid" type="text" class="form-control" placeholder="UUID">
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div style="text-align:right">
|
||||
<button id="run" @click="run()" type="button" class="btn btn-primary btn-lg btn-block">執行</button>
|
||||
</div>
|
||||
</div>
|
36
static/template/vue/counter.js
Normal file
36
static/template/vue/counter.js
Normal file
@ -0,0 +1,36 @@
|
||||
const PACKAGE_NAME = "uuidconvert";
|
||||
const fs = require("fs");
|
||||
|
||||
module.exports = {
|
||||
name: "counter",
|
||||
|
||||
template: fs.readFileSync(Editor.url(`packages://${PACKAGE_NAME}/static/template/vue/counter.html`), 'utf-8'),
|
||||
|
||||
created: function () {
|
||||
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
uuid: ""
|
||||
}
|
||||
},
|
||||
|
||||
props: {
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
run() {
|
||||
if (!this.uuid) {
|
||||
Editor.error("請輸入要轉換的UUID");
|
||||
return;
|
||||
}
|
||||
Editor.Ipc.sendToMain("uuidconvert:run-click", this.uuid);
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user