diff --git a/README.md b/README.md index 4be53a4..e1d5144 100644 --- a/README.md +++ b/README.md @@ -415,6 +415,18 @@ npm run serve - 启动后端微服务注册中心:nacos +- 在本地启动Gateway及各个微服务项目 + +- 在服务器端启动内网穿透Server端,在本地启动内网穿透Client端 + + ```bash + cd ./intranet-penetration/bin + # server + rathole ../conf/server.toml + # client + rathole.exe ../conf/client.toml + ``` + - 启动接口测试工具:Postman - 启动命令行:`npm run dev:alipay`(支付宝小程序)、`npm run dev:weapp`(微信小程序) diff --git a/backend-mock/index.js b/backend-mock/index.js index f9d4a18..93dc766 100644 --- a/backend-mock/index.js +++ b/backend-mock/index.js @@ -6,6 +6,8 @@ const server = http.createServer(); // 3. 监听请求事件 server.on("request", (req, res) => { + console.log(new Date(), "req.url", req.url); + //req-->request 请求对象, res-->response 响应对象 // 通过响应头设置返回前台数据格式及编码。(解决中文乱码的问题) // res.setHeader('Content-Type', 'text/html;charset=utf-8'); diff --git a/intranet-penetration/.gitignore b/intranet-penetration/.gitignore new file mode 100644 index 0000000..45c909b --- /dev/null +++ b/intranet-penetration/.gitignore @@ -0,0 +1,4 @@ +bin/rathole +bin/rathole.exe +conf/client.toml +conf/server.toml diff --git a/intranet-penetration/README.md b/intranet-penetration/README.md new file mode 100644 index 0000000..57a1ca2 --- /dev/null +++ b/intranet-penetration/README.md @@ -0,0 +1,29 @@ +# 内网穿透 + +> 开发时,在本地电脑启动后端服务,然后通过内网穿透进行小程序真机调试。 + +需要有一台公网服务器,一个域名(可选),以及服务器打开对应端口 + +## bin 二进制文件下载 + +GitHub: https://github.com/rapiz1/rathole/ + +## 配置 + +修改 conf 文件夹中配置文件 + +## 启动 + +服务端 + +```bash +cd bin +rathole ../conf/server.toml +``` + +本地 + +```bash +cd bin +rathole.exe ../conf/client.toml +``` diff --git a/intranet-penetration/conf/client.example.toml b/intranet-penetration/conf/client.example.toml new file mode 100644 index 0000000..ec92dea --- /dev/null +++ b/intranet-penetration/conf/client.example.toml @@ -0,0 +1,5 @@ +[client] +remote_addr = "xxx.xxx.xxx.xxx:yyy" # 服务器的地址。端口必须与 `server.bind_addr` 中的端口相同。 +[client.services.zzzz] +token = "xxxxxxxxxxxxxxxxx" # 必须与服务器相同以通过验证 +local_addr = "127.0.0.1:80" # 需要被转发的服务的地址 diff --git a/intranet-penetration/conf/server.example.toml b/intranet-penetration/conf/server.example.toml new file mode 100644 index 0000000..1de9824 --- /dev/null +++ b/intranet-penetration/conf/server.example.toml @@ -0,0 +1,5 @@ +[server] +bind_addr = "xxx.xxx.xxx.xxx:yyy" # `yyy` 配置了服务端监听客户端连接的端口 +[server.services.zzzz] +token = "xxxxxxxxxxxxxxxxx" # 用于验证的 token +bind_addr = "0.0.0.0:aaaa" # `aaaa` 配置暴露给互联网的端口 diff --git a/miniprogram/src/app.js b/miniprogram/src/app.js index 99c4fb1..76613cf 100644 --- a/miniprogram/src/app.js +++ b/miniprogram/src/app.js @@ -11,7 +11,9 @@ const App = createApp({ App.use(setGlobalDataPlugin, { globalData: { debugMode: true, // 是否展示调试内容 - baseUrl: "http://localhost", // 不带最后的 / + baseUrl: true + ? "http://39.99.244.156:5203" + : "http://localhost", // 不带最后的 / } }) diff --git a/miniprogram/src/pages/index/login.vue b/miniprogram/src/pages/index/login.vue index 27ba04e..1cd88ad 100644 --- a/miniprogram/src/pages/index/login.vue +++ b/miniprogram/src/pages/index/login.vue @@ -62,7 +62,7 @@ export default { title: "登录成功", icon: 'success', success: function () { - Taro.redirectTo({ + Taro.switchTab({ url: '/pages/index/index' }) } diff --git a/miniprogram/src/pages/residents/code.config.js b/miniprogram/src/pages/residents/code.config.js index b055c98..1a01985 100644 --- a/miniprogram/src/pages/residents/code.config.js +++ b/miniprogram/src/pages/residents/code.config.js @@ -1,3 +1,4 @@ export default definePageConfig({ - navigationBarTitleText: '身份码' + navigationBarTitleText: '身份码', + enablePullDownRefresh: true, }) diff --git a/miniprogram/src/pages/residents/code.css b/miniprogram/src/pages/residents/code.css index add7dcb..85da619 100644 --- a/miniprogram/src/pages/residents/code.css +++ b/miniprogram/src/pages/residents/code.css @@ -5,5 +5,7 @@ #myQrcode { display: block; margin: 0 auto; - /* border: 20px solid red; */ + + margin-top: 50px; + margin-bottom: 40px; } diff --git a/miniprogram/src/pages/residents/code.vue b/miniprogram/src/pages/residents/code.vue index 3d1e623..4c7ec15 100644 --- a/miniprogram/src/pages/residents/code.vue +++ b/miniprogram/src/pages/residents/code.vue @@ -1,8 +1,5 @@