import { useState } from 'react'; import { Ionicons } from '@expo/vector-icons'; import { useRouter } from 'expo-router'; import { ActivityIndicator, KeyboardAvoidingView, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useKeywordBlock } from '../../../src/hooks'; import { colors } from '../../../src/theme'; /* ===================== 子组件:顶部导航 ===================== */ function Header({ onBack }: { onBack: () => void }) { return ( 关键词屏蔽 ); } /* ===================== 子组件:关键词标签 ===================== */ function KeywordChip({ text, onRemove, }: { text: string; onRemove: () => void; }) { return ( {text} ); } /* ===================== 页面 ===================== */ export default function KeywordBlockScreen() { const router = useRouter(); const { setting, loading, error, refresh, addKeyword, removeKeyword } = useKeywordBlock(); const [text, setText] = useState(''); const handleAdd = async () => { const value = text.trim(); if (!value) return; await addKeyword(value); setText(''); }; if (loading) { return (
router.back()} /> ); } if (error || !setting) { return (
router.back()} /> 加载失败,请重试 重试 ); } return (
router.back()} /> {setting.blockedCount} 累计拦截的招聘信息条数 已屏蔽关键词 {setting.keywords.length === 0 ? ( 暂无屏蔽词,添加后相关岗位与消息将被过滤 ) : ( {setting.keywords.map((word) => ( removeKeyword(word)} /> ))} )} {setting.suggestions.length > 0 ? ( 系统建议屏蔽 点击即可快速添加高频骚扰词 {setting.suggestions.map((word) => ( addKeyword(word)} > {word} ))} ) : null} 屏蔽关键词后,标题或详情包含该词的职位推荐与沟通消息将被隐藏,不影响你已投递的岗位。 添加 ); } const styles = StyleSheet.create({ safeArea: { flex: 1, backgroundColor: colors.pageBg, }, flex: { flex: 1, }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 8, height: 48, backgroundColor: colors.white, borderBottomWidth: 1, borderBottomColor: colors.borderLight, }, headerBtn: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center', }, headerTitle: { flex: 1, textAlign: 'center', fontSize: 17, fontWeight: '700', color: colors.textPrimary, }, scroll: { flex: 1, }, content: { padding: 8, paddingBottom: 16, }, stateBox: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 12, }, stateText: { marginTop: 12, fontSize: 14, color: colors.textSecondary, }, retryBtn: { marginTop: 16, paddingHorizontal: 24, paddingVertical: 8, borderRadius: 18, backgroundColor: colors.primaryBtn, }, retryText: { fontSize: 13, fontWeight: '600', color: colors.white, }, statCard: { borderRadius: 8, padding: 8, alignItems: 'center', marginBottom: 8, }, statValue: { fontSize: 32, fontWeight: '800', }, statLabel: { marginTop: 4, fontSize: 13, color: colors.textSecondary, }, card: { backgroundColor: colors.white, borderRadius: 8, padding: 8, marginBottom: 8, }, cardTitle: { fontSize: 15, fontWeight: '700', color: colors.textPrimary, marginBottom: 4, }, cardHint: { fontSize: 12, color: colors.textSecondary, marginBottom: 12, }, emptyText: { fontSize: 13, lineHeight: 19, color: colors.textSecondary, }, chipWrap: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginTop: 12, }, chip: { flexDirection: 'row', alignItems: 'center', backgroundColor: colors.dangerLight, borderRadius: 16, paddingVertical: 6, paddingHorizontal: 10, gap: 4, }, chipText: { fontSize: 13, fontWeight: '600', color: colors.dangerText, }, suggestChip: { flexDirection: 'row', alignItems: 'center', backgroundColor: colors.primaryLight, borderRadius: 16, paddingVertical: 6, paddingHorizontal: 10, gap: 2, }, suggestText: { fontSize: 13, fontWeight: '600', color: colors.primary, }, noteCard: { flexDirection: 'row', alignItems: 'flex-start', backgroundColor: colors.white, borderRadius: 8, padding: 8, gap: 8, }, noteText: { flex: 1, fontSize: 12, lineHeight: 18, color: colors.textSecondary, }, inputBar: { flexDirection: 'row', alignItems: 'center', gap: 8, paddingHorizontal: 12, paddingVertical: 10, backgroundColor: colors.white, borderTopWidth: 1, borderTopColor: colors.borderLight, }, input: { flex: 1, height: 40, borderRadius: 20, backgroundColor: colors.pageBg, paddingHorizontal: 16, fontSize: 14, color: colors.textPrimary, }, addBtn: { height: 40, paddingHorizontal: 20, borderRadius: 20, backgroundColor: colors.primaryBtn, alignItems: 'center', justifyContent: 'center', }, addBtnDisabled: { backgroundColor: colors.border, }, addBtnText: { fontSize: 14, fontWeight: '700', color: colors.white, }, });