befly 3.64.0 → 3.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/auth/login.js +19 -64
- package/apis/dashboard/environmentInfo.js +1 -0
- package/apis/tongJi/errorReport.js +1 -1
- package/index.js +4 -6
- package/package.json +1 -1
package/apis/auth/login.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import adminTable from "#befly/tables/admin.json";
|
|
2
|
+
import loginLogTable from "#befly/tables/loginLog.json";
|
|
2
3
|
import { toSessionTtlSeconds } from "#befly/utils/util.js";
|
|
3
4
|
|
|
4
5
|
export default {
|
|
@@ -21,61 +22,15 @@ export default {
|
|
|
21
22
|
min: null,
|
|
22
23
|
max: null
|
|
23
24
|
},
|
|
24
|
-
clientType:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
input: "string",
|
|
34
|
-
min: 0,
|
|
35
|
-
max: 100
|
|
36
|
-
},
|
|
37
|
-
productCode: {
|
|
38
|
-
name: "产品代号",
|
|
39
|
-
input: "string",
|
|
40
|
-
min: 0,
|
|
41
|
-
max: 100
|
|
42
|
-
},
|
|
43
|
-
productVersion: {
|
|
44
|
-
name: "产品版本",
|
|
45
|
-
input: "string",
|
|
46
|
-
min: 0,
|
|
47
|
-
max: 50
|
|
48
|
-
},
|
|
49
|
-
clientVersion: {
|
|
50
|
-
name: "客户端版本",
|
|
51
|
-
input: "string",
|
|
52
|
-
min: 0,
|
|
53
|
-
max: 100
|
|
54
|
-
},
|
|
55
|
-
os: {
|
|
56
|
-
name: "操作系统",
|
|
57
|
-
input: "string",
|
|
58
|
-
min: 0,
|
|
59
|
-
max: 100
|
|
60
|
-
},
|
|
61
|
-
system: {
|
|
62
|
-
name: "系统",
|
|
63
|
-
input: "string",
|
|
64
|
-
min: 0,
|
|
65
|
-
max: 100
|
|
66
|
-
},
|
|
67
|
-
brand: {
|
|
68
|
-
name: "设备品牌",
|
|
69
|
-
input: "string",
|
|
70
|
-
min: 0,
|
|
71
|
-
max: 100
|
|
72
|
-
},
|
|
73
|
-
model: {
|
|
74
|
-
name: "设备型号",
|
|
75
|
-
input: "string",
|
|
76
|
-
min: 0,
|
|
77
|
-
max: 100
|
|
78
|
-
}
|
|
25
|
+
clientType: loginLogTable.clientType,
|
|
26
|
+
productName: loginLogTable.productName,
|
|
27
|
+
productCode: loginLogTable.productCode,
|
|
28
|
+
productVersion: loginLogTable.productVersion,
|
|
29
|
+
clientVersion: loginLogTable.clientVersion,
|
|
30
|
+
os: loginLogTable.os,
|
|
31
|
+
system: loginLogTable.system,
|
|
32
|
+
brand: loginLogTable.brand,
|
|
33
|
+
model: loginLogTable.model
|
|
79
34
|
},
|
|
80
35
|
required: ["account", "password", "loginType"],
|
|
81
36
|
handler: async (befly, ctx) => {
|
|
@@ -86,15 +41,15 @@ export default {
|
|
|
86
41
|
username: ctx.body.account,
|
|
87
42
|
nickname: "",
|
|
88
43
|
ip: ctx.ip || "",
|
|
89
|
-
clientType: body.clientType,
|
|
90
|
-
productName: body.productName ||
|
|
91
|
-
productCode: body.productCode ||
|
|
92
|
-
productVersion: body.productVersion ||
|
|
93
|
-
clientVersion: body.clientVersion ||
|
|
94
|
-
os: body.os ||
|
|
95
|
-
system: body.system ||
|
|
96
|
-
brand: body.brand ||
|
|
97
|
-
model: body.model ||
|
|
44
|
+
clientType: body.clientType || "",
|
|
45
|
+
productName: body.productName || "",
|
|
46
|
+
productCode: body.productCode || "",
|
|
47
|
+
productVersion: body.productVersion || "",
|
|
48
|
+
clientVersion: body.clientVersion || "",
|
|
49
|
+
os: body.os || "",
|
|
50
|
+
system: body.system || "",
|
|
51
|
+
brand: body.brand || "",
|
|
52
|
+
model: body.model || "",
|
|
98
53
|
loginTime: Date.now(),
|
|
99
54
|
loginResult: 0,
|
|
100
55
|
failReason: ""
|
|
@@ -108,7 +108,7 @@ export default {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
try {
|
|
111
|
-
await befly.mysql.insData({ table: "
|
|
111
|
+
await befly.mysql.insData({ table: "beflyErrorReport", data: data });
|
|
112
112
|
stored = true;
|
|
113
113
|
} catch (error) {
|
|
114
114
|
Logger.error("errorReport 插入失败", error);
|
package/index.js
CHANGED
|
@@ -115,7 +115,7 @@ async function ensureSyncPrerequisites(ctx) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
export async function createBefly(
|
|
118
|
+
export async function createBefly(config = {}, menus = []) {
|
|
119
119
|
const mergedConfig = deepMerge(beflyConfig, config);
|
|
120
120
|
const mergedMenus = deepMerge(prefixMenuPaths(beflyMenus, "core"), menus);
|
|
121
121
|
mergedConfig.projectLists = mergeProjectListsByCode(mergedConfig.projectLists);
|
|
@@ -144,7 +144,6 @@ export async function createBefly(env = {}, config = {}, menus = []) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
return new Befly({
|
|
147
|
-
env: env,
|
|
148
147
|
config: mergedConfig,
|
|
149
148
|
tables: tables,
|
|
150
149
|
menus: mergedMenus,
|
|
@@ -162,7 +161,6 @@ export async function createBefly(env = {}, config = {}, menus = []) {
|
|
|
162
161
|
export class Befly {
|
|
163
162
|
constructor(init = {}) {
|
|
164
163
|
this.context = {
|
|
165
|
-
env: init.env || {},
|
|
166
164
|
config: init.config || {},
|
|
167
165
|
tables: init.tables || {}
|
|
168
166
|
};
|
|
@@ -208,7 +206,7 @@ export class Befly {
|
|
|
208
206
|
await ensureSyncPrerequisites(this.context);
|
|
209
207
|
|
|
210
208
|
// 自动同步(PM2 cluster:主进程执行,其它进程等待同步完成)
|
|
211
|
-
if (isPrimaryProcess(
|
|
209
|
+
if (isPrimaryProcess(Bun.env)) {
|
|
212
210
|
await syncApi(this.context, this.apis);
|
|
213
211
|
await syncMenu(this.context, this.menus);
|
|
214
212
|
await syncDev(this.context);
|
|
@@ -229,7 +227,7 @@ export class Befly {
|
|
|
229
227
|
port: this.context.config.appPort || 3000,
|
|
230
228
|
hostname: this.context.config.appHost || "0.0.0.0",
|
|
231
229
|
// 开发模式下启用详细错误信息
|
|
232
|
-
development: this.context.
|
|
230
|
+
development: this.context.config.runMode === "development",
|
|
233
231
|
// 空闲连接超时时间(秒),防止恶意连接占用资源
|
|
234
232
|
fetch: async (req, httpServer) => {
|
|
235
233
|
const url = new URL(req.url);
|
|
@@ -247,7 +245,7 @@ export class Befly {
|
|
|
247
245
|
error: (error) => {
|
|
248
246
|
Logger.error("服务启动时发生错误", error);
|
|
249
247
|
// 开发模式下返回详细错误信息
|
|
250
|
-
if (this.context.
|
|
248
|
+
if (this.context.config.runMode === "development") {
|
|
251
249
|
return Response.json(
|
|
252
250
|
{
|
|
253
251
|
code: 1,
|