<?php
/** CLI: 唯一参数为站点根目录；仅修正点检异常菜单图标，不调整表结构、权限或业务数据。 */
if(PHP_SAPI!=='cli')exit;
$root=$argv[1]??'D:/phpstudy_pro/WWW/cqoms.com';require rtrim($root,'/\\').'/vendor/autoload.php';
$app=new \think\App(rtrim($root,'/\\').'/');$app->initialize();
$c=\think\facade\Db::connect()->getConfig();$p=$c['prefix'];
if(!preg_match('/^[a-zA-Z0-9_]*$/D',$p))throw new RuntimeException('Invalid prefix');
$table=$p.'admin_menus_wx';
$before=\think\facade\Db::query("SELECT id,title,icon FROM `$table` WHERE action=?",['checkIssue']);
if(!$before)throw new RuntimeException('点检异常记录菜单不存在，请先确认菜单安装情况');
\think\facade\Db::execute("UPDATE `$table` SET icon=? WHERE action=?",['info-circle','checkIssue']);
$after=\think\facade\Db::query("SELECT id,title,icon FROM `$table` WHERE action=?",['checkIssue']);
echo json_encode(['database'=>$c['database'],'applied'=>true,'before'=>$before,'after'=>$after],JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT),PHP_EOL;
