更新blog界面

This commit is contained in:
2026-03-20 20:35:00 +08:00
parent b3a25ceb82
commit d30a2531a7
7 changed files with 87 additions and 94 deletions
@@ -5,14 +5,14 @@ declare(strict_types=1);
namespace app\index\controller\Article;
use app\index\BaseController;
use app\model\Articles;
use app\model\ArticlesCategory;
use Symfony\Component\VarDumper\VarDumper;
use think\exception\ValidateException;
use think\facade\Request;
use think\facade\Session;
use think\response\Json;
use think\db\exception\DbException;
use app\model\Cms\Articles;
use app\model\Cms\ArticlesCategory;
class ArticleController extends BaseController
{
@@ -102,6 +102,34 @@ class ArticleController extends BaseController
}
}
/**
* 获取文章分类列表
* @return Json
*/
public function getArticleCategories(): Json
{
$tid = $this->getTenantId();
if (empty($tid)) {
return json([
'code' => 400,
'msg' => '无法识别租户信息',
'list' => [],
]);
}
$articleCategories = ArticlesCategory::where('delete_time', null)
->where('tid', $tid)
->select()
->toArray();
return json([
'code' => 200,
'msg' => 'success',
'list' => $articleCategories,
]);
}
/**
* 游客文章阅读量函数
* @return Json
+3
View File
@@ -27,6 +27,9 @@ Route::get('homeData', 'app\index\controller\Index@getHomeData');
// --- 新闻中心列表路由 ---
Route::get('getCenterNews', 'app\index\controller\Article\NewsCenterController@getCenterNews');
// --- 文章分类路由 ---
Route::get('getArticleCategories', 'app\index\controller\Article\ArticleController@getArticleCategories');
// --- 新闻中心互动路由 ---
Route::post('articleViews/:id', 'app\index\controller\Article\ArticleController@articleViews');
Route::post('articleLikes/:id', 'app\index\controller\Article\ArticleController@articleLikes');