forked from newthuhole/hole_thu_frontend
前端生成各楼代号
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { get_json} from './infrastructure/functions';
|
import { get_json, gen_name} from './infrastructure/functions';
|
||||||
import { API_BASE } from './Common';
|
import { API_BASE } from './Common';
|
||||||
import { cache } from './cache';
|
import { cache } from './cache';
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ const parse_replies = (replies, color_picker) =>
|
|||||||
replies
|
replies
|
||||||
.sort((a, b) => parseInt(a.cid, 10) - parseInt(b.cid, 10))
|
.sort((a, b) => parseInt(a.cid, 10) - parseInt(b.cid, 10))
|
||||||
.map((info) => {
|
.map((info) => {
|
||||||
|
info.name = gen_name(info.name_id);
|
||||||
info._display_color = color_picker.get(info.name);
|
info._display_color = color_picker.get(info.name);
|
||||||
info.variant = {};
|
info.variant = {};
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -30,3 +30,46 @@ export function listen_darkmode(override) { // override: true/false/undefined
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NAMES = [
|
||||||
|
'Alice',
|
||||||
|
'Bob',
|
||||||
|
'Carol',
|
||||||
|
'Dave',
|
||||||
|
'Eve',
|
||||||
|
'Francis',
|
||||||
|
'Grace',
|
||||||
|
'Hans',
|
||||||
|
'Isabella',
|
||||||
|
'Jason',
|
||||||
|
'Kate',
|
||||||
|
'Louis',
|
||||||
|
'Margaret',
|
||||||
|
'Nathan',
|
||||||
|
'Olivia',
|
||||||
|
'Paul',
|
||||||
|
'Queen',
|
||||||
|
'Richard',
|
||||||
|
'Susan',
|
||||||
|
'Thomas',
|
||||||
|
'Uma',
|
||||||
|
'Vivian',
|
||||||
|
'Winnie',
|
||||||
|
'Xander',
|
||||||
|
'Yasmine',
|
||||||
|
'Zach'
|
||||||
|
]
|
||||||
|
|
||||||
|
export function gen_name(name_id) {
|
||||||
|
if (name_id == 0)
|
||||||
|
return '洞主';
|
||||||
|
|
||||||
|
let r = name_id - 1;
|
||||||
|
let name = '';
|
||||||
|
do {
|
||||||
|
name += ' ' + NAMES[r % 26];
|
||||||
|
r = parseInt(r / 26);
|
||||||
|
} while (r);
|
||||||
|
|
||||||
|
return name.substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user