updated 压缩工具由webpack换成rollup
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import {getOptions} from './module/options';
|
||||
import {getSelectors,mergeSelector,selector2id} from './module/selector';
|
||||
import {reverseId,getItemsById,getChainById,getPairsById} from './module/id';
|
||||
import {setModeData,getModeData,modeData as _data} from './module/mode';
|
||||
import {setModeData,getModeData,modeData} from './module/mode';
|
||||
|
||||
let _data = modeData;
|
||||
|
||||
// 对外方法
|
||||
var relationship = function (parameter){
|
||||
let relationship = function (parameter){
|
||||
if(typeof parameter =='string'){
|
||||
parameter = getOptions(parameter);
|
||||
}
|
||||
var options = Object.assign({
|
||||
let options = Object.assign({
|
||||
text:'', // 目标对象:目标对象的称谓汉字表达,称谓间用‘的’字分隔
|
||||
target:'', // 相对对象:相对对象的称谓汉字表达,称谓间用‘的’字分隔,空表示自己
|
||||
sex:-1, // 本人性别:0表示女性,1表示男性
|
||||
@@ -18,12 +20,12 @@ var relationship = function (parameter){
|
||||
optimal:false // 最短关系:计算两者之间的最短关系
|
||||
},parameter);
|
||||
_data = getModeData(options.mode);
|
||||
var from_selectors = getSelectors(options.text);
|
||||
var to_selectors = getSelectors(options.target);
|
||||
let from_selectors = getSelectors(options.text);
|
||||
let to_selectors = getSelectors(options.target);
|
||||
if(!to_selectors.length){
|
||||
to_selectors = [''];
|
||||
}
|
||||
var result = []; //匹配结果
|
||||
let result = []; //匹配结果
|
||||
// console.log('[selectors]',from_selectors,to_selectors);
|
||||
from_selectors.forEach(function(from_selector){
|
||||
to_selectors.forEach(function(to_selector){
|
||||
@@ -34,11 +36,11 @@ var relationship = function (parameter){
|
||||
optimal:options.optimal
|
||||
}).forEach(function(data){
|
||||
// console.log('[data]',from_selector,to_selector,options.optimal,data);
|
||||
var ids = data?selector2id(data['selector'],data['sex']):[];
|
||||
let ids = data?selector2id(data['selector'],data['sex']):[];
|
||||
// console.log('[ids]',data['selector'],data['sex'],ids);
|
||||
ids.forEach(function(id){
|
||||
var temps = [id];
|
||||
var sex = data['sex'];
|
||||
let temps = [id];
|
||||
let sex = data['sex'];
|
||||
if(options.reverse){
|
||||
temps = reverseId(id,sex);
|
||||
if(id.match(/([fhs1](&[ol\d]+)?|[olx]b)$/)){
|
||||
@@ -49,7 +51,7 @@ var relationship = function (parameter){
|
||||
}
|
||||
if(options.type=='chain'){
|
||||
temps.forEach(function(id){
|
||||
var item = getChainById(id,data['sex']);
|
||||
let item = getChainById(id,data['sex']);
|
||||
if(item){
|
||||
result.push(item);
|
||||
}
|
||||
@@ -57,12 +59,12 @@ var relationship = function (parameter){
|
||||
}else if(options.type=='pair'){
|
||||
temps = reverseId(id,data['sex']);
|
||||
temps.forEach(function(r_id){
|
||||
var pairs = getPairsById(id,r_id);
|
||||
let pairs = getPairsById(id,r_id);
|
||||
result = result.concat(pairs);
|
||||
});
|
||||
}else{
|
||||
temps.forEach(function(id){
|
||||
var items = getItemsById(id);
|
||||
let items = getItemsById(id);
|
||||
if(!items.length){
|
||||
items = getItemsById(sex+','+id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user