Skip to content

Commit

Permalink
feat : add prefab mock file
Browse files Browse the repository at this point in the history
  • Loading branch information
pojol committed Jun 21, 2023
1 parent 13ca709 commit e310ecb
Show file tree
Hide file tree
Showing 10 changed files with 2,030 additions and 1,729 deletions.
71 changes: 71 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# v0.3.5 (pre
Major adjustments are nearing completion. Version 0.3 will only fix bugs next.
* Feature
- Added a queue delay configuration to control the scheduling frequency of the robot
- Optimized the CSS implementation of nodes in the sideplane
- Added HTTP query params as input
* Fix
- The code input box has disordered input logic after switching input methods
- Clicking inputnumber in bots will lose focus
- When zooming and resizing the window, the editor window is not enlarged or reduced proportionally

# v0.3.1 (pre
* Feature
- Added a button to erase the behavior tree
- The drawing of the graph now depends entirely on the data in model/tree
* Fix
- Clicking too fast caused the current node to draw incorrectly
- Some jumps in the debugging window are fixed
- When zooming and resizing the window, the editor window is not enlarged or reduced proportionally
# v0.3.0 (pre

* Feature
- Rewrote the entire editor using the umi framework and ts (type safe, supports dark mode switching
- Replaced components with functions, wrote code using hooks + redux (stateless mode (optimized loading time and drawing efficiency
- Added a new bot loading method that can load a bot by accessing the URL (easier to spread
- Introduced the SQLite in-memory database (easy to try, can be deployed locally quickly
* Fix
- Fixed the loss of tail node information
- Fixed the problem that batches could not exit accurately during pressure testing

# v0.2.5
* Feature
- Rewrote the sidebar to provide a better filtering method
- Prefab is displayed separately as a page and provides search and editing functions
- Optimized connection points (shrink when there is no mouse movein)
- Added time sorting to the report page

## v0.2.1
* Feature
- Added new parallel nodes
- Deleted the original assert node type
- Added a runtime err column to output runtime error information
- Refactored the runtime logic of bots
- Introduced the logic to display thread information in the response column (parallel nodes will create new threads)
- Added a small animation when running to the node (optimization prompt

## v0.1.17
* Feature
* Fix
- Fixed logic errors in asynchronous loading of behavior trees

## v0.1.16
* Feature
- Provides fmt function for lua code
- Leave enough space for prefab and move change to overlap with meta window
- Add step shortcut [F10]
* Fix
- Error deleting configuration file failed
- Root node position correction
- Fix health check not performed after initializing server address

## v0.1.15
* Feature
- Removed the debug button in the edit interface and automatically created when clicking step
- Added a delay for step on the last node (to prevent continuous clicking
- Added a reset button to prevent the user from not wanting to execute down
- Removed the utils in the script module (changed to an independent uuid and random interface displayed at the first level directory for easy reference
- Added node "prefab" function (now users can define and reuse their own script nodes in the config panel
- Added connection status prompt
* Fix
- step api does not return correct error information
File renamed without changes.
38 changes: 38 additions & 0 deletions demos/prefab/http_request.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--[[
每个 script 节点的代码将被预编译后存放在池中,供每次执行到的时候调用
]]
--
local parm = {
body = {}, -- request body
timeout = "10s",
headers = {}
}

-- REMOTE 可以存放在 global 脚本中(editor/config/global 便于统一修改
local url = REMOTE .. "/group/methon"
-- 载入预设的模块
local http = require("http")
--

--[[
execute 每次执行到 script 或 condition 节点时会调用一次这个函数
script 节点时返回值用作于 editor/response 面板的展示(仅调试阶段
condition 节点时返回值用于 判定节点执行结果(true or false
]]
function execute()
res, errmsg = http.post(url, parm)
if errmsg ~= nil then
meta.Err = errmsg
return
end

if res["status_code"] ~= 200 then
meta.Err = "post " .. url .. " http status code err " .. res["status_code"]
return
end

body = json.decode(res["body"])
merge(meta, body.Body) -- 将 res 数据合并到 meta 结构中(覆盖

return state.Succ, body -- 将http response传递给 editor 中的 response 栏
end
21 changes: 21 additions & 0 deletions demos/prefab/mock_acc_info.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local parm = {
body = {
Token = meta.Token
}, -- request body
timeout = "10s",
headers = {}
}

local url = REMOTE .. "/base/acc.info"
local http = require("http")

function execute()
-- http post request
res, errmsg = http.post(url, parm)
if errmsg == nil then
body = json.decode(res["body"])
merge(meta, body.Body)
end

return state.Succ,body.Body
end
21 changes: 21 additions & 0 deletions demos/prefab/mock_hero_info.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local parm = {
body = {
Token = meta.Token
}, -- request body
timeout = "10s",
headers = {}
}

local url = REMOTE .. "/base/hero.info"
local http = require("http")

function execute()
-- http post request
res, errmsg = http.post(url, parm)
if errmsg == nil then
body = json.decode(res["body"])
merge(meta, body.Body)
end

return state.Succ, body.Body
end
24 changes: 24 additions & 0 deletions demos/prefab/mock_hero_lvup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

local parm = {
body = {
Token = meta.Token,
HeroID = "joy"
}, -- request body
timeout = "10s",
headers = {},
}

local url = REMOTE .. "/base/hero.lvup"
local http = require("http")

function execute()

-- http post request
res, errmsg = http.post(url, parm)
if errmsg == nil then
body = json.decode(res["body"])
merge(meta, body.Body)
end

return state.Succ, body.Body
end
19 changes: 19 additions & 0 deletions demos/prefab/mock_login_guest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local parm = {
body = {}, -- request body
timeout = "10s",
headers = {}
}

local url = REMOTE .. "/login/guest"
local http = require("http")

function execute()
-- http post request
res, errmsg = http.post(url, parm)
if errmsg == nil then
body = json.decode(res["body"])
merge(meta, body.Body)
end

return state.Succ, body.Body
end
1 change: 0 additions & 1 deletion editor/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default defineConfig({
{ path: "/docs", component: "docs", name: "docs", key: "docs" },
],
plugins: [
'@umijs/plugins/dist/react-query',
],
npmClient: 'pnpm',
});
3 changes: 2 additions & 1 deletion editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"build": "umi build",
"preview": "umi preview",
"postinstall": "umi setup",
"umiclean": "umi clean",
"setup": "umi setup",
"start": "npm run dev",
"electron-dev": "electron .",
"package_win32_x64": "electron-packager ./ Gobot --platform=win32 --arch=x64 --overwrite",
"package_win32_x64": "electron-packager ./ Gobot --platform=win32 --arch=x64 --asar=true --prune=true --overwrite",
"package_darwin_arm64": "electron-packager ./ Gobot --platform=darwin --arch=arm64 --overwrite"
},
"dependencies": {
Expand Down
Loading

0 comments on commit e310ecb

Please sign in to comment.