refactor: restructure entire project for human maintainability

Server:
- Add Express framework, replace custom router/request parser
- Create DAO layer (12 files) centralizing all 73 SQL queries
- Rewrite 7 route files as thin Express controllers calling DAOs
- Add SCF-to-Express adapter (lib/serverless.js)
- Add auth middleware (middleware/auth.js)
- Remove dead code from lib/auth.js

Admin console:
- Extract DataTable component (table + pagination)
- Extract ConfirmModal component (modal + form styles)
- Create listMixin for paginated list pages
- Move form styles to common.css for slot compatibility
- Refactor device + subscription pages as examples

Miniprogram:
- Split 734-line BLE monolith into 4 focused modules
  (protocol, connection, commands, barrel index)
- Create API module (utils/api.js) with named functions
- Create page utilities (utils/page.js)
- Refactor index + profile pages to use API module
这个提交包含在:
Guoguo
2026-04-29 05:58:20 -07:00
父节点 9f0e629c82
当前提交 bb4b80f867
修改 46 个文件,包含 4306 行新增2020 行删除
+5 -5
查看文件
@@ -1,5 +1,5 @@
var ble = require('../../services/ble')
var http = require('../../utils/request')
var api = require('../../utils/api')
var config = require('../../config/env')
var app = getApp()
@@ -49,7 +49,7 @@ Page({
self.setData({ connected: ble.isConnected() })
http.get('/api/v1/device/list').then(function (data) {
api.getDevices().then(function (data) {
var devices = data.devices || []
self.setData({ hasDevice: devices.length > 0 })
if (devices.length > 0) {
@@ -61,7 +61,7 @@ Page({
}
}).catch(function () {})
http.get('/api/v1/subscription').then(function (sub) {
api.getSubscription().then(function (sub) {
self.setData({
subscription: sub,
subRemaining: sub.remaining_days || 0
@@ -125,7 +125,7 @@ Page({
var self = this
wx.showLoading({ title: '解绑中...' })
ble.disconnect()
http.post('/api/v1/device/unbind', {}).then(function () {
api.unbindDevice().then(function () {
wx.hideLoading()
self.setData({
hasDevice: false,
@@ -157,7 +157,7 @@ Page({
success: function (res) {
if (res.confirm && res.content) {
var deviceId = res.content.trim()
http.post('/api/v1/device/mock-bind', { device_id: deviceId }).then(function () {
api.mockBind(deviceId).then(function () {
wx.showToast({ title: '模拟绑定成功', icon: 'success' })
self.checkState()
}).catch(function (err) {