Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dynamic-feed): add follow-group for filter #123

Merged
merged 4 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@commitlint/prompt-cli": "^19.5.0",
"@commitlint/types": "^19.5.0",
"@emotion/babel-plugin": "^11.12.0",
"@iconify/json": "^2.2.258",
"@iconify/json": "^2.2.259",
"@magicdawn/prettier-config": "^0.0.4",
"@styled/typescript-styled-plugin": "^1.0.1",
"@svgr/core": "^8.1.0",
Expand All @@ -38,7 +38,7 @@
"@types/ms": "^0.7.34",
"@types/node": "22.7.5",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.0",
"@types/react-dom": "18.3.1",
"@types/ua-parser-js": "^0.7.39",
"@unocss/preset-rem-to-px": "^0.63.4",
"@violentmonkey/types": "^0.1.9",
Expand All @@ -60,7 +60,7 @@
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.79.5",
"sass-embedded": "^1.79.4",
"sass-embedded": "^1.79.5",
"turbo": "^2.1.3",
"type-fest": "^4.26.1",
"typed-scss-modules": "^8.0.1",
Expand Down
264 changes: 132 additions & 132 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function TabPaneVideoSourceTabConfig() {
>
<div
css={css`
order: ${sortedTabKeys.indexOf('watchlater') + 1};
order: ${sortedTabKeys.indexOf(ETab.Watchlater) + 1};
`}
>
<div className={styles.settingsGroupSubTitle}>
Expand All @@ -90,7 +90,7 @@ export function TabPaneVideoSourceTabConfig() {

<div
css={css`
order: ${sortedTabKeys.indexOf('fav') + 1};
order: ${sortedTabKeys.indexOf(ETab.Fav) + 1};
`}
>
<div className={styles.settingsGroupSubTitle}>
Expand All @@ -114,6 +114,32 @@ export function TabPaneVideoSourceTabConfig() {
</Space>
</div>

<div
css={css`
order: ${sortedTabKeys.indexOf(ETab.DynamicFeed) + 1};
`}
>
<div className={styles.settingsGroupSubTitle}>
<TabIcon tabKey={ETab.DynamicFeed} mr={5} mt={-2} />
动态
</div>
<Space size={10}>
<CheckboxSettingItem
configKey='enableFollowGroupFilterForDynamicFeed'
label='启用分组筛选'
tooltip={
<>
动态筛选里加入分组
<br />
目前基于全部动态 + 分组UP过滤, 速度较慢~
<br />
且貌似只能拉取最近一个月的动态数据
</>
}
/>
</Space>
</div>

<div
css={css`
order: ${sortedTabKeys.indexOf(ETab.RecommendApp) + 1};
Expand Down
68 changes: 68 additions & 0 deletions src/modules/rec-services/dynamic-feed/group/group-content.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */

export interface FollowGroupContentJson {
code: number
message: string
ttl: number
data: FollowGroupContent[]
}

export interface FollowGroupContent {
mid: number
attribute: number
tag: null
special: number
contract_info: ContractInfo
uname: string
face: string
sign: string
face_nft: number
official_verify: OfficialVerify
vip: Vip
name_render: NameRender
live: Live
nft_icon: string
rec_reason: string
track_id: string
follow_time: string
}

export interface ContractInfo {
is_contract?: boolean
}

export interface Live {
live_status: number
jump_url: string
}

export interface NameRender {}

export interface OfficialVerify {
type: number
desc: string
}

export interface Vip {
vipType: number
vipDueDate: number
dueRemark: string
accessStatus: number
vipStatus: number
vipStatusWarn: string
themeType: number
label: Label
avatar_subscript: number
nickname_color: string
avatar_subscript_url: string
}

export interface Label {
path: string
text: string
label_theme: string
text_color: string
bg_style: number
bg_color: string
border_color: string
}
18 changes: 18 additions & 0 deletions src/modules/rec-services/dynamic-feed/group/groups.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface FollowGroupsJson {
code: number
message: string
ttl: number
data: FollowGroup[]
}

export interface FollowGroup {
tagid: number
name: string
count: number
tip: Tip
}

export enum Tip {
Empty = '',
第一时间收到该分组下用户更新稿件的通知 = '第一时间收到该分组下用户更新稿件的通知',
}
49 changes: 49 additions & 0 deletions src/modules/rec-services/dynamic-feed/group/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { request } from '$request'
import { getUid } from '$utility/cookie'
import { encWbi, getWwebId } from '$utility/wbi'
import { uniq } from 'lodash'
import type { FollowGroupContent, FollowGroupContentJson } from './group-content'
import type { FollowGroupsJson } from './groups'

/**
* 其中返回的没有 "悄悄关注", 而且悄悄关注使用 API /x/relation/whispers
*/

export async function getAllFollowGroups() {
const params = await encWbi({
web_location: '0.0',
w_webid: (await getWwebId()) || '',
})
const res = await request.get('/x/relation/tags', { params })
const json = res.data as FollowGroupsJson
const groups = json.data || []
return groups
}

export async function getFollowGroupContent(tagid: number) {
const ps = 20

const singleRequest = async (page: number) => {
const res = await request.get('/x/relation/tag', {
params: {
mid: getUid(),
tagid,
pn: page,
ps,
},
})
const json = res.data as FollowGroupContentJson
return json.data
}

let pn = 1
let items: FollowGroupContent[] = []
let currentPageItems: FollowGroupContent[] = []
do {
currentPageItems = await singleRequest(pn++)
items = items.concat(currentPageItems)
} while (currentPageItems.length > 0)

const mids = uniq(items.map((x) => x.mid))
return mids
}
Loading