update README.md.

Signed-off-by: 烟雨如花 <2324281453@qq.com>
This commit is contained in:
烟雨如花 2025-01-15 13:18:50 +00:00 committed by Gitee
parent b0ad61346c
commit 5d8480dd17
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -353,46 +353,32 @@ decimal -> DECIMAL(precision, scale)
### 全局变量对应关系 ### 全局变量对应关系
1. `$_W` (WeEngine全局配置): 1. `$_W` (WeEngine全局配置):
```python ```php
class WeConfig: $_W = array(
def __init__(self, request: Request): 'config' => array(), // 系统配置信息
self.config = {} # 系统配置 'timestamp' => time(), // 当前时间戳
self.uniacid = None # 当前公众号ID (从请求参数i获取) 'charset' => 'utf8', // 字符集
self.acid = None # 当前账号ID 'clientip' => '', // 客户端IP
self.uid = None # 当前用户ID 'uniacid' => 0, // 当前统一公众号ID
self.timestamp = int(time.time()) # 当前时间戳 'acid' => 0, // 当前账号ID
self.clientip = request.client.host # 客户端IP 'uid' => 0, // 当前用户ID
self.container = "wxapp" # 容器类型 'isajax' => false, // 是否AJAX请求
self.isajax = "XMLHttpRequest" in request.headers.get("X-Requested-With", "") 'ispost' => false, // 是否POST请求
self.ispost = request.method == "POST" 'siteroot' => '', // 站点根目录URL
self.sitescheme = "https://" if request.url.scheme == "https" else "http://" 'siteurl' => '', // 当前URL
self.script_name = request.url.path 'attachurl' => '', // 附件URL
self.siteroot = str(request.base_url) 'setting' => array(), // 站点设置
self.attachurl = f"{self.siteroot}attachment/" 'module' => array() // 当前模块信息
);
``` ```
2. `$_GPC` (全局请求参数): 2. `$_GPC` (全局请求参数):
```python ```php
async def get_all_params(request: Request) -> dict: $_GPC = array_merge(
"""合并所有请求参数""" $_GET, // GET参数
# 查询参数 $_POST, // POST参数
params = dict(request.query_params) $_COOKIE // COOKIE数据
);
# POST/表单数据
try:
form = await request.form()
params.update(dict(form))
except:
try:
json_data = await request.json()
params.update(json_data)
except:
pass
# Cookie数据
params.update(dict(request.cookies))
return params
``` ```
### 迁移方法步骤 ### 迁移方法步骤