Skip to content

Commit

Permalink
- [发现] 基于全站条目数据的猜你喜欢
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Jun 13, 2023
1 parent 03f308a commit 057ccd5
Show file tree
Hide file tree
Showing 33 changed files with 987 additions and 215 deletions.
2 changes: 2 additions & 0 deletions src/components/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export const Image = observer(
setError451(src)
that.recoveryToBgmCover()
} else if (this.status === 404) {
setError404(src)
that.recoveryToBgmCover()
} else {
setTimeout(() => {
Expand All @@ -374,6 +375,7 @@ export const Image = observer(
setError451(src)
this.recoveryToBgmCover()
} else if (String(error).includes('code=404')) {
setError404(src)
this.recoveryToBgmCover()
} else {
setTimeout(() => {
Expand Down
6 changes: 5 additions & 1 deletion src/constants/events/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,9 @@ export default {
'Hentai.切换布局': 'Hentai.switchLayout',

// 维基人
'维基人.右上角菜单': 'Wiki.topRightMenu'
'维基人.右上角菜单': 'Wiki.topRightMenu',

// 猜你喜欢
'猜你喜欢.跳转': 'Like.to',
'猜你喜欢.切换': 'Like.switch'
}
6 changes: 3 additions & 3 deletions src/screens/_/base/horizontal-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* @Author: czy0729
* @Date: 2019-04-08 01:25:26
* @Last Modified by: czy0729
* @Last Modified time: 2023-05-26 12:56:25
* @Last Modified time: 2023-06-12 04:33:12
*/
import React from 'react'
import { ScrollView, View } from 'react-native'
import { Flex, Text, Touchable } from '@components'
import { _ } from '@stores'
import { desc, findSubjectCn, stl } from '@utils'
import { desc, findSubjectCn, HTMLDecode, stl } from '@utils'
import { ob } from '@utils/decorators'
import { SCROLL_VIEW_RESET_PROPS } from '@constants'
import { SubjectTypeCn } from '@types'
Expand Down Expand Up @@ -147,7 +147,7 @@ export const HorizontalList = ob(
ellipsizeMode={ellipsizeMode}
bold
>
{title}
{HTMLDecode(title)}
</Text>
{!!desc && (
<Touchable
Expand Down
15 changes: 13 additions & 2 deletions src/screens/_/base/manage/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2023-03-26 05:32:31
* @Last Modified by: czy0729
* @Last Modified time: 2023-03-28 06:56:13
* @Last Modified time: 2023-06-11 03:30:56
*/
import React from 'react'
import { View } from 'react-native'
Expand All @@ -12,7 +12,18 @@ import { titleCase } from '@utils'
import { ob } from '@utils/decorators'
import { styles } from './styles'

function Content({ icon, size, type, collection }) {
function Content({ icon, size, type, collection, horizontal }) {
if (horizontal) {
return (
<Flex style={[styles.content, styles.horizontal]}>
<Iconfont name={icon} size={size - 1} color={_[`color${titleCase(type)}`]} />
<Text style={_.ml.xs} type={type} size={13} lineHeight={15} align='center'>
{collection}
</Text>
</Flex>
)
}

return (
<View style={styles.content}>
<Flex style={styles.icon} justify='center'>
Expand Down
5 changes: 4 additions & 1 deletion src/screens/_/base/manage/content/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
* @Author: czy0729
* @Date: 2022-07-22 18:25:21
* @Last Modified by: czy0729
* @Last Modified time: 2023-03-28 07:29:04
* @Last Modified time: 2023-06-11 03:29:19
*/
import { _ } from '@stores'

export const styles = _.create({
content: {
minHeight: 40
},
horizontal: {
minWidth: 48
},
icon: {
width: 40
},
Expand Down
14 changes: 11 additions & 3 deletions src/screens/_/base/manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-07-22 17:54:53
* @Last Modified by: czy0729
* @Last Modified time: 2023-04-13 23:42:03
* @Last Modified time: 2023-06-11 03:26:17
*/
import React from 'react'
import { Touchable, Flex } from '@components'
Expand All @@ -24,7 +24,14 @@ const HIT_SLOP = {
}

export const Manage = ob(
({ style, subjectId, collection = '', typeCn = '动画', onPress }: ManageProps) => {
({
style,
subjectId,
collection = '',
typeCn = '动画',
horizontal,
onPress
}: ManageProps) => {
if (SHARE_MODE) return null

let icon
Expand Down Expand Up @@ -61,7 +68,8 @@ export const Manage = ob(
icon,
size,
type,
collection: _collection
collection: _collection,
horizontal
}
return (
<Flex style={styles.manage} justify='end' align='start'>
Expand Down
5 changes: 4 additions & 1 deletion src/screens/_/base/manage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-07-26 05:06:54
* @Last Modified by: czy0729
* @Last Modified time: 2023-03-28 06:27:20
* @Last Modified time: 2023-06-11 03:26:03
*/
import { Fn, SubjectId, SubjectTypeCn, ViewStyle } from '@types'

Expand All @@ -17,6 +17,9 @@ export type Props = {
/** 条目类型 (中文) */
typeCn?: SubjectTypeCn

/** 水平布局 */
horizontal?: boolean

/** 点击 */
onPress: Fn
}
17 changes: 14 additions & 3 deletions src/screens/_/base/pagination-list-2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const PaginationList2 = ({
data,
limit: _limit = 24,
onPage,
onNextPage,
...other
}: PaginationList2Props) => {
// 用户记住列表看到多少页, 在触发更新后需要使用此值去重新划归数组当前页数
Expand Down Expand Up @@ -56,7 +57,11 @@ export const PaginationList2 = ({
if (typeof onPage === 'function') {
onPage(data.slice(page * limit, (page + 1) * limit))
}
}, [data, limit, list, onPage])

if (typeof onNextPage === 'function') {
onNextPage(data.slice((page + 1) * limit, (page + 2) * limit))
}
}, [data, limit, list, onPage, onNextPage])

useEffect(() => {
const list = data.slice(0, lastPage.current * limit)
Expand All @@ -69,8 +74,14 @@ export const PaginationList2 = ({
_loaded: getTimestamp()
})

if (typeof onPage === 'function') onPage(list)
}, [data, limit, onPage])
if (typeof onPage === 'function') {
onPage(list)
}

if (typeof onNextPage === 'function') {
onNextPage(data.slice(limit, limit * 2))
}
}, [data, limit, onPage, onNextPage])

return (
<ListView
Expand Down
3 changes: 3 additions & 0 deletions src/screens/_/base/pagination-list-2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ export type Props = Override<

/** 下一页回调 */
onPage?: (nextPageData?: any[]) => any

/** 下下一页回调 */
onNextPage?: (nextPageData?: any[]) => any
}
>
4 changes: 2 additions & 2 deletions src/screens/_/base/rank/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-06-13 10:28:41
* @Last Modified by: czy0729
* @Last Modified time: 2023-05-26 11:51:20
* @Last Modified time: 2023-06-11 04:42:27
*/
import { _ } from '@stores'

Expand All @@ -19,7 +19,7 @@ export const memoStyles = _.memoStyles(() => ({
textShadowRadius: 1,
textShadowColor: 'rgba(0, 0, 0, 0.48)',
backgroundColor: _.select('#ffc107', _._colorDarkModeLevel2),
borderRadius: _.radiusXs,
borderRadius: 4,
overflow: 'hidden'
},
fit: {
Expand Down
8 changes: 4 additions & 4 deletions src/screens/_/base/rate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2023-06-10 14:08:09
* @Last Modified by: czy0729
* @Last Modified time: 2023-06-10 14:27:49
* @Last Modified time: 2023-06-12 04:02:47
*/
import React from 'react'
import { View } from 'react-native'
Expand All @@ -14,10 +14,10 @@ import { IOS } from '@constants'

export { RateProps }

export const Rate = ob(({ value = '' }: RateProps) => {
export const Rate = ob(({ value = '', onPress }: RateProps) => {
return (
<View style={styles.rate} pointerEvents='none'>
<Text overrideStyle={styles.rateText}>
<View style={styles.rate}>
<Text overrideStyle={styles.rateText} onPress={onPress}>
{value}
{IOS ? '' : ' '}
</Text>
Expand Down
6 changes: 3 additions & 3 deletions src/screens/_/base/rate/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* @Author: czy0729
* @Date: 2023-06-10 14:08:17
* @Last Modified by: czy0729
* @Last Modified time: 2023-06-10 14:24:38
* @Last Modified time: 2023-06-11 03:35:59
*/
import { _ } from '@stores'

export const styles = _.create({
rate: {
position: 'absolute',
zIndex: 1,
top: 8,
right: _.ios(20, 14),
top: _.sm,
right: _.ios(26, 20),
opacity: 0.5
},
rateText: {
Expand Down
10 changes: 9 additions & 1 deletion src/screens/_/base/rate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
* @Author: czy0729
* @Date: 2023-06-10 14:18:13
* @Last Modified by: czy0729
* @Last Modified time: 2023-06-10 14:26:47
* @Last Modified time: 2023-06-12 04:00:45
*/
import { Fn } from '@types'

export type Props = {
/** 评分 */
value: string | number

/** 对齐方向 */
position?: 'top' | 'bottom'

/** 文字点击 */
onPress?: Fn
}
7 changes: 6 additions & 1 deletion src/screens/discovery/index/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2021-07-16 14:21:27
* @Last Modified by: czy0729
* @Last Modified time: 2023-05-30 17:12:51
* @Last Modified time: 2023-06-13 19:06:31
*/
import { _ } from '@stores'
import { getTimestamp } from '@utils'
Expand Down Expand Up @@ -104,6 +104,11 @@ export const MENU_MAP = {
size: 20,
web: false
},
Like: {
key: 'Like',
name: '猜你喜欢',
icon: 'md-looks'
},
Recommend: {
key: 'Recommend',
name: '推荐',
Expand Down
4 changes: 2 additions & 2 deletions src/screens/discovery/like/cate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* @Author: czy0729
* @Date: 2021-03-16 20:58:10
* @Last Modified by: czy0729
* @Last Modified time: 2023-06-11 00:59:12
* @Last Modified time: 2023-06-13 05:32:39
*/
import React from 'react'
import { SegmentedControl } from '@components'
import { obc } from '@utils/decorators'
import { SUBJECT_TYPE } from '@constants'
import { Ctx } from '../types'
import { memoStyles } from './styles'
import { SUBJECT_TYPE } from '@constants'

function Cate(props, { $ }: Ctx) {
const styles = memoStyles()
Expand Down
Loading

0 comments on commit 057ccd5

Please sign in to comment.