Skip to content

Commit

Permalink
Showing 3 changed files with 22 additions and 8 deletions.
Binary file modified src/assets/images/l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions src/screens/_/base/avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
* @Author: czy0729
* @Date: 2019-05-19 17:10:16
* @Last Modified by: czy0729
* @Last Modified time: 2022-08-16 05:05:56
* @Last Modified time: 2022-09-08 19:47:13
*/
import React from 'react'
import { View } from 'react-native'
import { Image } from '@components'
import { _, systemStore, userStore } from '@stores'
import { _, systemStore, userStore, usersStore } from '@stores'
import { getTimestamp, getCoverMedium } from '@utils'
import { t } from '@utils/fetch'
import { HOST_API_V0 } from '@utils/fetch.v0/ds'
@@ -27,7 +27,7 @@ import { Props as AvatarProps } from './types'
export { AvatarProps }

/** 判断是否自己的头像, 一周才变化一次 */
const ts = Math.floor(getTimestamp() / 604800)
const TS = Math.floor(getTimestamp() / 604800)

/** 中质量头像 */
const USER_MEDIUM = '//lain.bgm.tv/pic/user/m/'
@@ -64,16 +64,18 @@ export const Avatar = ob(
let fallback = false

/**
* 判断是否自己的头像, 若是不走CDN, 保证最新
* 注意头像后面?r=xxx的参数不要去掉, 因头像地址每个人都唯一, 需要防止本地缓存
* 判断是否自己的头像, 若是不走 CDN, 保证最新
* 注意头像后面 ?r=xxx 的参数不要去掉, 因头像地址每个人都唯一, 需要防止本地缓存
*/
const mSrc = getCoverMedium(src, true)
let _src
if (avatar?.medium) {
const _1 = mSrc.split('?')[0].split('/m/')
const _2 = getCoverMedium(avatar.medium, true).split('?')[0].split('/m/')

// 为自己
if (_1[1] && _2[1] && _1[1] === _2[1]) {
_src = `${mSrc}?r=${ts}`
_src = usersStore.customAvatar || `${mSrc}?r=${TS}`
}
}

16 changes: 14 additions & 2 deletions src/stores/users/index.ts
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@
* @Author: czy0729
* @Date: 2019-07-24 10:31:45
* @Last Modified by: czy0729
* @Last Modified time: 2022-08-07 04:08:59
* @Last Modified time: 2022-09-08 19:44:48
*/
import { observable, computed } from 'mobx'
import { getTimestamp } from '@utils'
import { getTimestamp, HTMLDecode } from '@utils'
import store from '@utils/store'
import { fetchHTML } from '@utils/fetch'
import {
@@ -164,6 +164,18 @@ class UsersStore
return map
}

/** 自定义的头像 */
@computed get customAvatar() {
try {
const sign = this.users()?.sign || ''
const avatars = sign.match(/\[avatar\](.+?)\[\/avatar\]/)
const src = avatars ? String(avatars[1]).trim() : ''
return HTMLDecode(src)
} catch (error) {
return ''
}
}

// -------------------- mounted --------------------
init = async () => {
const res = this.readStorage(

0 comments on commit 6eaab1b

Please sign in to comment.