细节修正

This commit is contained in:
2026-01-12 14:31:33 +08:00
parent 12dca45b4d
commit a2d0da5a5f
4 changed files with 33 additions and 19 deletions

View File

@@ -10,9 +10,16 @@
v-model="searchKeyword"
placeholder="搜索文章..."
style="width: 300px"
onkeydown=""
clearable
/>
@keyup.enter="handleSearch"
@clear="handleSearch"
>
<template #append>
<el-button @click="handleSearch">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
</div>
<el-table :data="articles" style="width: 100%">
@@ -94,7 +101,8 @@ defineOptions({
name: 'ArticleManagementView'
});
import { ref, onMounted } from 'vue';
import { ElButton, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElMessage, ElMessageBox } from 'element-plus';
import { ElButton, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElMessage, ElMessageBox, ElIcon } from 'element-plus';
import { Search } from '@element-plus/icons-vue';
import { useRouter } from 'vue-router';
import { resourceApi, resourceTagApi } from '@/apis/resource'
import type { PageParam, ResourceSearchParams, Resource, Tag } from '@/types';
@@ -108,7 +116,7 @@ const pageParam = ref<PageParam>({
pageSize: 10
});
const filter = ref<ResourceSearchParams>({
keyword: searchKeyword.value
title: searchKeyword.value
});
const total = ref<number>(0);
const articles = ref<Resource[]>([]);
@@ -135,6 +143,7 @@ async function loadCategories() {
}
async function loadArticles() {
filter.value.title = searchKeyword.value;
const res = await resourceApi.getResourcePage(pageParam.value, filter.value);
if (res.success) {
articles.value = res.pageDomain?.dataList || [];
@@ -142,6 +151,11 @@ async function loadArticles() {
}
}
function handleSearch() {
pageParam.value.pageNumber = 1; // 搜索时重置到第一页
loadArticles();
}
function showCreateDialog() {
// 尝试跳转
router.push('/article/add')