多语言
This commit is contained in:
@@ -4,6 +4,7 @@ namespace plugin\admin\app\controller;
|
||||
|
||||
use plugin\admin\app\common\Util;
|
||||
use plugin\admin\app\model\Option;
|
||||
use plugin\admin\app\model\Rule;
|
||||
use plugin\admin\app\model\User;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
@@ -48,7 +49,26 @@ class IndexController
|
||||
$logo = $config['logo']['image'] ?? '/app/admin/admin/images/logo.png';
|
||||
return raw_view('account/login',['logo'=>$logo,'title'=>$title]);
|
||||
}
|
||||
return raw_view('index/index');
|
||||
// 获取当前语言
|
||||
$lang = session('lang', 'zh-cn');
|
||||
|
||||
// 加载语言文件
|
||||
$common_translations = include __DIR__ . "/../lang/{$lang}/common.php";
|
||||
|
||||
// 获取菜单并应用翻译
|
||||
$rules = Rule::whereIn('type', [0, 1])->orderBy('weight')->get();
|
||||
$menus = [];
|
||||
foreach ($rules as $rule) {
|
||||
$menu = $rule->toArray();
|
||||
$menu['title'] = $rule->getTranslatedTitle($lang);
|
||||
$menus[] = $menu;
|
||||
}
|
||||
|
||||
return view('index/index', [
|
||||
'lang' => $lang,
|
||||
'translations' => $common_translations,
|
||||
'menus' => $menus
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user