fix "score cost per closet item" isn't calculated

at "texture upload" page
This commit is contained in:
Pig Fang 2020-03-06 10:15:01 +08:00
parent 998c5f011a
commit ed04dd1740
5 changed files with 10 additions and 7 deletions

View File

@ -211,6 +211,7 @@ class SkinlibController extends Controller
), ),
'scorePublic' => intval(option('score_per_storage')), 'scorePublic' => intval(option('score_per_storage')),
'scorePrivate' => intval(option('private_score_per_storage')), 'scorePrivate' => intval(option('private_score_per_storage')),
'closetItemCost' => intval(option('score_per_closet_item')),
'award' => intval(option('score_award_per_texture')), 'award' => intval(option('score_award_per_texture')),
'contentPolicy' => $parsedown->text(option_localized('content_policy')), 'contentPolicy' => $parsedown->text(option_localized('content_policy')),
]); ]);

View File

@ -28,6 +28,7 @@ const Upload: React.FC = () => {
const award = useBlessingExtra<number>('award') const award = useBlessingExtra<number>('award')
const scorePublic = useBlessingExtra<number>('scorePublic') const scorePublic = useBlessingExtra<number>('scorePublic')
const scorePrivate = useBlessingExtra<number>('scorePrivate') const scorePrivate = useBlessingExtra<number>('scorePrivate')
const closetItemCost = useBlessingExtra<number>('closetItemCost')
useEffect(() => { useEffect(() => {
const mount = document.querySelector('#previewer')! const mount = document.querySelector('#previewer')!
@ -119,6 +120,8 @@ const Upload: React.FC = () => {
} }
const costRatio = isPrivate ? scorePrivate : scorePublic const costRatio = isPrivate ? scorePrivate : scorePublic
const size = file?.size ?? 0
const scoreCost = (~~(size / 1024) || 1) * costRatio + closetItemCost
return ( return (
<> <>
@ -241,11 +244,7 @@ const Upload: React.FC = () => {
</div> </div>
{file && ( {file && (
<div className="callout callout-success mt-3"> <div className="callout callout-success mt-3">
<p> <p>{t('skinlib.upload.cost', { score: scoreCost })}</p>
{t('skinlib.upload.cost', {
score: (~~(file.size / 1024) || 1) * costRatio,
})}
</p>
</div> </div>
)} )}
{isPrivate && ( {isPrivate && (

View File

@ -18,6 +18,7 @@ beforeEach(() => {
privacyNotice: 'privacy notice', privacyNotice: 'privacy notice',
scorePrivate: 10, scorePrivate: 10,
scorePublic: 1, scorePublic: 1,
closetItemCost: 10,
award: 0, award: 0,
contentPolicy: 'the policy', contentPolicy: 'the policy',
} }
@ -145,7 +146,7 @@ describe('score cost', () => {
}) })
expect( expect(
queryByText(t('skinlib.upload.cost', { score: 1 })), queryByText(t('skinlib.upload.cost', { score: 11 })),
).toBeInTheDocument() ).toBeInTheDocument()
}) })
@ -159,7 +160,7 @@ describe('score cost', () => {
fireEvent.click(getByLabelText(t('skinlib.upload.set-as-private'))) fireEvent.click(getByLabelText(t('skinlib.upload.set-as-private')))
expect( expect(
queryByText(t('skinlib.upload.cost', { score: 10 })), queryByText(t('skinlib.upload.cost', { score: 20 })),
).toBeInTheDocument() ).toBeInTheDocument()
}) })
}) })

View File

@ -63,6 +63,7 @@
- Fixed that avatar can't be resized when requesting an non-existed user. - Fixed that avatar can't be resized when requesting an non-existed user.
- Fixed that the same texture files with different models were treated as different textures. (Thanks [Steven Qiu](https://github.com/tnqzh123)) - Fixed that the same texture files with different models were treated as different textures. (Thanks [Steven Qiu](https://github.com/tnqzh123))
- Fixed when uploading duplicated texture, alert is missing. - Fixed when uploading duplicated texture, alert is missing.
- Fixed that "score cost per closet item" isn't calculated at "texture upload" page.
## Removed ## Removed

View File

@ -63,6 +63,7 @@
- 修复获取不存在的用户的头像时,未能正确设置尺寸的问题 - 修复获取不存在的用户的头像时,未能正确设置尺寸的问题
- 修复同一材质文件但模型不同被认为不同材质的问题(感谢 [Steven Qiu](https://github.com/tnqzh123) - 修复同一材质文件但模型不同被认为不同材质的问题(感谢 [Steven Qiu](https://github.com/tnqzh123)
- 修复上传重复材质时没有提示用户的问题 - 修复上传重复材质时没有提示用户的问题
- 「材质上传」页面的积分消耗没有计算衣柜收藏所需的积分
## 移除 ## 移除