更新前端相关
This commit is contained in:
@@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user