Skip to content

Commit

Permalink
chore(blog): 添加刷新博客数据的用户权限过滤
Browse files Browse the repository at this point in the history
  • Loading branch information
boxsnake committed Jan 26, 2025
1 parent ac00090 commit 0915e47
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ cache/
.vscode/
auto-imports.d.ts
pnpm-lock.yaml

src/_data/*.json
10 changes: 7 additions & 3 deletions scripts/refreshBlogData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { blog, password } from '@/apis/forum/gitee'
import fs from 'node:fs/promises'
import teamMemberList from '~/_data/teamMemberList.json'
import blogMemberList from '~/_data/blogMemberList.json'
import { URL } from 'node:url'

import type ForumAPI from '@/apis/forum/api'
Expand Down Expand Up @@ -40,8 +41,11 @@ export const refreshBlogData = async () => {
return totalPage
}

const isTeamMember = async (id: string | number) => {
return teamMemberList.findIndex((val) => val === id)
const isGrantedMember = (id: string | number) => {
return (
teamMemberList.some((val) => val === Number(id)) ||
blogMemberList.some((val) => val === Number(id))
)
}

const totalPage = await requestData(page)
Expand All @@ -53,7 +57,7 @@ export const refreshBlogData = async () => {
await Promise.all(pool.flatMap((item) => Array(totalPage - 1).fill(item)))

posts
.filter((val) => isTeamMember(val.user.id))
.filter((val) => isGrantedMember(val.user.id))
.sort(
(a, b) =>
new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
Expand Down
4 changes: 3 additions & 1 deletion src/_data/blogMemberList.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
[8901509]
[
8901509
]
6 changes: 5 additions & 1 deletion src/_data/feedbackMemberList.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
[15375175, 14647057, 4922359]
[
15375175,
14647057,
4922359
]
2 changes: 1 addition & 1 deletion src/_data/posts.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@
"createdAt": "2025-01-14T17:47:49+08:00",
"updatedAt": "2025-01-25T12:08:28+08:00"
}
]
]
38 changes: 33 additions & 5 deletions src/_data/teamMemberList.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
[
7029, 1171483, 1277295, 1485948, 1862853, 2253624, 4782617, 4840416, 4922359,
5095901, 5482877, 5685289, 7430700, 7577601, 7824691, 7964621, 8008281,
8108968, 8171326, 8609588, 8733184, 8901509, 9101702, 9155564, 9163390,
9264359, 9266781, 9267342, 9569245, 10236865, 10315086, 13266110
]
7029,
1171483,
1277295,
1485948,
1862853,
2253624,
4782617,
4840416,
4922359,
5095901,
5482877,
5685289,
7430700,
7577601,
7824691,
7964621,
8008281,
8108968,
8171326,
8609588,
8733184,
8901509,
9101702,
9155564,
9163390,
9264359,
9266781,
9267342,
9569245,
10236865,
10315086,
13266110
]

0 comments on commit 0915e47

Please sign in to comment.