feat: add log

This commit is contained in:
eleanor.mao 2025-04-19 22:33:22 +08:00
parent f86b4481d8
commit 744928fab7
2 changed files with 19 additions and 15 deletions

View File

@ -12,8 +12,8 @@ import { EmployType, EMPLOY_TYPE_TITLE_MAP, FULL_PRICE_OPTIONS, PART_PRICE_OPTIO
import { SalaryRange } from '@/types/job'; import { SalaryRange } from '@/types/job';
import { MaterialProfile } from '@/types/material'; import { MaterialProfile } from '@/types/material';
import { logWithPrefix } from '@/utils/common'; import { logWithPrefix } from '@/utils/common';
import { getCurrentCity } from '@/utils/location';
import { isFullTimePriceRequired, isPartTimePriceRequired } from '@/utils/job' import { isFullTimePriceRequired, isPartTimePriceRequired } from '@/utils/job'
import { getCurrentCity } from '@/utils/location';
import { navigateTo } from '@/utils/route'; import { navigateTo } from '@/utils/route';
import './index.less'; import './index.less';
@ -24,7 +24,8 @@ interface IProps {
const PREFIX = 'fragment-profile-intention'; const PREFIX = 'fragment-profile-intention';
const log = logWithPrefix(PREFIX); const log = logWithPrefix(PREFIX);
const realtimeLogger = Taro.getRealtimeLogManager();
realtimeLogger.tag(PREFIX);
const calcInitCityCodes = (codeString: string = '') => { const calcInitCityCodes = (codeString: string = '') => {
const codes = codeString.split('、'); const codes = codeString.split('、');
return codes.filter(code => !!CITY_CODE_TO_NAME_MAP.get(code)); return codes.filter(code => !!CITY_CODE_TO_NAME_MAP.get(code));
@ -82,6 +83,7 @@ function ProfileIntentionFragment(props: IProps, ref) {
const handleSelectCity = useCallback( const handleSelectCity = useCallback(
data => { data => {
log('handleSelectCity', data); log('handleSelectCity', data);
realtimeLogger.info('handleSelectCity', data);
const { openSource, cityCode: code } = data; const { openSource, cityCode: code } = data;
if (openSource !== OpenSource.AddIndentCity) { if (openSource !== OpenSource.AddIndentCity) {
return; return;

View File

@ -11,6 +11,7 @@ import ProfileAdvantagesFragment from '@/fragments/profile/advantages';
import ProfileBasicFragment from '@/fragments/profile/basic'; import ProfileBasicFragment from '@/fragments/profile/basic';
import ProfileExperienceFragment from '@/fragments/profile/experience'; import ProfileExperienceFragment from '@/fragments/profile/experience';
import ProfileIntentionFragment from '@/fragments/profile/intention'; import ProfileIntentionFragment from '@/fragments/profile/intention';
import useLocation from '@/hooks/use-location';
import { MaterialProfile } from '@/types/material'; import { MaterialProfile } from '@/types/material';
import { logWithPrefix } from '@/utils/common'; import { logWithPrefix } from '@/utils/common';
import { collectEvent } from '@/utils/event'; import { collectEvent } from '@/utils/event';
@ -18,7 +19,6 @@ import { isFullTimePriceRequired, isPartTimePriceRequired } from '@/utils/job';
import { updateProfile, subscribeMaterialMessage } from '@/utils/material'; import { updateProfile, subscribeMaterialMessage } from '@/utils/material';
import { navigateBack } from '@/utils/route'; import { navigateBack } from '@/utils/route';
import Toast from '@/utils/toast'; import Toast from '@/utils/toast';
import useLocation from '@/hooks/use-location';
import './index.less'; import './index.less';
@ -42,12 +42,12 @@ const REQUIRE_KEYS = {
const CONDITIONAL_REQUIRED_KEYS = { const CONDITIONAL_REQUIRED_KEYS = {
[ProfileGroupType.Intention]: [ [ProfileGroupType.Intention]: [
['fullTimeMinPrice', (data) => isFullTimePriceRequired(data.employType)], ['fullTimeMinPrice', data => isFullTimePriceRequired(data.employType)],
['fullTimeMaxPrice', (data) => isFullTimePriceRequired(data.employType)], ['fullTimeMaxPrice', data => isFullTimePriceRequired(data.employType)],
['partyTimeMinPrice', (data) => isPartTimePriceRequired(data.employType)], ['partyTimeMinPrice', data => isPartTimePriceRequired(data.employType)],
['partyTimeMaxPrice', (data) => isPartTimePriceRequired(data.employType)], ['partyTimeMaxPrice', data => isPartTimePriceRequired(data.employType)],
], ],
} };
const getNextStepGroupType = (curType: ProfileGroupType) => { const getNextStepGroupType = (curType: ProfileGroupType) => {
switch (curType) { switch (curType) {
@ -62,15 +62,17 @@ const getNextStepGroupType = (curType: ProfileGroupType) => {
} }
}; };
const isValidFormData = (type: ProfileGroupType, data: Partial<MaterialProfile>) => { const isValidFormData = (type: ProfileGroupType, data: Partial<MaterialProfile>) => {
const requireKeys = REQUIRE_KEYS[type] || []; const requireKeys = REQUIRE_KEYS[type] || [];
const conditionalKeys = CONDITIONAL_REQUIRED_KEYS[type] || [] const conditionalKeys = CONDITIONAL_REQUIRED_KEYS[type] || [];
const requiredValidator = (key: any) => typeof data[key] !== 'undefined' && data[key] !== '' const requiredValidator = (key: any) => typeof data[key] !== 'undefined' && data[key] !== '';
return requireKeys.every(requiredValidator) && conditionalKeys.every(([key, validator]) => { return (
return !validator(data) || requiredValidator(key) requireKeys.every(requiredValidator) &&
}); conditionalKeys.every(([key, validator]) => {
return !validator(data) || requiredValidator(key);
})
);
}; };
export default function MaterialCreateProfile() { export default function MaterialCreateProfile() {
@ -123,7 +125,7 @@ export default function MaterialCreateProfile() {
return ( return (
<div className={PREFIX}> <div className={PREFIX}>
<ProfileFragment ref={ref} profile={{cityCodes: location.cityCode || '' }} /> <ProfileFragment ref={ref} profile={{ cityCodes: location.cityCode || '' }} />
<SafeBottomPadding /> <SafeBottomPadding />
<div className={`${PREFIX}__footer`}> <div className={`${PREFIX}__footer`}>
<Button className={`${PREFIX}__submit-btn`} onClick={handleSubmit}> <Button className={`${PREFIX}__submit-btn`} onClick={handleSubmit}>