// 1. 先导入必要依赖(注意顺序) import App from './App' import uviewPlus from '@/uni_modules/uview-plus' // 导入 Pinia 实例(你的 stores/index.js 导出的 pinia) import pinia from '@/pinia/index' import EmptyView from '@/components/empty-view/empty-view.vue'; import UploadImage from '@/components/upload-image/upload-image.vue'; // #ifdef VUE3 import { createSSRApp } from 'vue' export function createApp() { // 2. 创建 Vue 实例 const app = createSSRApp(App) // 3. 注册 uviewPlus(保持原有逻辑) app.use(uviewPlus) // 4. 注册 Pinia(核心:在 app 挂载前注册) app.use(pinia) app.component('EmptyView', EmptyView) app.component('UploadImage', UploadImage) // 5. 返回 app + pinia(可选,便于调试) return { app, pinia } } // #endif // 全局注册(可选):如果需要全局使用,可在 main.js 中注册为全局方法: // javascript // 运行 // import { createSSRApp } from 'vue'; // import * as dictUtils from '@/utils/dict'; // // export function createApp() { // const app = createSSRApp(App); // // 注册全局字典方法 // app.config.globalProperties.$dict = dictUtils; // return { app }; // } // 组件中使用: // javascript // 运行 // import { getCurrentInstance } from 'vue'; // const { proxy } = getCurrentInstance(); // const label = proxy.$dict.getDictLabel('ai_image_status', 10);