From 517b321a663296a82664be0798dd9eec9dde676a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=B0=8F=E7=99=BD?= <271301671@qq.com> Date: Sat, 25 May 2024 20:19:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=A4=9A=E8=AF=AD=E8=A8=80=E8=AE=BE=E7=BD=AEAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/SettingController.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/vendor/thinkcmf/cmf-api/src/admin/controller/SettingController.php b/vendor/thinkcmf/cmf-api/src/admin/controller/SettingController.php index dc112b6f1..46036f21c 100644 --- a/vendor/thinkcmf/cmf-api/src/admin/controller/SettingController.php +++ b/vendor/thinkcmf/cmf-api/src/admin/controller/SettingController.php @@ -328,6 +328,57 @@ class SettingController extends RestAdminBaseController $this->success(lang('EDIT_SUCCESS')); } + /** + * 多语言设置 + * @throws \think\exception\DbException + * @OA\Get( + * tags={"admin"}, + * path="/admin/setting/lang", + * summary="多语言设置", + * description="多语言设置", + * @OA\Response( + * response="1", + * @OA\JsonContent(example={"code": 1,"msg": "success","data":{ + * "lang_setting":{} + * } + * }) + * ), + * @OA\Response( + * response="0", + * @OA\JsonContent(example={"code": 0,"msg": "error!","data": ""}) + * ), + * ) + */ + public function lang() + { + $langSetting = cmf_get_option('lang_setting'); + if (empty($langSetting)) { + $app = app(); + $langConfig = $app->lang->getConfig(); + $defaultLang = $app->lang->defaultLangSet(); + $adminDefaultLang = empty($langConfig['admin_default_lang']) ? 'zh-cn' : $langConfig['admin_default_lang']; + $langSetting = [ + 'multi_lang_mode' => 1, + 'home_multi_lang' => 0, + 'default_lang' => $defaultLang, + 'allow_lang_list' => [[ + 'lang' => $defaultLang, + 'alias' => '', + 'domain' => '', + ]], + 'admin_multi_lang' => 0, + 'admin_default_lang' => $adminDefaultLang, + 'admin_allow_lang_list' => [[ + 'lang' => $adminDefaultLang, + ]] + ]; + + + } + $this->success('success', ['lang_setting' => $langSetting]); + } + + /** * 多语言设置提交保存 * @throws \think\exception\DbException -- Gitee