updated 代码优化

This commit is contained in:
PASSER-BY
2023-10-16 22:52:33 +08:00
parent 3e421ed1ab
commit bbb7a97b7e
6 changed files with 13 additions and 22 deletions

View File

@@ -2,7 +2,6 @@
* 缓存数据
*/
import _input from './data/input';
import {modeData} from './mode';
let _hash = Object.assign({},modeData,_input);

View File

@@ -151,8 +151,7 @@ let data = Object.assign({},modeData,{
'xs':['姐妹']
});
export function getChainById(id,sex){
let arr = id.split(',');
let item = arr.map(function(sign){
let item = id.split(',').map(function(sign){
let key = sign.replace(/&[ol\d]+/,'');
return data[key][0];
}).join('的');

View File

@@ -39,27 +39,20 @@ let getMap = function(prefixMap,branch){
return map;
};
// 分支前缀处理
let prefixMap1 = {};
let prefixMap = {};
for(let key in _prefix){
prefixMap1[key] = {};
prefixMap[key] = {};
for(let selector in _prefix[key]){
if(selector.indexOf(']')==-1){
prefixMap1[key][selector] = _prefix[key][selector];
}
}
}
let prefixMap2 = {};
for(let key in _prefix){
prefixMap2[key] = {};
for(let selector in _prefix[key]){
if(selector.indexOf(']')>-1){
prefixMap[key][selector] = _prefix[key][selector];
}else{
expandSelector(selector).forEach(function(s){
prefixMap2[key][s] = _prefix[key][selector];
prefixMap[key][s] = _prefix[key][selector];
});
}
}
}
_map = Object.assign({},_map,getMap(prefixMap1,_branch),getMap(prefixMap2,_branch));
_map = Object.assign({},_map,getMap(prefixMap,_branch));
// 主要关系
for(let key in _main){
_map[key] = [].concat(_main[key],_map[key]||[]);