1, 'default_navigation'=>0 ])->find(); if(!$data){ $data = self::where([ 'default_navigation'=>1 ])->find(); } if(!$data){ return false; } $data = $data->toArray(); $data['config'] = json_decode($data['config'],true); $data = $this->oldIndexToNew($data); Cache::set(\app\common\constant\cache\Keys::PAGE_NAVIGATION,$data); return $data; } /** * 旧路由地址换成新的 * @param $arr * @return mixed */ public function oldIndexToNew($arr){ foreach ($arr as &$item){ if(is_array($item)){ $item = $this->oldIndexToNew($item); }elseif(is_string($item)){ $item = str_replace("pages/public/diy/diy","pages/index/index",$item); } } return $arr; } }