@nestim/koishi-plugin-qqgm-webui 0.3.1 → 0.3.2
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/lib/main-schema.js +4 -1
- package/lib/plugin-config.js +18 -5
- package/package.json +1 -1
- package/public/app.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### 兼容 chat-style 1.1.2 风格池
|
|
6
|
+
|
|
7
|
+
- 配置页支持数字型 union(`0 / 25 / 50 / 75`):下拉正常显示,保存时按数字写回,不会写成字符串;
|
|
8
|
+
- 过滤 Schema 里 `hidden` / `deprecated` 的旧字段(例如 chat-style 旧的 `probability` / `enabled`),配置页不再出现;
|
|
9
|
+
- 数字 union 在对象列表/嵌套分群配置里同样生效。
|
|
10
|
+
|
|
11
|
+
### 测试
|
|
12
|
+
|
|
13
|
+
- 增加数字 union 与 hidden 字段用例(16 项通过)。
|
|
14
|
+
|
|
3
15
|
## 0.3.1
|
|
4
16
|
|
|
5
17
|
### 配置页:不再生搬 JSON
|
package/README.md
CHANGED
package/lib/main-schema.js
CHANGED
|
@@ -56,6 +56,7 @@ function fieldInfo(key, field) {
|
|
|
56
56
|
default: defaultValue,
|
|
57
57
|
options,
|
|
58
58
|
sensitive: /key|token|secret|password/i.test(key),
|
|
59
|
+
hidden: meta.hidden === true,
|
|
59
60
|
json: type === 'array' || type === 'object' || type === 'intersect',
|
|
60
61
|
long,
|
|
61
62
|
arrayOf,
|
|
@@ -73,7 +74,9 @@ function groups() {
|
|
|
73
74
|
const dict = group.dict || {};
|
|
74
75
|
return {
|
|
75
76
|
title: (group.meta && group.meta.description) || '配置',
|
|
76
|
-
fields: Object.keys(dict)
|
|
77
|
+
fields: Object.keys(dict)
|
|
78
|
+
.map((key) => fieldInfo(key, dict[key]))
|
|
79
|
+
.filter((field) => !field.hidden),
|
|
77
80
|
};
|
|
78
81
|
});
|
|
79
82
|
}
|
package/lib/plugin-config.js
CHANGED
|
@@ -81,7 +81,9 @@ function fieldInfo(key, field, groupTitle) {
|
|
|
81
81
|
const type = String((field && field.type) || 'string');
|
|
82
82
|
const options = [];
|
|
83
83
|
if (type === 'union') {
|
|
84
|
-
for (const match of String(field).matchAll(/"([^"]+)"/g))
|
|
84
|
+
for (const match of String(field).matchAll(/"([^"]+)"|(-?\d+(?:\.\d+)?)/g)) {
|
|
85
|
+
options.push(match[1] ?? match[2]);
|
|
86
|
+
}
|
|
85
87
|
} else if (type === 'const') {
|
|
86
88
|
const value = meta.default;
|
|
87
89
|
if (value != null) options.push(String(value));
|
|
@@ -103,10 +105,14 @@ function fieldInfo(key, field, groupTitle) {
|
|
|
103
105
|
list = true;
|
|
104
106
|
} else if (field.inner && field.inner.dict) {
|
|
105
107
|
objectList = true;
|
|
106
|
-
itemFields = Object.keys(field.inner.dict)
|
|
108
|
+
itemFields = Object.keys(field.inner.dict)
|
|
109
|
+
.map((name) => fieldInfo(name, field.inner.dict[name], groupTitle))
|
|
110
|
+
.filter((info) => !info.hidden);
|
|
107
111
|
}
|
|
108
112
|
} else if (type === 'object' && field.dict) {
|
|
109
|
-
objectFields = Object.keys(field.dict)
|
|
113
|
+
objectFields = Object.keys(field.dict)
|
|
114
|
+
.map((name) => fieldInfo(name, field.dict[name], groupTitle))
|
|
115
|
+
.filter((info) => !info.hidden);
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
return {
|
|
@@ -117,6 +123,8 @@ function fieldInfo(key, field, groupTitle) {
|
|
|
117
123
|
description,
|
|
118
124
|
default: defaultValue,
|
|
119
125
|
options,
|
|
126
|
+
numericUnion: type === 'union' && options.length > 0 && options.every((opt) => /^-?\d+(?:\.\d+)?$/.test(opt)),
|
|
127
|
+
hidden: meta.hidden === true,
|
|
120
128
|
sensitive: /key|token|secret|password/i.test(key),
|
|
121
129
|
required: meta.required === true,
|
|
122
130
|
long,
|
|
@@ -156,12 +164,17 @@ function flattenFields(config) {
|
|
|
156
164
|
for (const group of config.list) {
|
|
157
165
|
const title = (group.meta && group.meta.description) || '';
|
|
158
166
|
const dict = group.dict || {};
|
|
159
|
-
for (const key of Object.keys(dict))
|
|
167
|
+
for (const key of Object.keys(dict)) {
|
|
168
|
+
const info = fieldInfo(key, dict[key], title);
|
|
169
|
+
if (!info.hidden) out.push(info);
|
|
170
|
+
}
|
|
160
171
|
}
|
|
161
172
|
return out;
|
|
162
173
|
}
|
|
163
174
|
const dict = config.dict || {};
|
|
164
|
-
return Object.keys(dict)
|
|
175
|
+
return Object.keys(dict)
|
|
176
|
+
.map((key) => fieldInfo(key, dict[key], ''))
|
|
177
|
+
.filter((field) => !field.hidden);
|
|
165
178
|
}
|
|
166
179
|
|
|
167
180
|
function readFile(ctx) {
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -1345,6 +1345,7 @@ function collectSimpleValue(container, field) {
|
|
|
1345
1345
|
const input = container.querySelector('input, select, textarea');
|
|
1346
1346
|
if (!input) return undefined;
|
|
1347
1347
|
if (field.type === 'number') return input.value === '' ? undefined : Number(input.value);
|
|
1348
|
+
if (field.numericUnion) return input.value === '' ? undefined : Number(input.value);
|
|
1348
1349
|
if (field.json) {
|
|
1349
1350
|
try { return JSON.parse(input.value); }
|
|
1350
1351
|
catch { throw new Error(`${field.label || field.key} 的 JSON 格式不对`); }
|