Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
afe7d434
Commit
afe7d434
authored
Apr 14, 2024
by
love_飞影
Committed by
Chunchi Che
May 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: function style lint
parent
822d4a64
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
src/infra/audio/core/resource.ts
src/infra/audio/core/resource.ts
+6
-6
No files found.
src/infra/audio/core/resource.ts
View file @
afe7d434
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment