Commit afe7d434 authored by love_飞影's avatar love_飞影 Committed by Chunchi Che

style: function style lint

parent 822d4a64
......@@ -10,34 +10,34 @@ const sourceDb = createStore(AUDIO_DB_NAME, "sources");
const { assetsPath } = useConfig();
/** 从网络加载音频资源 */
async function _loadFromNet(name: string) {
async function loadFromNet(name: string) {
const prefix = `${assetsPath}/sound/`;
const response = await fetch(`${prefix}${name}`);
const fileBlob = await response.arrayBuffer();
_cacheResource(name, fileBlob);
cacheResource(name, fileBlob);
return fileBlob;
}
/** 从缓存中加载音频资源 */
function _loadFromCache(name: string) {
function loadFromCache(name: string) {
return get(name, sourceDb);
}
/** 缓存资源 */
function _cacheResource(name: string, fileBlob: ArrayBuffer) {
function cacheResource(name: string, fileBlob: ArrayBuffer) {
set(name, fileBlob, sourceDb);
}
/** 加载音频资源 */
export async function loadAudio(name: string) {
// 从缓存资源获取
const cachedFile = await _loadFromCache(name);
const cachedFile = await loadFromCache(name);
if (cachedFile) {
return cachedFile;
}
// 从网络获取
const fileBlob = await _loadFromNet(name);
const fileBlob = await loadFromNet(name);
return fileBlob;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment