更新前端相关

This commit is contained in:
扫地僧 2026-02-06 00:06:11 +08:00
parent a32b1656b0
commit 776aacfa2e
6 changed files with 55 additions and 25 deletions

View File

@ -8,7 +8,7 @@ use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use think\response\Json;
use app\model\SystemSiteSettings;
use app\model\System\SystemSiteSettings;
class SiteSettingsController extends BaseController
{
@ -19,7 +19,7 @@ class SiteSettingsController extends BaseController
public function getNormalInfos()
{
$siteSettings = SystemSiteSettings::where('delete_time', null)
->field('id, label, value, sort')
->field('id, label, value, sort')
->order('id', 'asc')
->select();
return json([
@ -69,11 +69,11 @@ class SiteSettingsController extends BaseController
$allSettings = SystemSiteSettings::column('value', 'label');
$allSettings['type'] = 'normal';
$labels = array_column($data, 'label');
$userInfo = $this->getAdminUserInfo();
$this->logSuccess('站点设置管理', '保存基本信息', ['labels' => $labels], $userInfo);
return json([
'code' => 200,
'msg' => '保存成功',
@ -88,7 +88,7 @@ class SiteSettingsController extends BaseController
public function getLegalInfos()
{
$siteSettings = SystemSiteSettings::where('delete_time', null)
->field('id, label, value, sort')
->field('id, label, value, sort')
->order('id', 'asc')
->select();
return json([
@ -139,19 +139,19 @@ class SiteSettingsController extends BaseController
$allSettings = SystemSiteSettings::column('value', 'label');
$allSettings['type'] = 'legal_notice';
$labels = array_column($data, 'label');
$userId = Session::get('user_id', 0);
$userFromSession = Session::get('user', []);
$userFromCache = Cache::get('userInfo_' . $userId, []);
$account = Session::get('account', '');
$name = Session::get('name', '');
\think\facade\Log::record('SiteSettings Debug - user_id: ' . $userId . ', userFromSession: ' . json_encode($userFromSession) . ', userFromCache: ' . json_encode($userFromCache) . ', account: ' . $account . ', name: ' . $name);
$this->logSuccess('站点设置管理', '保存法律声明和隐私条款', ['labels' => $labels]);
return json([
'code' => 200,
'msg' => '保存成功',

View File

@ -10,6 +10,7 @@ use app\model\FrontMenu;
use app\model\OnePage;
use think\db\exception\DbException;
use think\facade\Env;
use app\model\System\SystemSiteSettings;
class Index extends BaseController
{
@ -30,7 +31,7 @@ class Index extends BaseController
$files = glob($logPath . '*.log');
if ($files) {
// 按修改时间排序,最新的在前
usort($files, function($a, $b) {
usort($files, function ($a, $b) {
return filemtime($b) - filemtime($a);
});
@ -39,7 +40,7 @@ class Index extends BaseController
if (file_exists($latestFile)) {
$content = file_get_contents($latestFile);
$lines = explode("\n", $content);
// 倒序遍历只取最近的100条
$count = 0;
for ($i = count($lines) - 1; $i >= 0 && $count < 100; $i--) {
@ -48,7 +49,7 @@ class Index extends BaseController
$count++;
}
}
// 再倒序回来,使最新的日志在最后
$logs = array_reverse($logs);
}
@ -138,15 +139,15 @@ class Index extends BaseController
$requestPath = $this->request->pathinfo();
$path = str_replace('onepage/', '', $requestPath);
}
// 确保路径以 / 开头
if (empty($path) || $path[0] !== '/') {
$path = '/' . $path;
}
// 解码路径
$path = urldecode($path);
// 查找对应路径的单页
$onePage = OnePage::where('path', $path)
->where('status', 1)
@ -174,4 +175,30 @@ class Index extends BaseController
]);
}
}
/**
* 前端底部数据
* @return \think\response\Json
*/
public function getFooterData()
{
try {
$footerData = SystemSiteSettings::where('delete_time', null)
->field('label, value')
->select()
->toArray();
return json([
'code' => 200,
'msg' => 'success',
'data' => $footerData
]);
} catch (DbException $e) {
return json([
'code' => 500,
'msg' => 'fail' . $e->getMessage(),
'data' => null
]);
}
}
}

View File

@ -5,6 +5,9 @@ use think\facade\Route;
Route::get('/', 'app\index\controller\Index@index');
Route::get('index/index', 'app\index\controller\Index@index');
// --- 前端底部数据路由 ---
Route::get('footerdata', 'app\index\controller\Index@getFooterData');
// --- 文章详情路由 ---
Route::get('kingdeenews/detail/:id', 'app\index\controller\Article\NewsCenterController@getKingdeeNewsDetail');
Route::get('companynews/detail/:id', 'app\index\controller\Article\NewsCenterController@getCompanyNewsDetail');

View File

@ -9,28 +9,28 @@
// | Author: Liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace app\model;
namespace app\model\System;
use think\Model;
use think\model\concern\SoftDelete;
/**
* 文章分类模型
* 站点设置模型
*/
class SystemSiteSettings extends Model
{
// 启用软删除
use SoftDelete;
// 数据库表名
protected $name = 'mete_system_site_settings';
// 字段类型转换
protected $type = [
'id' => 'integer',
'label' => 'string',
'value' => 'string',
'sort' => 'integer',
'remark' => 'string',
'id' => 'integer',
'label' => 'string',
'value' => 'string',
'sort' => 'integer',
'remark' => 'string',
];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB