mirror of
https://ghproxy.com/https://github.com/StreakingMan/solvable-sheep-game
synced 2025-05-25 09:08:14 +08:00
feat: 配置上传时间间隔限制
This commit is contained in:
parent
66f7e48166
commit
c9cc9114c3
|
@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|||
import { Icon, Sound, Theme } from '../themes/interface';
|
||||
import { QRCodeCanvas } from 'qrcode.react';
|
||||
import Bmob from 'hydrogen-js-sdk';
|
||||
import { captureElement } from '../utils';
|
||||
import { captureElement, LAST_UPLOAD_TIME_STORAGE_KEY } from '../utils';
|
||||
import { copy } from 'clipboard';
|
||||
|
||||
const STORAGEKEY = 'customTheme';
|
||||
|
@ -261,6 +261,21 @@ export const ConfigDialog: FC<{
|
|||
setConfigError('');
|
||||
generateTheme()
|
||||
.then((theme) => {
|
||||
// 五分钟能只能上传一次
|
||||
const lastUploadTime = localStorage.getItem(
|
||||
LAST_UPLOAD_TIME_STORAGE_KEY
|
||||
);
|
||||
if (
|
||||
lastUploadTime &&
|
||||
new Date().getTime() - Number(lastUploadTime) <
|
||||
1000 * 60 * 5
|
||||
) {
|
||||
setConfigError(
|
||||
'五分钟内只能上传一次(用的人有点多十分抱歉😭),先保存预览看看效果把~'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const stringify = JSON.stringify(theme);
|
||||
localStorage.setItem(STORAGEKEY, stringify);
|
||||
const query = Bmob.Query('config');
|
||||
|
@ -271,9 +286,14 @@ export const ConfigDialog: FC<{
|
|||
//@ts-ignore
|
||||
const link = `${location.origin}?customTheme=${res.objectId}`;
|
||||
setGenLink(link);
|
||||
localStorage.setItem(
|
||||
LAST_UPLOAD_TIME_STORAGE_KEY,
|
||||
new Date().getTime().toString()
|
||||
);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
.catch(({ error }) => {
|
||||
setConfigError(error);
|
||||
setGenLink('');
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
@ -3,6 +3,7 @@ import { getDefaultTheme } from './themes/default';
|
|||
|
||||
export const LAST_LEVEL_STORAGE_KEY = 'lastLevel';
|
||||
export const LAST_SCORE_STORAGE_KEY = 'lastScore';
|
||||
export const LAST_UPLOAD_TIME_STORAGE_KEY = 'lastUploadTime';
|
||||
export const DEFAULT_BGM_STORAGE_KEY = 'defaultBgm';
|
||||
export const DEFAULT_TRIPLE_SOUND_STORAGE_KEY = 'defaultTripleSound';
|
||||
export const DEFAULT_CLICK_SOUND_STORAGE_KEY = 'defaultClickSound';
|
||||
|
|
Loading…
Reference in New Issue
Block a user