优化
支持sys模块 支持decimal 增加系统模块
This commit is contained in:
126
README.md
126
README.md
@@ -1,77 +1,59 @@
|
||||
# Fast Web (快速网站开发框架)
|
||||
|
||||
<style>
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.box {
|
||||
flex: 1;
|
||||
padding: 10px;
|
||||
border-right: 1px solid #ccc;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.box:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 24px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
## 简介
|
||||
Fast Web 是使用 C++ 和 Lua 开发的网站框架,以快速开发、部署简单为理念,核心部分由C++实现,Lua 脚本语言处理业务逻辑,
|
||||
Fast Web 旨在简化复杂的部署和环境配置,使开发者能够迅速启动并运行他们的网站。
|
||||
# Fast Web
|
||||
|
||||
QQ群:153076832
|
||||
## 特性
|
||||
- **LUA脚本**:通过Lua脚本实现业务逻辑开发,编写及维护更加容易
|
||||
- **易于部署**:只需一个可执行文件
|
||||
|
||||
Fast Web 是一个网站服务程序,以快速开发、部署简单为理念,旨在简化复杂的部署和环境配置,使开发者能够迅速启动并运行他们的网站。
|
||||
|
||||
|
||||
- **LUA脚本**:Lua脚本编写业务逻辑,轻松引用拓展模块
|
||||
- **易于部署**:支持跨平台一键部署,依赖简单,轻量高效
|
||||
- **灵活易用**:适合各类个人博客、API接口到复杂的企业级项目
|
||||
- **开源共建**:欢迎开发者贡献代码,参与项目共建,推动Fast Web的发展
|
||||
<br>
|
||||
|
||||
## 示例
|
||||
|
||||
URL: http://127.0.0.1:8888/scripts/index.lua?key=123456
|
||||
|
||||
#### 拦截器
|
||||
```lua
|
||||
function access()
|
||||
|
||||
if request:pstring("key") == "123456" then
|
||||
return true
|
||||
end
|
||||
|
||||
response:send("密钥不正确,已被拦截器拦截.")
|
||||
return false
|
||||
end
|
||||
```
|
||||
#### 业务代码
|
||||
```lua
|
||||
-- 通用入口函数
|
||||
function access()
|
||||
|
||||
-- MYSQL执行SELECT查询map表
|
||||
local result = mysql:select():table("map"):query()
|
||||
|
||||
-- 构建回复数据
|
||||
local data = result:table()
|
||||
|
||||
-- 返回JSON数据
|
||||
json(data)
|
||||
end
|
||||
```
|
||||
|
||||
## 部署
|
||||
### Windows
|
||||
```bash
|
||||
# 克隆仓库
|
||||
git clone https://github.com/Liuccysdgg/fastweb.git
|
||||
# 进入项目目录
|
||||
cd fastweb
|
||||
# 编译项目 (确保你的机器上安装了VS2022集成开发环境)
|
||||
# 运行 fastweb.sln 编译
|
||||
```
|
||||
|
||||
### Linux
|
||||
```bash
|
||||
# 下载构建脚本
|
||||
https://github.com/Liuccysdgg/fastweb/blob/master/build.sh
|
||||
# 运行脚本
|
||||
./build.sh
|
||||
```
|
||||
|
||||
三方库均仅提供x64二进制发布版本,如需更新或修改请自行根据下方链接下载编译
|
||||
|
||||
## 🙇致谢
|
||||
如果没有社区已有的优秀软件帮助,fastweb就不可能构建出来
|
||||
|
||||
https://github.com/Liuccysdgg/ylib 跨平台快速开发库
|
||||
|
||||
https://github.com/ldcsaa/HP-Socket HPSocket高性能网络库
|
||||
|
||||
https://github.com/ThePhD/sol2 C++ 与 Lua 的绑定
|
||||
|
||||
https://github.com/lua/lua 脚本解释器
|
||||
|
||||
<div class="container">
|
||||
<div class="box">
|
||||
<div class="icon">⚡</div>
|
||||
<h3>立即开始</h3>
|
||||
<p>无论您是编程新手还是经验丰富的开发人员,学习和使用 Fast Web 都很容易。</p>
|
||||
<p><a href="https://fw.newobj.org/doc/">从我们的新手指南开始</a></p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="icon">⬇️</div>
|
||||
<h3>下载</h3>
|
||||
<p>所有版本的 Fast Web 源代码和安装程序均可供下载!</p>
|
||||
<p>最新版:<a href="https://fw.newobj.org/download/">点击下载</a></p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="icon">📄</div>
|
||||
<h3>文档</h3>
|
||||
<p>Fast Web 标准库的文档以及教程和指南都可以在线获取。</p>
|
||||
<p><a href="https://fw.newobj.org/doc/">文档中心</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "module/codec.h"
|
||||
#include "module/time.h"
|
||||
#include "module/file.h"
|
||||
#include "module/sys.h"
|
||||
#define LOOP_STATE_USE 1
|
||||
bool state_manager::start()
|
||||
{
|
||||
@@ -82,6 +83,7 @@ sol::state* state_manager::create_state()
|
||||
module::codec::regist(lua);
|
||||
module::time::regist(lua);
|
||||
module::file::regist(lua);
|
||||
module::sys::regist(lua);
|
||||
|
||||
global::getInstance()->regist_lua(lua);
|
||||
return lua;
|
||||
|
||||
@@ -567,7 +567,11 @@ VarType module::mysql_result::get(sol::object obj, sol::this_state s)
|
||||
{
|
||||
GET_VALUE(get_int64);
|
||||
}
|
||||
return sol::make_object(s, sol::nil);
|
||||
else if (type == "decimal")
|
||||
{
|
||||
GET_VALUE(get_double);
|
||||
}
|
||||
return sol::make_object(s, sol::nil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
12
src/module/sys.cpp
Normal file
12
src/module/sys.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "sys.h"
|
||||
#include "util/system.h"
|
||||
std::string module::sys::current_dir()
|
||||
{
|
||||
return system::current_dir();
|
||||
}
|
||||
void module::sys::regist(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<module::sys>("sys",
|
||||
"current_dir", &module::sys::current_dir
|
||||
);
|
||||
}
|
||||
17
src/module/sys.h
Normal file
17
src/module/sys.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "sol/sol.hpp"
|
||||
#include "imodule.h"
|
||||
|
||||
namespace module
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统
|
||||
/// </summary>
|
||||
class sys:public module::imodule {
|
||||
public:
|
||||
static std::string current_dir();
|
||||
static void regist(sol::state* lua);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user