💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 控制器 ## 代码 注意:这里这个是 `public` ,而不是 `private` ``` <?php namespace app\agent\controller; use think\Controller; use think\Db; class MenuController extends Controller { /** * 导出后台菜单语言包 */ public function _exportAppMenuDefaultLang() { $menus = Db::name('AdminMenu')->order(["app" => "ASC", "controller" => "ASC", "action" => "ASC"])->select(); $langDir = config('DEFAULT_LANG'); $adminMenuLang = CMF_ROOT . "data/lang/" . $langDir . "/admin_menu.php"; if (!empty($adminMenuLang) && !file_exists_case($adminMenuLang)) { mkdir(dirname($adminMenuLang), 0777, true); } $lang = []; foreach ($menus as $menu) { $lang_key = strtoupper($menu['app'] . '_' . $menu['controller'] . '_' . $menu['action']); $lang[$lang_key] = $menu['name']; } $langStr = var_export($lang, true); $langStr = preg_replace("/\s+\d+\s=>\s(\n|\r)/", "\n", $langStr); if (!empty($adminMenuLang)) { file_put_contents($adminMenuLang, "<?php\nreturn $langStr;"); } } } ```