Files
Nekosonic-Music/src/composables/useToast.ts
Atdunbg 7847a9f6b2 feat: 跨平台持久化与版本管理优化
- Cookie 存储从 temp_dir 迁移至 Tauri app_data_dir,兼容 Linux
- 简单统一风格,UI优化
- recentLocal 播放历史持久化到 localStorage
- 添加设置界面可以修改简单的设置
2026-05-12 09:58:07 +08:00

23 lines
512 B
TypeScript

import { ref } from 'vue';
export interface Toast {
id: number;
message: string;
type: 'success' | 'error' | 'info';
}
const toasts = ref<Toast[]>([]);
let nextId = 0;
export function showToast(message: string, type: 'success' | 'error' | 'info' = 'info', duration = 3000) {
const id = nextId++;
toasts.value.push({ id, message, type });
setTimeout(() => {
toasts.value = toasts.value.filter(t => t.id !== id);
}, duration);
}
export function useToast() {
return { toasts, showToast };
}