8000 filter article by tags or category · pycoder404/blog-vue@52fb32e · GitHub
[go: up one dir, main page]

Skip to content

Commit 52fb32e

Browse files
committed
filter article by tags or category
1 parent 41cde61 commit 52fb32e

File tree

17 files changed

+215
-101
lines changed

17 files changed

+215
-101
lines changed

src/api/article.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,3 @@ export function UpdateArticle(articleId, data) {
3131
data: data
3232
})
3333
}
34-
35-
36-
export function getTagList(queryParams) {
37-
return request({
38-
url: '/api/tag/',
39-
method: 'get',
40-
params: queryParams
41-
})
42-
}
43-
44-
export function getCategoryList(queryParams) {
45-
return request({
46-
url: '/api/category/',
47-
method: 'get',
48-
params: queryParams
49-
})
50-
}
51-

src/api/category.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import request from '@/utils/request'
2+
3+
export function getCategoryList(queryParams) {
4+
return request({
5+
url: '/api/category/',
6+
method: 'get',
7+
params: queryParams
8+
})
9+
}
10+
11+
export function getCategoryDetail(categoryId, queryParams) {
12+
return request({
13+
url: '/api/category/' + categoryId + '/',
14+
method: 'get',
15+
params: queryParams
16+
})
17+
}
18+
19+
export function createCategory(data) {
20+
return request({
21+
url: '/api/category/',
22+
method: 'post',
23+
data: data
24+
})
25+
}
26+
27+
export function UpdateCategory(categoryId, data) {
28+
return request({
29+
url: '/api/category/' + categoryId + '/',
30+
method: 'put',
31+
data: data
32+
})
33+
}

src/api/comment.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import request from '@/utils/request'
2+
3+
export function getCommentList(queryParams) {
4+
return request({
5+
url: '/api/comment/',
6+
method: 'get',
7+
params: queryParams
8+
})
9+
}
10+
11+
export function getCommentDetail(commentId, queryParams) {
12+
return request({
13+
url: '/api/comment/' + commentId + '/',
14+
method: 'get',
15+
params: queryParams
16+
})
17+
}
18+
19+
export function createComment(data) {
20+
return request({
21+
url: '/api/comment/',
22+
method: 'post',
23+
data: data
24+
})
25+
}
26+
27+
export function UpdateComment(commentId, data) {
28+
return request({
29+
url: '/api/comment/' + commentId + '/',
30+
method: 'put',
31+
data: data
32+
})
33+
}

src/api/tag.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import request from '@/utils/request'
2+
3+
export function getTagList(queryParams) {
4+
return request({
5+
url: '/api/tag/',
6+
method: 'get',
7+
params: queryParams
8+
})
9+
}
10+
11+
export function getTagDetail(tagId, queryParams) {
12+
return request({
13+
url: '/api/tag/' + tagId + '/',
14+
method: 'get',
15+
params: queryParams
16+
})
17+
}
18+
19+
export function createTag(data) {
20+
return request({
21+
url: '/api/tag/',
22+
method: 'post',
23+
data: data
24+
})
25+
}
26+
27+
export function UpdateTag(tagId, data) {
28+
return request({
29+
url: '/api/tag/' + tagId + '/',
30+
method: 'put',
31+
data: data
32+
})
33+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<svg t="1658307719852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22179" width="200" height="200"><path d="M810.667 213.333a64 64 0 0 1 64 64V704a64 64 0 0 1-64 64H478.336l-146.645 96.107a21.333 21.333 0 0 1-33.024-17.856V768h-85.334a64 64 0 0 1-64-64V277.333a64 64 0 0 1 64-64h597.334z m0 64H213.333V704h149.334v63.296L459.243 704h351.424V277.333z m-271.36 213.334v64h-176.64v-64h176.64z m122.026-128v64H362.667v-64h298.666z" p-id="22180"></path></svg>
3+
</template>
4+
5+
<script>
6+
export default {
7+
name: 'IconGithub'
8+
}
9+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<svg t="1658307659096" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="20286" width="200" height="200"><path d="M725.333333 192c-89.6 0-168.533333 44.8-213.333333 115.2C467.2 236.8 388.266667 192 298.666667 192 157.866667 192 42.666667 307.2 42.666667 448c0 253.866667 469.333333 512 469.333333 512s469.333333-256 469.333333-512c0-140.8-115.2-256-256-256z" fill="#F44336" p-id="20287"></path></svg>
3+
</template>
4+
5+
<script>
6+
export default {
7+
name: 'IconGithub'
8+
}
9+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line number 10000 Diff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<svg t="1658307702286" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21275" width="200" height="200"><path d="M999.722667 449.024C886.912 324.864 699.733333 193.621333 512 196.266667 324.266667 193.578667 137.088 324.906667 24.234667 449.024a94.336 94.336 0 0 0 0 125.781333C135.722667 697.642667 320.298667 827.733333 505.130667 827.733333h13.141333c185.472 0 369.962667-130.090667 481.578667-252.970666a94.293333 94.293333 0 0 0-0.128-125.738667zM315.733333 512a196.266667 196.266667 0 1 1 196.266667 196.266667A196.266667 196.266667 0 0 1 315.733333 512z" p-id="21276"></path><path d="M512 512m-85.333333 0a85.333333 85.333333 0 1 0 170.666666 0 85.333333 85.333333 0 1 0-170.666666 0Z" p-id="21277"></path></svg>
3+
</template>
4+
5+
<script>
6+
export default {
7+
name: 'IconGithub'
8+
}
9+
</script>

src/components/SvgIcon/index.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import IconGmail from "./components/IconGmail";
1313
import IconQq from "./components/IconQQ";
1414
import IconWechat from "./components/IconWechat";
15+
import IconLike from "./components/IconLike";
16+
import IconView from "./components/IconView";
17+
import IconComment from "./components/IconComment";
1518
1619
const IconMap = {
1720
alipay: 'icon-alipay',
@@ -20,6 +23,9 @@
2023
gmail: 'icon-gmail',
2124
qq: 'icon-qq',
2225
wechat: 'icon-wechat',
26+
like: 'icon-like',
27+
view: 'icon-view',
28+
comment: 'icon-comment',
2329
}
2430
2531
export default {
@@ -30,7 +36,10 @@
3036
IconGithub,
3137
IconGmail,
3238
IconQq,
33-
IconWechat
39+
IconWechat,
40+
IconLike,
41+
IconView,
42+
IconComment
3443
},
3544
props: {
3645
icon: {

src/layout/components/MainHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<router-link to="/">
2222
<el-dropdown-item>Home</el-dropdown-item>
2323
</router-link>
24-
<router-link to="/article/new">
24+
<router-link to="/article/create">
2525
<el-dropdown-item>New</el-dropdown-item>
2626
</router-link>
2727

src/permission.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,38 @@ const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist
1313
router.beforeEach(async (to, from, next) => {
1414
// start progress bar
1515
NProgress.start()
16-
console.log("before route change")
16+
// console.log("before route change")
17+
// console.log(to.path)
1718
// set page title
1819
document.title = getPageTitle(to.meta.title)
1920

2021
// determine whether the user has logged in
2122
const hasAccessToken = getAccessToken()
22-
console.log("check is has access token: ",hasAccessToken)
23+
// console.log("check is has access token: ",hasAccessToken)
2324
if (hasAccessToken) {
24-
console.log("has access token:",hasAccessToken)
25+
// console.log("has access token:",hasAccessToken)
2526
// FIXME 添加对accessToken的过期检查和refresh
2627
if (to.path === '/login') {
2728
// if is logged in, redirect to the home page
2829
next({path: '/'})
2930
NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
3031
} else {
3132
// determine whether the user has obtained his permission roles through getInfo
32-
console.log("check is has roles")
33-
console.log(store.getters.roles)
33+
// console.log("check is has roles")
34+
// console.log(store.getters.roles)
35+
// FIXME Ctrl + F5强制刷新界面,对store有啥影响吗,为啥会导致没有roles,重新获取Info?
3436
const hasRoles = store.getters.roles && store.getters.roles.length > 0
3537
if (hasRoles) {
36-
console.log("yes has roles")
38+
// console.log("yes has roles")
3739
next()
38-
console.log('next done')
40+
// console.log('next done')
3941
} else {
40-
console.log('can not get roles from store')
42+
// console.log('can not get roles from store')
4143
try {
4244
// get user info
4345
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
4446
// FIXME 这里的roles是user/GetInfo如何反馈的,如何只反馈roles的
45-
console.log("get info")
47+
// console.log("get info")
4648
const { roles } = await store.dispatch('user/getInfo')
4749
console.log(roles)
4850
// // generate accessible routes map based on roles

0 commit comments

Comments
 (0)
0