mirror of
https://ghproxy.com/https://github.com/StreakingMan/solvable-sheep-game
synced 2025-05-23 19:41:07 +08:00
fix: 音频文件切换为minio外链
This commit is contained in:
parent
ffabf6805f
commit
680811c50c
|
@ -68,8 +68,8 @@ yarn dev:diy
|
||||||
yarn build:diy
|
yarn build:diy
|
||||||
```
|
```
|
||||||
|
|
||||||
会在 `diy/diy-dist` 下生成静态资源,直接将这些文件复制服务器上做代理即可。如果嫌麻烦,推荐使用 [vercel](https://vercel.com/)
|
会在 `diy/diy-dist` 下生成静态资源,直接将这些文件复制服务器上做代理即可。如果嫌麻烦,推荐使用 [vercel](https://vercel.com/)
|
||||||
一键部署(每月免费 100G 流量), 将更改后的项目推到自己的 github(gitlab,bitbucket 同样支持)仓库,
|
一键部署(每月免费 100G 流量), 将更改后的项目推到自己的 github(gitlab,bitbucket 同样支持)仓库,
|
||||||
使用 github 账号登录 vercel 后导入该项目,构建模版选择 vite,
|
使用 github 账号登录 vercel 后导入该项目,构建模版选择 vite,
|
||||||
构建命令更改为 `yarn build:diy` 输出地址改为 `diy/diy-dist` 即可 。见下图:
|
构建命令更改为 `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` 列
|
`config` 表用来存储自定义配置的 json 字符串,需要新增 `content` 列
|
||||||
|
|
||||||
`file` 表则是为了节省 vercel 流量,将一些默认文件转为 base64 字符串存到了数据库中,需要添加三列
|
|
||||||

|
|
||||||
|
|
||||||
`rank` 表,储存排名信息
|
`rank` 表,储存排名信息
|
||||||

|

|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 58 KiB |
83
src/main.tsx
83
src/main.tsx
|
@ -5,11 +5,7 @@ import './styles/global.scss';
|
||||||
import './styles/utils.scss';
|
import './styles/utils.scss';
|
||||||
import Bmob from 'hydrogen-js-sdk';
|
import Bmob from 'hydrogen-js-sdk';
|
||||||
import {
|
import {
|
||||||
DEFAULT_BGM_STORAGE_KEY,
|
|
||||||
domRelatedOptForTheme,
|
domRelatedOptForTheme,
|
||||||
LAST_LEVEL_STORAGE_KEY,
|
|
||||||
LAST_SCORE_STORAGE_KEY,
|
|
||||||
LAST_TIME_STORAGE_KEY,
|
|
||||||
parsePathCustomThemeId,
|
parsePathCustomThemeId,
|
||||||
PLAYING_THEME_ID_STORAGE_KEY,
|
PLAYING_THEME_ID_STORAGE_KEY,
|
||||||
resetScoreStorage,
|
resetScoreStorage,
|
||||||
|
@ -77,58 +73,37 @@ Bmob.initialize(
|
||||||
import.meta.env.VITE_BMOB_SECCODE
|
import.meta.env.VITE_BMOB_SECCODE
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadTheme = () => {
|
// 请求主题
|
||||||
// 请求主题
|
if (customThemeIdFromPath) {
|
||||||
if (customThemeIdFromPath) {
|
const storageTheme = localStorage.getItem(customThemeIdFromPath);
|
||||||
const storageTheme = localStorage.getItem(customThemeIdFromPath);
|
if (storageTheme) {
|
||||||
if (storageTheme) {
|
try {
|
||||||
try {
|
const customTheme = JSON.parse(storageTheme);
|
||||||
const customTheme = JSON.parse(storageTheme);
|
successTrans(customTheme);
|
||||||
successTrans(customTheme);
|
} catch (e) {
|
||||||
} catch (e) {
|
errorTip('主题配置解析失败');
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
loadTheme();
|
successTrans(getDefaultTheme());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
import { Theme } from '../interface';
|
import { Theme } from '../interface';
|
||||||
import {
|
|
||||||
DEFAULT_BGM_STORAGE_KEY,
|
|
||||||
DEFAULT_CLICK_SOUND_STORAGE_KEY,
|
|
||||||
DEFAULT_TRIPLE_SOUND_STORAGE_KEY,
|
|
||||||
} from '../../utils';
|
|
||||||
|
|
||||||
const icons = <const>[
|
const icons = <const>[
|
||||||
`🎨`,
|
`🎨`,
|
||||||
|
@ -36,16 +31,13 @@ export const getDefaultTheme: () => Theme<DefaultSoundNames> = () => {
|
||||||
sounds: [
|
sounds: [
|
||||||
{
|
{
|
||||||
name: 'button-click',
|
name: 'button-click',
|
||||||
src:
|
src: 'https://minio.streakingman.com/solvable-sheep-game/sound-button-click.mp3',
|
||||||
localStorage.getItem(DEFAULT_CLICK_SOUND_STORAGE_KEY) || '',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'triple',
|
name: 'triple',
|
||||||
src:
|
src: 'https://minio.streakingman.com/solvable-sheep-game/sound-triple.mp3',
|
||||||
localStorage.getItem(DEFAULT_TRIPLE_SOUND_STORAGE_KEY) ||
|
|
||||||
'',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
bgm: localStorage.getItem(DEFAULT_BGM_STORAGE_KEY) || '',
|
bgm: 'https://minio.streakingman.com/solvable-sheep-game/sound-disco.mp3',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,9 +9,6 @@ export const LAST_CUSTOM_THEME_ID_STORAGE_KEY = 'lastCustomThemeId';
|
||||||
export const LAST_UPLOAD_TIME_STORAGE_KEY = 'lastUploadTime';
|
export const LAST_UPLOAD_TIME_STORAGE_KEY = 'lastUploadTime';
|
||||||
export const CUSTOM_THEME_STORAGE_KEY = 'customTheme';
|
export const CUSTOM_THEME_STORAGE_KEY = 'customTheme';
|
||||||
export const CUSTOM_THEME_FILE_VALIDATE_STORAGE_KEY = 'customThemeFileValidate';
|
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_NAME_STORAGE_KEY = 'username';
|
||||||
export const USER_ID_STORAGE_KEY = 'userId';
|
export const USER_ID_STORAGE_KEY = 'userId';
|
||||||
export const PLAYING_THEME_ID_STORAGE_KEY = 'playingThemeId';
|
export const PLAYING_THEME_ID_STORAGE_KEY = 'playingThemeId';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user