本文整理汇总了TypeScript中idx.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: idx
const filteredAssociations = R.pickBy(field => {
const loaded = idx(field, _ => _.associations[field.name]) as any;
if (loaded) {
return idx(loaded, _ => _.existItems.length) != idx(field, _ => _.value.length);
}
return true;
})(associations);
开发者ID:danielwii,项目名称:asuna-admin,代码行数:7,代码来源:async.ts
示例2: rehydrateWatcher
/**
* 恢复 store 时跳转到主页面
* @param action
*/
function* rehydrateWatcher(action) {
logger.log('[rehydrateWatcher]', action);
yield put(appActions.restored());
const token = idx(action, _ => _.payload.auth.token);
const path = idx(action, _ => _.payload.router.path);
logger.log('[rehydrateWatcher]', !!token, path);
if (token) {
yield put(routerActions.toIndex());
}
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:14,代码来源:app.redux.ts
示例3: tokenWatcher
/**
* 未找到可用 token 时重定向到登录页面
*/
function* tokenWatcher(action) {
const {
auth: { token },
router: { path },
} = yield select((state: RootState) => ({ auth: state.auth, router: state.router }));
// restored will be handled later at yield take(appActionTypes.RESTORED), simply ignore here
if ([appActionTypes.RESTORED].includes(action.type)) {
return;
}
if (action.type === REHYDRATE) {
logger.log('[tokenWatcher]', 'REHYDRATE found, wait to restore...');
const restoredAction = yield take(appActionTypes.RESTORED);
logger.log('[tokenWatcher]', 'waiting for app restored', restoredAction);
if (!idx(restoredAction, _ => _.payload.auth.token)) {
yield put(routerActions.toLogin());
}
} else if (action.type === authActionTypes.LOGOUT) {
logger.log('[tokenWatcher]', 'logout...');
yield put(routerActions.toLogin());
} else if (!token && path !== '/login') {
logger.log('[tokenWatcher]', 'no token found and path is not login, goto login');
yield put(routerActions.toLogin());
} else if (!path) {
logger.warn('[tokenWatcher]', 'no path found, redirect to login...');
yield put(routerActions.toLogin());
}
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:auth.redux.ts
示例4: toErrorMessage
export function toErrorMessage(e) {
if (e.response) {
return idx(e, _ => _.response.data.message);
}
return e.message;
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:6,代码来源:error.ts
示例5: castModelName
export const enumDecorator = ({
modelName,
fields,
}: {
modelName: string;
fields: (Fields & WithHidden) | PositionsField | EnumField;
}): { modelName; fields: (Fields & WithHidden) | PositionsField | EnumField } => {
const TAG = '[enumDecorator]';
logger.log(TAG, { fields });
const enumFilterFields = R.filter(R.propEq('type', DynamicFormTypes.EnumFilter))(fields);
if (R.not(R.isEmpty(enumFilterFields))) {
const [, enumFilterField] = R.toPairs(enumFilterFields)[0];
logger.debug(TAG, { enumFilterField });
const enums = _.map(
_.keys(idx(enumFilterField as EnumField, _ => _.options.enumData)),
castModelName,
);
const current = castModelName(R.pathOr('', ['value'])(enumFilterField));
logger.debug(TAG, { enums, current });
// check if positions has value already
// save positions value if no value exists, update models' sequence for else
const positionsFieldPair = R.compose(
R.toPairs,
R.map(field => {
// raw is the original value, if exists, means it's update request
if (field.value && !field.raw) {
const value = R.is(String, field.value) ? JSON.parse(field.value) : field.value;
return { ...field, value, raw: field.value };
}
return { ...field, value: R.path([current, 'value'])(fields), raw: field.value };
}),
R.filter(R.pathEq(['options', 'type'], 'SortPosition')),
)(fields);
const filteredNames = R.without(current)(enums);
const filteredFields = R.omit(filteredNames)(fields);
const wrappedFields = current
? R.mergeDeepRight(filteredFields, {
[current]: {
isFilterField: true,
options: { filterType: R.path(['options', 'filterType'])(enumFilterField) },
value: R.isEmpty(positionsFieldPair)
? R.path([current, 'value'])(filteredFields)
: R.path([0, 1, 'value'])(positionsFieldPair),
},
...R.fromPairs(positionsFieldPair),
})
: filteredFields;
logger.debug(TAG, 'wrappedFields', {
current,
filteredNames,
filteredFields,
wrappedFields,
positionsFieldPair,
});
return { modelName, fields: wrappedFields };
}
return { modelName, fields };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:65,代码来源:index.ts
注:本文中的idx.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论