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 行删除
+32
查看文件
@@ -0,0 +1,32 @@
var http = require('./request')
module.exports = {
// Auth
login: function (code) { return http.post('/api/v1/auth/login', { code: code }) },
getPhone: function (code) { return http.post('/api/v1/user/phone', { code: code }) },
// User
getProfile: function () { return http.get('/api/v1/user/profile') },
updateProfile: function (data) { return http.put('/api/v1/user/profile', data) },
// Device
getDevices: function () { return http.get('/api/v1/device/list') },
bindDevice: function (deviceId) { return http.post('/api/v1/device/bind', { device_id: deviceId }) },
confirmBind: function (deviceId, token) { return http.post('/api/v1/device/bind/confirm', { device_id: deviceId, bind_token: token }) },
mockBind: function (deviceId) { return http.post('/api/v1/device/mock-bind', { device_id: deviceId }) },
unbindDevice: function (deviceId) { return http.post('/api/v1/device/unbind', { device_id: deviceId }) },
// Subscription
getSubscription: function () { return http.get('/api/v1/subscription') },
activateTrial: function () { return http.post('/api/v1/subscription/trial') },
purchase: function (plan) { return http.post('/api/v1/subscription/purchase', { plan: plan }) },
// Treatment
getRecords: function (params) { return http.get('/api/v1/treatment/history', params) },
syncTreatment: function (data) { return http.post('/api/v1/treatment/sync', data) },
getRecordDetail: function (id) { return http.get('/api/v1/treatment/' + id) },
// Device commands
getPendingCommands: function (deviceId) { return http.get('/api/v1/device/command/pending', { device_id: deviceId }) },
reportCommandResult: function (data) { return http.post('/api/v1/device/command/result', data) }
}
+25
查看文件
@@ -0,0 +1,25 @@
var app = getApp()
/** Get status bar height for custom navigation pages */
function getStatusBarHeight() {
return app.globalData.statusBarHeight || 44
}
/** Standard back navigation with fallback */
function navigateBack(fallbackUrl) {
wx.navigateBack({
fail: function () {
if (fallbackUrl) {
wx.reLaunch({ url: fallbackUrl })
}
}
})
}
/** Check if dev mode is enabled */
function isDevMode() {
var config = require('../config/env')
return config.__DEV__ || false
}
module.exports = { getStatusBarHeight: getStatusBarHeight, navigateBack: navigateBack, isDevMode: isDevMode }