From 1f140121fb5caeadce6aaccfa9a378c90b489485 Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sun, 26 Oct 2025 19:12:13 +0800 Subject: [PATCH] handle duplicate static combine conditions --- .../combineCalculator.mjs | 22 +++++++++- .../index.vue | 44 ++++++++++++++++++- .../GeekAutoStartChatWithBoss/index.vue | 10 +++-- 3 files changed, 68 insertions(+), 8 deletions(-) diff --git a/packages/geek-auto-start-chat-with-boss/combineCalculator.mjs b/packages/geek-auto-start-chat-with-boss/combineCalculator.mjs index f379072..a9f3169 100644 --- a/packages/geek-auto-start-chat-with-boss/combineCalculator.mjs +++ b/packages/geek-auto-start-chat-with-boss/combineCalculator.mjs @@ -125,8 +125,26 @@ export function checkAnyCombineBossRecommendFilterHasCondition(value) { }) } -export function formatStaticCombineFilters(staticCombineRecommendJobFilterConditions) { - const result = staticCombineRecommendJobFilterConditions.map((condition) => { +export function getStaticCombineFilterKey(condition) { + const kAsO = {} + for (const key of Object.keys(condition ?? []).sort()) { + if (condition[key] === null || condition[key] === undefined) { + continue + } + kAsO[key] = condition[key] + } + return JSON.stringify(kAsO) +} + +export function formatStaticCombineFilters(rawStaticCombineRecommendJobFilterConditions) { + rawStaticCombineRecommendJobFilterConditions = JSON.parse(JSON.stringify(rawStaticCombineRecommendJobFilterConditions)) + const map = new Map() + for (const condition of rawStaticCombineRecommendJobFilterConditions ?? []) { + const key = getStaticCombineFilterKey(condition) + map.set(key, condition) + } + const conditions = Array.from(map.values()) + const result = conditions.map((condition) => { return { salaryList: condition.salary ? [condition.salary] : [], experienceList: condition.experience ? [condition.experience] : [], diff --git a/packages/ui/src/renderer/src/features/StaticCombineBossRecommendFilter/index.vue b/packages/ui/src/renderer/src/features/StaticCombineBossRecommendFilter/index.vue index f28b135..1533584 100644 --- a/packages/ui/src/renderer/src/features/StaticCombineBossRecommendFilter/index.vue +++ b/packages/ui/src/renderer/src/features/StaticCombineBossRecommendFilter/index.vue @@ -4,7 +4,22 @@ >添加条件
- + @@ -156,7 +182,9 @@ import conditions from '@geekgeekrun/geek-auto-start-chat-with-boss/internal-config/job-filter-conditions-20241002.json' import industryFilterExemption from '@geekgeekrun/geek-auto-start-chat-with-boss/internal-config/job-filter-industry-filter-exemption-20241002.json' import { ArrowUp, ArrowDown, Delete, Plus } from '@element-plus/icons-vue' -import { PropType } from 'vue' +import { computed, PropType } from 'vue' + +import { getStaticCombineFilterKey } from '@geekgeekrun/geek-auto-start-chat-with-boss/combineCalculator.mjs' const props = defineProps({ modelValue: { @@ -210,6 +238,18 @@ function removeCondition(index) { props.modelValue?.splice(index, 1) // gtagRenderer('resume_work_exp_removed') } +const duplicatedMap = computed(() => { + const map = new Map() + for (const condition of props.modelValue ?? []) { + const key = getStaticCombineFilterKey(condition) + if (!map.has(key)) { + map.set(key, []) + } + const arr = map.get(key) + arr.push(condition) + } + return map +})