Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions scripts/generate-sound-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// 音频文件路径
const soundsDir = path.join(__dirname, '../src/assets/sounds');
const soundsDir = path.join(__dirname, '../public/sounds');
const outputFile = path.join(__dirname, '../src/utils/soundList.js');

// 读取音频文件
Expand Down Expand Up @@ -53,9 +53,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}\`;
}

// 播放音频文件
Expand Down
6 changes: 3 additions & 3 deletions src/components/settings/NotificationSoundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/soundList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

// 播放音频文件
Expand Down
Loading