Skip to content

Commit 71d6ae3

Browse files
authored
Merge pull request #8 from TatsukiMengChen/dev
v1.1.0合并
2 parents 1034d88 + be1f3d0 commit 71d6ae3

12 files changed

+223
-156
lines changed

NOTICE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
LuaMaker
2-
Copyright 2023 Mimeng Studio
2+
Copyright 2023-2024 Mimeng Studio
33

44
This product is mainly built by
55

66
boxy (https://gitee.com/cocotais/boxy)
7-
Copyright Coconut Studio. All Rights Reserved.
7+
Copyright Cocotais. All Rights Reserved.
88

99
The packages and their licenses used in the development process are listed below,
1010
please use the search function of the text editor to retrieve the relevant license information by yourself.

getLICENSE.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//该脚本不可用
2+
/*
3+
const { exec } = require('child_process');
4+
const fs = require('fs');
5+
6+
// 执行yarn list命令并获取依赖信息
7+
exec('yarn list --json', (error, stdout) => {
8+
if (error) {
9+
console.error(`执行错误: ${error}`);
10+
return;
11+
}
12+
13+
const data = Array(JSON.stringify(stdout))
14+
//console.log(data)
15+
let csvContent = '"module name","license","repository"\n';
16+
17+
// 确保data是一个数组
18+
if (Array.isArray(data)) {
19+
data.forEach((dep) => {
20+
const moduleName = dep.name;
21+
const license = dep.license || 'UNKNOWN';
22+
const repository = dep.resolved || 'UNKNOWN';
23+
csvContent += `"${moduleName}","${license}","${repository}"\n`;
24+
});
25+
} else {
26+
console.error('数据格式错误,无法解析依赖信息。');
27+
return;
28+
}
29+
30+
// 读取NOTICE文件并删除从第13行开始的所有内容
31+
fs.readFile('NOTICE', 'utf8', (err, data) => {
32+
if (err) {
33+
console.error(err);
34+
return;
35+
}
36+
const lines = data.split('\n');
37+
const header = lines.slice(0, 11).join('\n') + '\n'; // 保留前12行
38+
39+
// 更新NOTICE文件内容
40+
const newData = header + csvContent;
41+
fs.writeFile('NOTICE', newData, (err) => {
42+
if (err) throw err;
43+
console.log('依赖信息已更新到 NOTICE 文件中。');
44+
});
45+
});
46+
});
47+
*/

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" href="./src/assets/mimeng.png" />
6-
<meta name="description" content="LuaMaker 是一款基于 Boxy 的图形化代码编辑器" />
6+
<meta name="description" content="LuaMaker 是一款基于 Boxy 的可视化脚本编辑器" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
88
<meta name="theme-color" content="#4062f6" />
99
<meta name="apple-mobile-web-app-capable" content="yes" />

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "luamaker",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"private": true,
55
"scripts": {
66
"dev": "vite --port 1234",

src/App.vue

+118-106
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,124 @@
11
<template>
2-
<a-layout>
3-
<a-layout-content>
4-
<Workspace />
5-
<Search />
6-
<Toolbox />
7-
<Zoombox />
8-
</a-layout-content>
9-
<a-layout-sider ref="layoutSider" :resize-directions="['left']" @moving="handleMoving" @moving-end="handleMoving">
10-
<Codespace />
11-
</a-layout-sider>
12-
</a-layout>
13-
<Navigator />
14-
<Trashcan />
15-
<Screenshot />
16-
<Dialog />
17-
</template>
18-
19-
<script setup>
20-
import './assets/categories'
21-
import './blocks/boxy'
22-
import './blocks/patch'
23-
import './theme/codemao.theme'
24-
import './theme/codemao.renderer'
25-
import './generators/lua'
26-
27-
import { Message, Modal, Notification } from '@arco-design/web-vue'
28-
import Blockly from 'blockly'
29-
import cookie from 'cookiejs'
30-
import { onMounted, ref, watch } from 'vue'
31-
32-
import tools from './assets/tools'
33-
import { useStore } from './store/store'
34-
import Codespace from './components/Codespace.vue'
35-
import Dialog from './components/Dialog.vue'
36-
import Navigator from './components/Navigator.vue'
37-
import Screenshot from './components/Screenshot.vue'
38-
import Search from './components/Search.vue'
39-
import Toolbox from './components/Toolbox.vue'
40-
import Trashcan from './components/Trashcan.vue'
41-
import Workspace from './components/Workspace.vue'
42-
import Zoombox from './components/Zoombox.vue'
43-
44-
let usedLayoutSider = void 0
45-
const layoutSider = ref()
46-
const store = useStore()
47-
48-
function handleMoving() {
49-
for (let i = 0; i < 5; i++) {
50-
setTimeout(() => {
51-
Blockly.svgResize(store.workspaceSvg)
52-
}, 100 * i)
2+
<a-layout>
3+
<a-layout-content>
4+
<Workspace />
5+
<Search />
6+
<Toolbox />
7+
<Zoombox />
8+
</a-layout-content>
9+
<a-layout-sider ref="layoutSider" :resize-directions="['left']" @moving="handleMoving" @moving-end="handleMoving">
10+
<Codespace />
11+
</a-layout-sider>
12+
</a-layout>
13+
<Navigator />
14+
<Trashcan />
15+
<Screenshot />
16+
<Dialog />
17+
</template>
18+
19+
<script setup>
20+
import './assets/categories'
21+
import './blocks/boxy'
22+
import './blocks/patch'
23+
import './theme/codemao.theme'
24+
import './theme/codemao.renderer'
25+
import './generators/lua'
26+
27+
import { Message, Modal, Notification } from '@arco-design/web-vue'
28+
import Blockly from 'blockly'
29+
import cookie from 'cookiejs'
30+
import { onMounted, ref, watch } from 'vue'
31+
32+
import tools from './assets/tools'
33+
import Codespace from './components/Codespace.vue'
34+
import Dialog from './components/Dialog.vue'
35+
import Navigator from './components/Navigator.vue'
36+
import Screenshot from './components/Screenshot.vue'
37+
import Search from './components/Search.vue'
38+
import Toolbox from './components/Toolbox.vue'
39+
import Trashcan from './components/Trashcan.vue'
40+
import Workspace from './components/Workspace.vue'
41+
import Zoombox from './components/Zoombox.vue'
42+
import { useStore } from './store/store'
43+
44+
let usedLayoutSider = void 0
45+
const layoutSider = ref()
46+
const store = useStore()
47+
48+
function handleMoving() {
49+
for (let i = 0; i < 5; i++) {
50+
setTimeout(() => {
51+
Blockly.svgResize(store.workspaceSvg)
52+
}, 100 * i)
53+
}
54+
}
55+
56+
function setLayoutSider(isOpen = false) {
57+
layoutSider.value.$el.style.display = isOpen ? 'block' : 'none'
58+
handleMoving()
59+
}
60+
61+
onMounted(() => {
62+
if (!localStorage.getItem('now')) {
63+
try {
64+
Blockly.serialization.workspaces.load(
65+
JSON.parse(localStorage.getItem('now')),
66+
store.workspaceSvg
67+
)
68+
} catch (e) {
69+
if (localStorage.getItem('now') != '{}') {
70+
localStorage.setItem(new Date().getTime(), localStorage.getItem('now'))
71+
Notification.error('加载本地缓存工程失败,数据已自动备份')
72+
}
5373
}
5474
}
55-
56-
function setLayoutSider(isOpen = false) {
57-
layoutSider.value.$el.style.display = isOpen ? 'block' : 'none'
58-
handleMoving()
75+
const tool = new tools()
76+
if (!tool.ifStorage) {
77+
Notification.error('当前环境不支持HTML5 web 存储(Storage)服务,项目的本地缓存功能将会受限')
5978
}
60-
61-
onMounted(() => {
62-
const tool = new tools()
63-
if (!tool.ifStorage) {
64-
Notification.error('当前环境不支持HTML5 web 存储(Storage)服务,项目的本地缓存功能将会受限')
79+
window.addEventListener('beforeunload', (e) => {
80+
if (
81+
JSON.stringify(Blockly.serialization.workspaces.save(store.workspaceSvg)) !=
82+
localStorage.getItem('now')
83+
) {
84+
const message = '离开页面后未保存的更改将丢失,确定继续?'
85+
e.returnValue = message
86+
return message
6587
}
66-
window.addEventListener('beforeunload', (e) => {
67-
if (
68-
JSON.stringify(Blockly.serialization.workspaces.save(store.workspaceSvg)) !=
69-
sessionStorage.setItem('now')
70-
) {
71-
const message = '离开页面后未保存的更改将丢失,确定继续?'
72-
e.returnValue = message
73-
return message
74-
}
75-
})
76-
watch(
77-
store.$state,
78-
(state) => {
79-
if (state.hasLayoutSider !== usedLayoutSider) {
80-
setLayoutSider(state.hasLayoutSider)
81-
usedLayoutSider = state.hasLayoutSider
82-
}
83-
},
84-
{ deep: true }
85-
)
86-
handleMoving()
87-
setLayoutSider()
8888
})
89-
</script>
90-
91-
<style>
92-
html,
93-
body,
94-
#app {
95-
width: 100%;
96-
height: 100%;
97-
margin: 0;
98-
padding: 0;
99-
100-
background: var(--color-bg-1);
101-
border: 0;
102-
}
103-
104-
::selection {
105-
background: #1ba2e333;
106-
}
107-
108-
body::-webkit-scrollbar {
109-
display: none;
110-
}
111-
</style>
112-
89+
watch(
90+
store.$state,
91+
(state) => {
92+
if (state.hasLayoutSider !== usedLayoutSider) {
93+
setLayoutSider(state.hasLayoutSider)
94+
usedLayoutSider = state.hasLayoutSider
95+
}
96+
},
97+
{ deep: true }
98+
)
99+
handleMoving()
100+
setLayoutSider()
101+
})
102+
</script>
103+
104+
<style>
105+
html,
106+
body,
107+
#app {
108+
width: 100%;
109+
height: 100%;
110+
margin: 0;
111+
padding: 0;
112+
113+
background: var(--color-bg-1);
114+
border: 0;
115+
}
116+
117+
::selection {
118+
background: #1ba2e333;
119+
}
120+
121+
body::-webkit-scrollbar {
122+
display: none;
123+
}
124+
</style>

src/blocks/boxy.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Blockly from 'blockly'
2+
23
import apis from '../assets/api.json'
34
import Events from '../assets/events.json'
45

@@ -531,7 +532,7 @@ Blockly.defineBlocksWithJsonArray([
531532
},
532533
{
533534
type: 'makefunction',
534-
message0: '触发器 %1 事件 %2 动作 %3',
535+
message0: '触发器 %1 事件 %2 执行 %3',
535536
args0: [
536537
{
537538
type: 'input_dummy'

src/components/Codespace.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@
1515
import { IconClose } from '@arco-iconbox/vue-boxy'
1616
import Blockly from 'blockly'
1717
import { luaGenerator } from 'blockly/lua'
18+
import LZString from 'lz-string'
1819
import { onMounted, ref } from 'vue'
1920
2021
import { useStore } from '../store/store'
2122
22-
const defaultContext = '未检测到积木块,尝试在编辑区拼几块积木吧'
23+
const defaultContext = '未检测到积木块,尝试在工作区拼几块积木吧'
2324
const code = ref(defaultContext)
2425
const store = useStore()
2526
2627
onMounted(() => {
2728
store.workspaceSvg.addChangeListener(() => {
2829
code.value = luaGenerator.workspaceToCode(store.workspaceSvg) || defaultContext
29-
sessionStorage.setItem(
30-
'now',
31-
JSON.stringify(Blockly.serialization.workspaces.save(store.workspaceSvg))
32-
)
3330
localStorage.setItem(
3431
'now',
3532
JSON.stringify(Blockly.serialization.workspaces.save(store.workspaceSvg))

src/components/Navigator.vue

+11-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ function handleIconClick() {
4343
}
4444
4545
function handleSaveClick() {
46+
if (store.workspaceSvg.getAllBlocks().length === 0) {
47+
Notification.warning('工作区空空如也,没有工程进行中哦,尝试拼几块积木吧!')
48+
return
49+
}
4650
try {
4751
const json = Blockly.serialization.workspaces.save(store.workspaceSvg)
4852
const text = LZString.compressToUTF16(JSON.stringify(json))
4953
const blob = new Blob([text], { type: 'text/plain;charset=utf-8' })
5054
const url = URL.createObjectURL(blob)
5155
const anchor = document.createElement('a')
5256
anchor.href = url
53-
anchor.download = localStorage.getItem('name')+'.luamaker'
57+
anchor.download = localStorage.getItem('name') + '.luamaker'
5458
anchor.click()
5559
} catch (err) {
5660
Notification.error('导出工程文件时发生错误:' + err)
@@ -60,14 +64,18 @@ function handleSaveClick() {
6064
}
6165
6266
function handleOutputClick() {
67+
if (store.workspaceSvg.getAllBlocks().length === 0) {
68+
Notification.warning('工作区空空如也,没有东西可以导出为Lua,尝试拼几块积木吧!')
69+
return
70+
}
6371
try {
6472
const json = Blockly.serialization.workspaces.save(store.workspaceSvg)
6573
const text = JSON.stringify(json)
6674
const blob = new Blob([text], { type: 'text/plain;charset=utf-8' })
6775
const url = URL.createObjectURL(blob)
6876
const anchor = document.createElement('a')
6977
anchor.href = url
70-
anchor.download = localStorage.getItem('name')+'.lua'
78+
anchor.download = localStorage.getItem('name') + '.lua'
7179
anchor.click()
7280
} catch (err) {
7381
Notification.error('导出Lua文件时发生错误:' + err)
@@ -90,6 +98,7 @@ function handleOpenClick() {
9098
const json = JSON.parse(LZString.decompressFromUTF16(this.result))
9199
//const json = JSON.parse(this.result)
92100
Blockly.serialization.workspaces.load(json, store.workspaceSvg)
101+
localStorage.setItem('now', JSON.stringify(json))
93102
})
94103
reader.readAsText(file)
95104
})

0 commit comments

Comments
 (0)