mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: use NumericArray to parse uids
This commit is contained in:
1 parent
38bee6415d
commit
4b48c0c164
3 files changed
+10
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.21.13",
|
"version": "2.21.14",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class DomainUserHandler extends ManageHandler {
|
|||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@param('uid', Types.Array)
|
@param('uid', Types.NumericArray)
|
||||||
@param('role', Types.String)
|
@param('role', Types.String)
|
||||||
async postSetUsers(domainId: string, uid: number[], role: string) {
|
async postSetUsers(domainId: string, uid: number[], role: string) {
|
||||||
await domain.setUserRole(domainId, uid, role);
|
await domain.setUserRole(domainId, uid, role);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export interface Types {
|
|||||||
Time: Type,
|
Time: Type,
|
||||||
Range: (range: Array<string | number> | Dictionary<any>) => Type,
|
Range: (range: Array<string | number> | Dictionary<any>) => Type,
|
||||||
Array: Type,
|
Array: Type,
|
||||||
|
NumericArray: Type,
|
||||||
Set: Type,
|
Set: Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,6 +141,13 @@ export const Types: Types = {
|
|||||||
if (v instanceof Array) return v;
|
if (v instanceof Array) return v;
|
||||||
return v ? [v] : [];
|
return v ? [v] : [];
|
||||||
}, null],
|
}, null],
|
||||||
|
NumericArray: [(v) => {
|
||||||
|
if (v instanceof Array) return v.map(Number);
|
||||||
|
return v ? [Number(v)] : [];
|
||||||
|
}, (v) => {
|
||||||
|
if (v instanceof Array) return !v.map(Number).includes(NaN);
|
||||||
|
return !Number.isNaN(+v);
|
||||||
|
}],
|
||||||
Set: [(v) => {
|
Set: [(v) => {
|
||||||
if (v instanceof Array) return new Set(v);
|
if (v instanceof Array) return new Set(v);
|
||||||
return v ? new Set([v]) : new Set();
|
return v ? new Set([v]) : new Set();
|
||||||
|
|||||||
Reference in new issue
Block a user