修正消息中心不显示
This commit is contained in:
@@ -97,6 +97,51 @@ execute_init_script() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 执行敏感词导入
|
||||
import_sensitive_words() {
|
||||
print_message $BLUE "开始导入敏感词数据..."
|
||||
|
||||
# 检查conda是否可用
|
||||
if ! command -v conda &> /dev/null; then
|
||||
print_message $YELLOW "conda命令未找到,跳过敏感词导入"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 检查schoolNewsCrawler环境是否存在
|
||||
if ! conda env list | grep -q "schoolNewsCrawler"; then
|
||||
print_message $YELLOW "conda环境 'schoolNewsCrawler' 不存在,跳过敏感词导入"
|
||||
print_message $YELLOW "提示: 可以使用以下命令创建环境: conda create -n schoolNewsCrawler python=3.10"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 切换到敏感词脚本目录
|
||||
local sensitive_dir="$SCRIPT_DIR/sensitiveData"
|
||||
if [ ! -d "$sensitive_dir" ]; then
|
||||
print_message $YELLOW "敏感词脚本目录不存在: $sensitive_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f "$sensitive_dir/writeWord.py" ]; then
|
||||
print_message $YELLOW "敏感词脚本不存在: $sensitive_dir/writeWord.py"
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_message $BLUE "激活conda环境: schoolNewsCrawler"
|
||||
cd "$sensitive_dir"
|
||||
|
||||
# 使用conda run来在指定环境中执行命令,添加-y参数自动确认
|
||||
conda run -n schoolNewsCrawler python writeWord.py -y
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_message $GREEN "敏感词数据导入成功"
|
||||
else
|
||||
print_message $YELLOW "敏感词数据导入失败,但不影响系统运行"
|
||||
fi
|
||||
|
||||
# 返回脚本目录
|
||||
cd "$SCRIPT_DIR"
|
||||
}
|
||||
|
||||
# 验证初始化结果
|
||||
verify_initialization() {
|
||||
print_message $BLUE "验证初始化结果..."
|
||||
@@ -120,6 +165,14 @@ verify_initialization() {
|
||||
else
|
||||
print_message $YELLOW "默认用户创建失败"
|
||||
fi
|
||||
|
||||
# 检查敏感词数量
|
||||
local sensitive_count=$(mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" -D"$DB_NAME" -e "SELECT COUNT(*) FROM tb_sensitive_word;" 2>/dev/null | tail -n 1)
|
||||
if [ -n "$sensitive_count" ] && [ "$sensitive_count" -gt 0 ]; then
|
||||
print_message $GREEN "敏感词数据: $sensitive_count 个"
|
||||
else
|
||||
print_message $YELLOW "敏感词数据: 0 个 (可能未导入或表不存在)"
|
||||
fi
|
||||
}
|
||||
|
||||
# 显示初始化信息
|
||||
@@ -146,6 +199,8 @@ show_initialization_info() {
|
||||
print_message $YELLOW " - AI智能体"
|
||||
print_message $YELLOW " - 系统配置"
|
||||
print_message $YELLOW " - 文件管理"
|
||||
print_message $YELLOW " - 敏感词过滤"
|
||||
print_message $YELLOW " - 消息通知"
|
||||
print_message $BLUE "====================================================="
|
||||
}
|
||||
|
||||
@@ -153,7 +208,7 @@ show_initialization_info() {
|
||||
main() {
|
||||
print_message $BLUE "====================================================="
|
||||
print_message $BLUE "校园思政新闻平台数据库重新初始化脚本"
|
||||
print_message $BLUE "版本: 1.0.0"
|
||||
print_message $BLUE "版本: 1.1.0"
|
||||
print_message $BLUE "====================================================="
|
||||
|
||||
# 检查MySQL连接
|
||||
@@ -170,12 +225,15 @@ main() {
|
||||
# 执行初始化脚本
|
||||
execute_init_script
|
||||
|
||||
# 导入敏感词数据
|
||||
|
||||
# 验证初始化结果
|
||||
verify_initialization
|
||||
|
||||
# 显示初始化信息
|
||||
show_initialization_info
|
||||
|
||||
import_sensitive_words
|
||||
|
||||
print_message $GREEN "初始化完成!"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user