Canonicalize WsRole strings and migrate legacy values
Normalize OneBot WS role values to canonical PascalCase ('Api'|'Event'|'Universal') across core and web UI, and support auto-migration from legacy lowercase on-disk values. Updated types, defaults, serializers/parsers, and runtime checks in ws-transport, adjusted WebUI select options and default entries, and updated the client User-Agent string. Added a test to verify that legacy lowercase role values are migrated to the new canonical form on load.
This commit is contained in:
1 parent
4d97f02fe9
commit
b62a6edd37
6 files changed
+57
-28
No files matched your search
@@ -336,7 +336,7 @@ export function ConfigPage({
|
||||
/>
|
||||
<SelectField
|
||||
label="角色"
|
||||
value={item.role ?? 'universal'}
|
||||
value={item.role ?? 'Universal'}
|
||||
options={WS_ROLE_OPTIONS}
|
||||
onChange={(v) => patch({ role: v })}
|
||||
className="sm:w-32"
|
||||
@@ -355,7 +355,7 @@ export function ConfigPage({
|
||||
host: '0.0.0.0',
|
||||
port: 3001,
|
||||
path: '/',
|
||||
role: 'universal' as WsRole,
|
||||
role: 'Universal' as WsRole,
|
||||
accessToken: generateAccessToken(),
|
||||
messageFormat: 'array',
|
||||
reportSelfMessage: false,
|
||||
@@ -381,7 +381,7 @@ export function ConfigPage({
|
||||
/>
|
||||
<SelectField
|
||||
label="角色"
|
||||
value={item.role ?? 'universal'}
|
||||
value={item.role ?? 'Universal'}
|
||||
options={WS_ROLE_OPTIONS}
|
||||
onChange={(v) => patch({ role: v })}
|
||||
className="sm:w-32"
|
||||
@@ -405,7 +405,7 @@ export function ConfigPage({
|
||||
defaultEntry={(suffix) => ({
|
||||
name: `wsclient-${suffix}`,
|
||||
url: 'ws://127.0.0.1:8080/ws',
|
||||
role: 'universal' as WsRole,
|
||||
role: 'Universal' as WsRole,
|
||||
reconnectIntervalMs: 5000,
|
||||
messageFormat: 'array',
|
||||
reportSelfMessage: false,
|
||||
@@ -559,9 +559,9 @@ const ADAPTER_REPORT_OPTIONS: ReadonlyArray<SegmentedOption<'on' | 'off'>> = [
|
||||
];
|
||||
|
||||
const WS_ROLE_OPTIONS: ReadonlyArray<SegmentedOption<WsRole>> = [
|
||||
{ value: 'universal', label: 'universal' },
|
||||
{ value: 'event', label: 'event' },
|
||||
{ value: 'api', label: 'api' },
|
||||
{ value: 'Universal', label: 'Universal' },
|
||||
{ value: 'Event', label: 'Event' },
|
||||
{ value: 'Api', label: 'Api' },
|
||||
];
|
||||
|
||||
interface BaseAdapter {
|
||||
|
||||
Reference in new issue
Block a user