diff --git a/admin/src/views/match/league/index.vue b/admin/src/views/match/league/index.vue
index b12fdcb..badc12a 100644
--- a/admin/src/views/match/league/index.vue
+++ b/admin/src/views/match/league/index.vue
@@ -40,6 +40,14 @@
:inactive-value="0" @change="handleToggleShow(row)" />
+
+
+
+ -
+
+
@@ -68,6 +76,9 @@
+
+
+
取消
@@ -120,17 +131,34 @@ const editData = reactive({
type: '',
icon: '',
sort: 0,
- is_show: 1
+ is_show: 1,
+ is_hot: 0
})
const handleEdit = (row: any) => {
- Object.assign(editData, { id: row.id, label: row.label, type: row.type, icon: row.icon || '', sort: row.sort, is_show: row.is_show })
+ Object.assign(editData, {
+ id: row.id,
+ label: row.label,
+ type: row.type,
+ icon: row.icon || '',
+ sort: row.sort,
+ is_show: row.is_show,
+ is_hot: row.is_hot || 0
+ })
showEdit.value = true
}
const handleToggleShow = async (row: any) => {
try {
- await leagueEdit({ id: row.id, label: row.label, sort: row.sort, is_show: row.is_show })
+ await leagueEdit({ id: row.id, is_show: row.is_show })
+ } catch (error) {
+ getLists()
+ }
+}
+
+const handleToggleHot = async (row: any) => {
+ try {
+ await leagueEdit({ id: row.id, is_hot: row.is_hot })
} catch (error) {
getLists()
}
diff --git a/docs/sql/alter_la_league_add_is_hot.sql b/docs/sql/alter_la_league_add_is_hot.sql
new file mode 100644
index 0000000..0add514
--- /dev/null
+++ b/docs/sql/alter_la_league_add_is_hot.sql
@@ -0,0 +1,17 @@
+-- 联赛管理增加“热门联赛”配置字段,可重复执行。
+SET @schema_name = DATABASE();
+SET @has_is_hot = (
+ SELECT COUNT(*)
+ FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @schema_name
+ AND TABLE_NAME = 'la_league'
+ AND COLUMN_NAME = 'is_hot'
+);
+SET @alter_sql = IF(
+ @has_is_hot = 0,
+ 'ALTER TABLE `la_league` ADD COLUMN `is_hot` tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''是否热门联赛: 0=否 1=是'' AFTER `is_show`',
+ 'SELECT ''la_league.is_hot already exists'''
+);
+PREPARE alter_stmt FROM @alter_sql;
+EXECUTE alter_stmt;
+DEALLOCATE PREPARE alter_stmt;
diff --git a/docs/sql/create_la_league.sql b/docs/sql/create_la_league.sql
index 9034b3b..053ec3e 100644
--- a/docs/sql/create_la_league.sql
+++ b/docs/sql/create_la_league.sql
@@ -16,6 +16,7 @@ CREATE TABLE `la_league` (
`icon` varchar(500) NOT NULL DEFAULT '' COMMENT '联赛图标 URL',
`sort` int NOT NULL DEFAULT 0 COMMENT '排序权重(越小越靠前)',
`is_show` tinyint unsigned NOT NULL DEFAULT 1 COMMENT '是否显示: 0=隐藏 1=显示',
+ `is_hot` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '是否热门联赛: 0=否 1=是',
`extra_data` json DEFAULT NULL COMMENT '额外数据(如 calendar 等)',
`create_time` int unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int unsigned NOT NULL DEFAULT 0 COMMENT '更新时间',
diff --git a/sbnews.sql b/sbnews.sql
index 1062ffb..4029d4e 100644
--- a/sbnews.sql
+++ b/sbnews.sql
@@ -796,6 +796,7 @@ CREATE TABLE `la_league` (
`icon` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`sort` int NOT NULL DEFAULT 0 COMMENT '排序权重(越小越靠前)',
`is_show` tinyint UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否显示: 0=隐藏 1=显示',
+ `is_hot` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否热门联赛: 0=否 1=是',
`extra_data` json NULL COMMENT '额外数据(如 calendar 等)',
`sessionid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Session ID',
`create_time` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
diff --git a/server/app/adminapi/lists/match/LeagueLists.php b/server/app/adminapi/lists/match/LeagueLists.php
index 963b8ab..9cc17a2 100644
--- a/server/app/adminapi/lists/match/LeagueLists.php
+++ b/server/app/adminapi/lists/match/LeagueLists.php
@@ -59,6 +59,7 @@ class LeagueLists extends BaseAdminDataLists implements ListsSearchInterface
'icon' => $sport['icon'] ?? '',
'sort' => $sport['sort'],
'is_show' => $sport['is_show'],
+ 'is_hot' => 0,
'is_group' => true,
'children' => $children,
];
@@ -86,6 +87,7 @@ class LeagueLists extends BaseAdminDataLists implements ListsSearchInterface
'icon' => '',
'sort' => '',
'is_show' => '',
+ 'is_hot' => '',
'is_group' => true,
'children' => $orphans,
];
diff --git a/server/app/adminapi/logic/match/LeagueLogic.php b/server/app/adminapi/logic/match/LeagueLogic.php
index 5086ffb..7227745 100644
--- a/server/app/adminapi/logic/match/LeagueLogic.php
+++ b/server/app/adminapi/logic/match/LeagueLogic.php
@@ -15,13 +15,24 @@ class LeagueLogic extends BaseLogic
public static function edit(array $params): bool
{
try {
- League::update([
- 'id' => $params['id'],
- 'label' => $params['label'],
- 'icon' => $params['icon'] ?? '',
- 'sort' => $params['sort'] ?? 0,
- 'is_show' => $params['is_show'] ?? 1,
- ]);
+ $league = League::findOrEmpty($params['id']);
+ if ($league->isEmpty()) {
+ self::setError('联赛不存在');
+ return false;
+ }
+
+ $data = [];
+ foreach (['label', 'icon', 'sort', 'is_show'] as $field) {
+ if (array_key_exists($field, $params)) {
+ $data[$field] = $params[$field];
+ }
+ }
+ if (array_key_exists('is_hot', $params)) {
+ $data['is_hot'] = $league->type === 'league' ? (int)$params['is_hot'] : 0;
+ }
+ if (!empty($data)) {
+ $league->save($data);
+ }
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
diff --git a/server/app/adminapi/validate/match/LeagueValidate.php b/server/app/adminapi/validate/match/LeagueValidate.php
index 977ad69..0c4b227 100644
--- a/server/app/adminapi/validate/match/LeagueValidate.php
+++ b/server/app/adminapi/validate/match/LeagueValidate.php
@@ -8,10 +8,12 @@ class LeagueValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
+ 'is_hot' => 'in:0,1',
];
protected $message = [
'id.require' => '联赛id不能为空',
+ 'is_hot.in' => '热门联赛状态值错误',
];
public function sceneDetail()
@@ -21,7 +23,7 @@ class LeagueValidate extends BaseValidate
public function sceneEdit()
{
- return $this->only(['id']);
+ return $this->only(['id', 'is_hot']);
}
public function sceneDelete()
diff --git a/server/app/api/controller/MatchController.php b/server/app/api/controller/MatchController.php
index e9373fd..8f1d2a1 100644
--- a/server/app/api/controller/MatchController.php
+++ b/server/app/api/controller/MatchController.php
@@ -52,7 +52,8 @@ class MatchController extends BaseApiController
if ($sportType > 0) {
$query->where('sport_type', $sportType);
}
- $leagues = $query->field('id, label, sport_type, icon, sort')
+ $leagues = $query->field('id, label, sport_type, icon, sort, is_hot')
+ ->order('is_hot desc')
->order('sort asc')
->select()
->toArray();
@@ -82,6 +83,7 @@ class MatchController extends BaseApiController
'id' => $item['id'],
'league_name' => $item['label'],
'icon' => $item['icon'],
+ 'is_hot' => (int)$item['is_hot'],
'count' => $counts[$item['label']] ?? 0,
];
}
diff --git a/uniapp/src/packages_match/components/MatchCenterPanel.vue b/uniapp/src/packages_match/components/MatchCenterPanel.vue
index ab83e60..728056d 100644
--- a/uniapp/src/packages_match/components/MatchCenterPanel.vue
+++ b/uniapp/src/packages_match/components/MatchCenterPanel.vue
@@ -9,22 +9,16 @@
-
+