diff --git a/diy/README.md b/diy/README.md index e1a95f3..5f05bbb 100644 --- a/diy/README.md +++ b/diy/README.md @@ -68,8 +68,8 @@ yarn dev:diy yarn build:diy ``` -会在 `diy/diy-dist` 下生成静态资源,直接将这些文件复制服务器上做代理即可。如果嫌麻烦,推荐使用 [vercel](https://vercel.com/) -一键部署(每月免费 100G 流量), 将更改后的项目推到自己的 github(gitlab,bitbucket 同样支持)仓库, +会在 `diy/diy-dist` 下生成静态资源,直接将这些文件复制服务器上做代理即可。如果嫌麻烦,推荐使用 [vercel](https://vercel.com/) +一键部署(每月免费 100G 流量), 将更改后的项目推到自己的 github(gitlab,bitbucket 同样支持)仓库, 使用 github 账号登录 vercel 后导入该项目,构建模版选择 vite, 构建命令更改为 `yarn build:diy` 输出地址改为 `diy/diy-dist` 即可 。见下图: @@ -79,7 +79,7 @@ yarn build:diy ## 其他 -如果您想体验项目的完整功能,则需要注册一个 [Bmob](https://www.bmobapp.com/) 账号, +如果您想体验项目的完整功能,则需要注册一个 [Bmob](https://www.bmobapp.com/) 账号, 注册后新建应用(有一年的白嫖版,免费请求数虽然很客观,但并发数有限制,请根据自己的实际流量 选择升级套餐,或者其他存储方案) @@ -94,9 +94,6 @@ ps: 如果您的项目托管在公共仓库中,请注意保护密钥,本地 `config` 表用来存储自定义配置的 json 字符串,需要新增 `content` 列 -`file` 表则是为了节省 vercel 流量,将一些默认文件转为 base64 字符串存到了数据库中,需要添加三列 -![img.png](database-file.png) - `rank` 表,储存排名信息 ![img.png](datebase-rank.png) diff --git a/diy/database-file.png b/diy/database-file.png deleted file mode 100644 index 6e8734f..0000000 Binary files a/diy/database-file.png and /dev/null differ diff --git a/src/main.tsx b/src/main.tsx index ca807ee..1d05e95 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -5,11 +5,7 @@ import './styles/global.scss'; import './styles/utils.scss'; import Bmob from 'hydrogen-js-sdk'; import { - DEFAULT_BGM_STORAGE_KEY, domRelatedOptForTheme, - LAST_LEVEL_STORAGE_KEY, - LAST_SCORE_STORAGE_KEY, - LAST_TIME_STORAGE_KEY, parsePathCustomThemeId, PLAYING_THEME_ID_STORAGE_KEY, resetScoreStorage, @@ -77,58 +73,37 @@ Bmob.initialize( import.meta.env.VITE_BMOB_SECCODE ); -const loadTheme = () => { - // 请求主题 - if (customThemeIdFromPath) { - const storageTheme = localStorage.getItem(customThemeIdFromPath); - if (storageTheme) { - try { - const customTheme = JSON.parse(storageTheme); - successTrans(customTheme); - } catch (e) { - errorTip('主题配置解析失败'); - } - } else { - Bmob.Query('config') - .get(customThemeIdFromPath) - .then((res) => { - const { content, increment } = res as any; - localStorage.setItem(customThemeIdFromPath, content); - try { - const customTheme = JSON.parse(content); - successTrans(customTheme); - } catch (e) { - errorTip('主题配置解析失败'); - } - // 统计访问次数 - increment('visitNum'); - // @ts-ignore - res.save(); - }) - .catch(({ error }) => { - errorTip(error); - }); +// 请求主题 +if (customThemeIdFromPath) { + const storageTheme = localStorage.getItem(customThemeIdFromPath); + if (storageTheme) { + try { + const customTheme = JSON.parse(storageTheme); + successTrans(customTheme); + } catch (e) { + errorTip('主题配置解析失败'); } } else { - successTrans(getDefaultTheme()); + Bmob.Query('config') + .get(customThemeIdFromPath) + .then((res) => { + const { content, increment } = res as any; + localStorage.setItem(customThemeIdFromPath, content); + try { + const customTheme = JSON.parse(content); + successTrans(customTheme); + } catch (e) { + errorTip('主题配置解析失败'); + } + // 统计访问次数 + increment('visitNum'); + // @ts-ignore + res.save(); + }) + .catch(({ error }) => { + errorTip(error); + }); } -}; - -// 音效资源请求 -if (!localStorage.getItem(DEFAULT_BGM_STORAGE_KEY)) { - const query = Bmob.Query('file'); - query.equalTo('type', '==', 'default'); - query - .find() - .then((results) => { - for (const file of results as any) { - localStorage.setItem(file.name, file.base64); - } - loadTheme(); - }) - .catch(({ error }) => { - errorTip(error); - }); } else { - loadTheme(); + successTrans(getDefaultTheme()); } diff --git a/src/themes/default/index.ts b/src/themes/default/index.ts index 451a3ee..703a3f5 100644 --- a/src/themes/default/index.ts +++ b/src/themes/default/index.ts @@ -1,9 +1,4 @@ import { Theme } from '../interface'; -import { - DEFAULT_BGM_STORAGE_KEY, - DEFAULT_CLICK_SOUND_STORAGE_KEY, - DEFAULT_TRIPLE_SOUND_STORAGE_KEY, -} from '../../utils'; const icons = [ `🎨`, @@ -36,16 +31,13 @@ export const getDefaultTheme: () => Theme = () => { sounds: [ { name: 'button-click', - src: - localStorage.getItem(DEFAULT_CLICK_SOUND_STORAGE_KEY) || '', + src: 'https://minio.streakingman.com/solvable-sheep-game/sound-button-click.mp3', }, { name: 'triple', - src: - localStorage.getItem(DEFAULT_TRIPLE_SOUND_STORAGE_KEY) || - '', + src: 'https://minio.streakingman.com/solvable-sheep-game/sound-triple.mp3', }, ], - bgm: localStorage.getItem(DEFAULT_BGM_STORAGE_KEY) || '', + bgm: 'https://minio.streakingman.com/solvable-sheep-game/sound-disco.mp3', }; }; diff --git a/src/utils.ts b/src/utils.ts index c5b69ea..a839da2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -9,9 +9,6 @@ export const LAST_CUSTOM_THEME_ID_STORAGE_KEY = 'lastCustomThemeId'; export const LAST_UPLOAD_TIME_STORAGE_KEY = 'lastUploadTime'; export const CUSTOM_THEME_STORAGE_KEY = 'customTheme'; export const CUSTOM_THEME_FILE_VALIDATE_STORAGE_KEY = 'customThemeFileValidate'; -export const DEFAULT_BGM_STORAGE_KEY = 'defaultBgm'; -export const DEFAULT_TRIPLE_SOUND_STORAGE_KEY = 'defaultTripleSound'; -export const DEFAULT_CLICK_SOUND_STORAGE_KEY = 'defaultClickSound'; export const USER_NAME_STORAGE_KEY = 'username'; export const USER_ID_STORAGE_KEY = 'userId'; export const PLAYING_THEME_ID_STORAGE_KEY = 'playingThemeId';