reghao 3 mesi fa
parent
commit
e827ffae50

+ 4 - 5
src/api/blog.js

@@ -3,7 +3,6 @@ import { delete0, get, post, postForm } from '@/utils/request'
 const blogApi = {
   getPost: '/api/blog/post',
   getCategory: '/api/blog/category',
-  getTag: '/api/blog/tag',
   getArchive: '/api/blog/archive',
   getAbout: '/api/blog/about',
   getSearchList: '/api/blog/search',
@@ -21,12 +20,12 @@ export function getPost(postId) {
   return get(blogApi.getPost + '/detail?articleId=' + postId)
 }
 
-export function getTag(queryInfo) {
-  return get(blogApi.getTag, queryInfo)
+export function getCategory(queryInfo) {
+  return get(blogApi.getCategory, queryInfo)
 }
 
-export function getTagPost(queryInfo) {
-  return get(blogApi.getTag + '/post', queryInfo)
+export function getCategoryPost(queryInfo) {
+  return get(blogApi.getCategory + '/post', queryInfo)
 }
 
 export function getArchive() {

+ 8 - 8
src/router/blog.js

@@ -1,8 +1,8 @@
 const Blog = () => import('views/blog/Blog')
 const ArticleIndex = () => import('views/blog/Article')
 const ArticlePage = () => import('views/blog/ArticlePage')
-const TagIndex = () => import('views/blog/TagIndex')
-const TagPage = () => import('views/blog/TagPage')
+const CategoryIndex = () => import('views/blog/CategoryIndex')
+const CategoryPage = () => import('views/blog/CategoryPage')
 const ArchivePage = () => import('views/blog/ArchivePage')
 const AboutPage = () => import('views/blog/AboutPage')
 const SearchPage = () => import('views/blog/SearchPage')
@@ -33,26 +33,26 @@ export default {
     },
     {
       path: '/blog/category',
-      name: 'TagIndex',
-      component: TagIndex,
+      name: 'CategoryIndex',
+      component: CategoryIndex,
       meta: { needAuth: false }
     },
     {
       path: '/blog/category/post',
-      name: 'TagPage',
-      component: TagPage,
+      name: 'CategoryPage',
+      component: CategoryPage,
       meta: { needAuth: false }
     },
     {
       path: '/blog/tag',
       name: 'TagIndex',
-      component: TagIndex,
+      component: CategoryIndex,
       meta: { needAuth: false }
     },
     {
       path: '/blog/tag/post',
       name: 'TagPage',
-      component: TagPage,
+      component: CategoryPage,
       meta: { needAuth: false }
     },
     {

+ 10 - 8
src/views/blog/AboutPage.vue

@@ -1,13 +1,15 @@
 <template>
   <el-row v-if="blogAbout !== null" class="movie-list">
-    <el-card class="box-card">
-      <div slot="header" class="clearfix">
-        <span>{{ blogAbout.title }}</span>
-      </div>
-      <div class="text item">
-        {{ blogAbout.content }}
-      </div>
-    </el-card>
+    <el-col :md="12">
+      <el-card class="box-card">
+        <div slot="header" class="clearfix">
+          <span>{{ blogAbout.title }}</span>
+        </div>
+        <div class="text item">
+          {{ blogAbout.content }}
+        </div>
+      </el-card>
+    </el-col>
   </el-row>
 </template>
 

+ 8 - 8
src/views/blog/ArchivePage.vue

@@ -1,9 +1,9 @@
 <template>
-  <el-scrollbar style="width: 100%; height: 80vh;">
-    <el-row class="movie-list">
-      <el-col :md="12">
+  <el-row class="movie-list">
+    <el-col :md="12">
+      <el-scrollbar style="width: 100%; height: 80vh;">
         <el-card class="box-card">
-          <el-timeline :reverse="true">
+          <el-timeline :reverse="false">
             <el-timeline-item
               v-for="(item, index) in blogArchive"
               :key="index"
@@ -13,11 +13,11 @@
                 {{ item.title }}
               </router-link>
             </el-timeline-item>
-          </el-timeline>>
+          </el-timeline>
         </el-card>
-      </el-col>
-    </el-row>
-  </el-scrollbar>
+      </el-scrollbar>
+    </el-col>
+  </el-row>
 </template>
 
 <script>

+ 1 - 1
src/views/blog/BlogImage.vue

@@ -85,7 +85,7 @@ export default {
       // 屏幕宽度, 为了控制分页条的大小
       screenWidth: document.body.clientWidth,
       currentPage: 1,
-      pageSize: 100,
+      pageSize: 12,
       totalSize: 0,
       dataList: [],
       addDialog: false

+ 26 - 1
src/views/blog/BlogPost.vue

@@ -16,6 +16,15 @@
             :value="item.id"
           />
         </el-select>
+        <el-input
+          v-model="queryInfo.title"
+          style="width: 20%; padding: 3px"
+          clearable
+          placeholder="标题"
+          @clear="onClear"
+          @keyup.enter.native="onSearch"
+        />
+        <el-button type="success" icon="el-icon-search" style="margin-left: 5px" @click="onSearch">查询</el-button>
         <el-button type="success" icon="el-icon-plus" style="margin-left: 5px" @click="handleAdd">添加</el-button>
         <el-button type="warning" icon="el-icon-delete" style="margin-left: 5px" @click="handleResetIndex">重置索引</el-button>
       </el-row>
@@ -249,7 +258,7 @@ export default {
       this.queryInfo.pn = parseInt(pageNumber)
     }
     const categoryId = this.$route.query.categoryId
-    if (categoryId !== undefined && categoryId !== null) {
+    if (categoryId !== undefined && categoryId !== '') {
       this.queryInfo.categoryId = parseInt(categoryId)
     }
     const title = this.$route.query.title
@@ -374,6 +383,22 @@ export default {
       // markdown文本格式
       this.addForm.content = this.$refs.md.d_value
     },
+    onSearch() {
+      this.onSelectChange()
+    },
+    onClear() {
+      this.queryInfo = {
+        pn: 1,
+        categoryId: null,
+        title: '',
+        published: 0
+      }
+      this.$router.push({
+        path: '/bg/blog/post',
+        query: this.queryInfo
+      })
+      this.$router.go(0)
+    },
     handleResetIndex() {
       this.$confirm('确定要重置文章索引?', '提示', {
         confirmButtonText: '确定',

+ 4 - 3
src/views/blog/TagIndex.vue → src/views/blog/CategoryIndex.vue

@@ -28,10 +28,10 @@
 </template>
 
 <script>
-import { getTag } from '@/api/blog'
+import {getCategory} from "@/api/blog";
 
 export default {
-  name: 'TagIndex',
+  name: 'CategoryIndex',
   data() {
     return {
       queryInfo: {
@@ -43,6 +43,7 @@ export default {
   },
   created() {
     const path = this.$route.path
+    console.log(path)
     if (path !== undefined && path !== null) {
       if (path.endsWith('category')) {
         document.title = '文章分类'
@@ -60,7 +61,7 @@ export default {
   },
   methods: {
     getData() {
-      getTag(this.queryInfo).then(resp => {
+      getCategory(this.queryInfo).then(resp => {
         if (resp.code === 0) {
           this.dataList = resp.data
         } else {

+ 3 - 3
src/views/blog/TagPage.vue → src/views/blog/CategoryPage.vue

@@ -65,10 +65,10 @@
 </template>
 
 <script>
-import { getTagPost } from '@/api/blog'
+import {getCategoryPost} from "@/api/blog";
 
 export default {
-  name: 'TagPage',
+  name: 'CategoryPage',
   data() {
     return {
       queryInfo: {
@@ -134,7 +134,7 @@ export default {
       scrollTo(0, 0)
     },
     getData() {
-      getTagPost(this.queryInfo).then(resp => {
+      getCategoryPost(this.queryInfo).then(resp => {
         if (resp.code === 0) {
           const respData = resp.data
           this.dataList = respData.list

+ 33 - 31
src/views/blog/SearchPage.vue

@@ -1,19 +1,20 @@
 <template>
   <el-row class="movie-list">
     <el-col :md="18">
-      <el-row v-for="(item, index) in dataList" :key="index" class="movie-list">
-        <el-card class="box-card">
-          <div slot="header" class="clearfix">
-            <router-link style="text-decoration-line: none" target="_blank" :to="`/blog/post/${item.articleId}`">
-              <span style="left: 0;margin-bottom: 0px;color: black;" v-html="item.title"></span>
-            </router-link>
-          </div>
-          <div class="text item">
-            <el-row>
-              <span v-html="item.summary" />
-            </el-row>
-            <el-row>
-              <el-col style="padding: 1px" :md="2" :sm="6" :xs="6">
+      <el-scrollbar style="width: 100%; height: 80vh;">
+        <el-row v-for="(item, index) in dataList" :key="index" class="movie-list">
+          <el-card class="box-card">
+            <div slot="header" class="clearfix">
+              <router-link style="text-decoration-line: none" target="_blank" :to="`/blog/post/${item.articleId}`">
+                <span style="left: 0;margin-bottom: 0px;color: black;" v-html="item.title"></span>
+              </router-link>
+            </div>
+            <div class="text item">
+              <el-row>
+                <span v-html="item.summary" />
+              </el-row>
+              <el-row>
+                <el-col style="padding: 1px" :md="2" :sm="6" :xs="6">
                 <span style="left: 0;margin-bottom: 0px;color: black;">
                     <router-link style="text-decoration-line: none" target="_blank" :to="`/blog/category/post?name=${item.category}`">
                       <el-tag type="warning">
@@ -21,27 +22,28 @@
                       </el-tag>
                     </router-link>
                   </span>
-              </el-col>
-              <el-col style="padding: 1px" :md="6" :sm="16" :xs="16">
+                </el-col>
+                <el-col style="padding: 1px" :md="6" :sm="16" :xs="16">
                 <span class="el-icon-watch" style="left: 0;margin-bottom: 0px;color: black;">
                   {{ item.publishAt }}
                 </span>
-              </el-col>
-            </el-row>
-          </div>
-        </el-card>
-      </el-row>
-      <el-pagination
-        background
-        :small="screenWidth <= 768"
-        layout="prev, pager, next"
-        :page-size="pageSize"
-        :current-page="currentPage"
-        :total="totalSize"
-        @current-change="handleCurrentChange"
-        @prev-click="handleCurrentChange"
-        @next-click="handleCurrentChange"
-      />
+                </el-col>
+              </el-row>
+            </div>
+          </el-card>
+        </el-row>
+        <el-pagination
+          background
+          :small="screenWidth <= 768"
+          layout="prev, pager, next"
+          :page-size="pageSize"
+          :current-page="currentPage"
+          :total="totalSize"
+          @current-change="handleCurrentChange"
+          @prev-click="handleCurrentChange"
+          @next-click="handleCurrentChange"
+        />
+      </el-scrollbar>
     </el-col>
     <el-col :md="6">
       <el-row class="movie-list">