Skip to content

Commit

Permalink
feat: 新增是否推荐字段
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed Jun 21, 2024
1 parent c805fd0 commit 67b862d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/components/WebsiteCard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@
</div>
<div class="text-sm text-slate-500 font-medium line-clamp-2">{{ websiteInfo.desc }}</div>
</div>
<!-- 置顶标签 -->
<div class="absolute top-1 right-1.5">
<!-- 置顶标签 -->
<template v-if="websiteInfo.pinned">
<el-tag type="success" effect="light"> 置顶 </el-tag>
</template>
<!-- 是否推荐 -->
<template v-if="websiteInfo.recommend">
<el-tag type="info" effect="light"> 推荐 </el-tag>
</template>
</div>
</el-card>
</template>
Expand Down
12 changes: 9 additions & 3 deletions src/pages/admin/_components/websites/components/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-06-05 10:47:28
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2024-06-21 14:25:06
* @LastEditTime: 2024-06-21 15:53:44
* @Description: 新增/编辑弹窗
-->
<template>
Expand Down Expand Up @@ -47,16 +47,21 @@
<dynamic-tag v-model="form.tags" />
</el-form-item>
<el-row>
<el-col :span="6">
<el-col :span="8">
<el-form-item label="置顶" prop="pinned">
<el-switch v-model="form.pinned" inline-prompt active-text="是" inactive-text="否" />
</el-form-item>
</el-col>
<el-col :span="18">
<el-col :span="8">
<el-form-item label="vpn" prop="vpn">
<el-switch v-model="form.vpn" inline-prompt active-text="是" inactive-text="否" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="推荐" prop="recommend">
<el-switch v-model="form.recommend" inline-prompt active-text="是" inactive-text="否" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="站点描述" prop="desc">
<el-input v-model="form.desc" type="textarea" :rows="3" maxlength="100" show-word-limit />
Expand Down Expand Up @@ -96,6 +101,7 @@ const form = reactive<WebsiteEdit>({
tags: [],
pinned: false,
vpn: false,
recommend: false,
desc: undefined,
sort: 1
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
</el-button>
</template>
</el-table-column>
<el-table-column prop="recommend" label="推荐" align="center" width="80">
<template #default="{ row }">
<el-button :type="row.recommend ? 'success' : 'danger'" circle size="small">
<template #icon>
<Icon :name="row.recommend ? 'ri:check-fill' : 'ri:close-fill'" />
</template>
</el-button>
</template>
</el-table-column>
<el-table-column prop="sort" label="排序" align="center" sortable min-width="100" />
<el-table-column prop="created_at" label="创建时间" align="center" width="180" sortable>
<template #default="{ row }">
Expand Down
1 change: 1 addition & 0 deletions src/pages/admin/_components/websites/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const handleEdit = (row: WebsiteList) => {
tags: row.tags,
pinned: row.pinned,
vpn: row.vpn,
recommend: row.recommend,
desc: row.desc,
sort: row.sort
})
Expand Down
5 changes: 4 additions & 1 deletion src/server/api/websites/index.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-05-29 14:39:50
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2024-06-19 16:30:24
* @LastEditTime: 2024-06-21 15:53:04
* @Description: 获取站点列表
*/
import type { Response, PageResponse, WebsiteList, WebsiteParams } from '~/types'
Expand Down Expand Up @@ -30,6 +30,9 @@ export default defineEventHandler(async (event): Promise<Response<PageResponse<W
.order('pinned', {
ascending: false
})
.order('recommend', {
ascending: false
})
.order('sort', {
ascending: false
})
Expand Down
3 changes: 2 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type WebsiteList = {
tags: string[] // 站点标签
pinned: boolean // 是否置顶
vpn: boolean // 是否需要 vpn
recommend: boolean // 是否推荐
user_id: string // 用户 id
email: string // 用户邮箱
sort: number // 排序
Expand All @@ -80,7 +81,7 @@ export type WebsiteParams = PaginationParams & Partial<Pick<WebsiteList, 'name'
*/
export type WebsiteEdit = Pick<
WebsiteList,
'category_id' | 'name' | 'url' | 'logo' | 'tags' | 'pinned' | 'vpn' | 'sort'
'category_id' | 'name' | 'url' | 'logo' | 'tags' | 'pinned' | 'vpn' | 'recommend' | 'sort'
> &
Partial<Pick<CategoryList, 'id' | 'desc'>>

Expand Down

0 comments on commit 67b862d

Please sign in to comment.