import { createSSRApp } from 'vue' import { createPinia } from 'pinia' import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' import App from './App.vue' import audioManager from './audioManager' export function createApp() { const app = createSSRApp(App) const pinia = createPinia() pinia.use(piniaPluginPersistedstate) app.use(pinia) /** * 全局点击音效工具函数,用于在任意按钮/元素点击时自动播放音效。 * 用法:@click="$clickSound(handler)" 或 @click="$clickSound(() => doSomething())" * @param {Function} handler - 原始点击回调函数(可选,点击时直接调用) * @param {string} [soundKey='点击按钮'] - audioManager 中的音效 key */ app.config.globalProperties.$clickSound = (handler, soundKey = '点击按钮') => { audioManager.play(soundKey); if (typeof handler === 'function') handler(); }; return { app } }