Fix notification sounds not loading after build by moving to public folder

Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-18 00:54:57 +00:00
co-authored by Sunwuyuan
parent e8014c499d
commit d09d135254
38 changed files with 10 additions and 10 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -242,9 +242,9 @@ export default {
getSoundPath(filename) {
if (!filename) return null;
try {
// 使用相对于public目录的路径,这样Vite不会在构建时打包所有音频
// 而是按需加载
return `/src/assets/sounds/${filename}`;
// 使用public目录路径,Vite会在构建时将public目录的文件复制到dist根目录
// 这样开发和生产环境都能正确加载音频文件
return `/sounds/${filename}`;
} catch {
return null;
}
+3 -3
View File
@@ -52,9 +52,9 @@ export const defaultUrgentSound = 'Teams 默认通话铃.mp3';
// 获取音频文件的完整路径
export function getSoundPath(filename) {
if (!filename) return null;
// 使用动态路径,避免Vite在构建时加载所有音频文件
// 这样只有在真正需要播放时才会加载对应的音频文件
return `/src/assets/sounds/${filename}`;
// 使用public目录路径,Vite会在构建时将public目录的文件复制到dist根目录
// 这样开发和生产环境都能正确加载音频文件
return `/sounds/${filename}`;
}
// 播放音频文件