多语言
This commit is contained in:
@@ -67,18 +67,26 @@ class RuleController extends Crud
|
||||
*/
|
||||
function get(Request $request): Response
|
||||
{
|
||||
// 添加调试日志
|
||||
error_log("RuleController::get called");
|
||||
|
||||
$rules = $this->getRules(admin('roles'));
|
||||
$types = $request->get('type', '0,1');
|
||||
$types = is_string($types) ? explode(',', $types) : [0, 1];
|
||||
$items = Rule::orderBy('weight', 'desc')->get()->toArray();
|
||||
|
||||
$items = Rule::orderBy('weight', 'desc')->get();
|
||||
|
||||
// 获取当前语言
|
||||
$lang = session('lang', 'zh-cn');
|
||||
|
||||
$formatted_items = [];
|
||||
foreach ($items as $item) {
|
||||
$item['pid'] = (int)$item['pid'];
|
||||
$item['name'] = $item['title'];
|
||||
$item['value'] = $item['id'];
|
||||
$item['icon'] = $item['icon'] ? "layui-icon {$item['icon']}" : '';
|
||||
$formatted_items[] = $item;
|
||||
$item_array = $item->toArray();
|
||||
$item_array['pid'] = (int)$item_array['pid'];
|
||||
$item_array['name'] = $item->getTranslatedTitle($lang);
|
||||
$item_array['title'] = $item->getTranslatedTitle($lang);
|
||||
$item_array['value'] = $item_array['id'];
|
||||
$item_array['icon'] = $item_array['icon'] ? "layui-icon {$item_array['icon']}" : '';
|
||||
$formatted_items[] = $item_array;
|
||||
}
|
||||
|
||||
$tree = new Tree($formatted_items);
|
||||
@@ -89,6 +97,10 @@ class RuleController extends Crud
|
||||
}
|
||||
$this->removeNotContain($tree_items, 'type', $types);
|
||||
$menus = $this->empty_filter(Tree::arrayValues($tree_items));
|
||||
|
||||
// 添加调试日志
|
||||
error_log("RuleController::get returning menus: " . json_encode($menus));
|
||||
|
||||
return $this->json(0, 'ok', $menus);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user