| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import App from './App.vue'
- import { createSSRApp } from 'vue'
- import store from './store'
- import uViewPlus, { props as uviewProps } from 'uview-plus'
- if (process.env.NODE_ENV === 'development') {
- console.log('%c[Mock] 开发模式已启用', 'color: green; font-weight: bold;');
- console.log('%c[Mock] 请启动Mock服务器: node mock-server.js', 'color: blue;');
- console.log('%c[Mock] 服务器地址: http://localhost:3001', 'color: blue;');
- }
- // http 拦截器与 API 需在 app 创建后注册
- import request from '@/utils/request.js'
- import httpApi from '@/utils/api.js'
- import hideNav from '@/utils/hideNav.js'
- import doubleTap from '@/utils/doubleTap.js'
- import common from '@/utils/common.js'
- import globalMinxins from '@/mixins'
- export function createApp() {
- const app = createSSRApp(App)
- app.use(store)
- app.use(uViewPlus)
- // 兼容依赖 uni.$u.props 的组件(如异步加载的 uview-plus 组件或 uni_modules 内旧 uview-ui)
- if (typeof uni !== 'undefined' && uni.$u && typeof uni.$u.props === 'undefined') {
- uni.$u.props = uviewProps
- }
- app.use(request)
- app.use(httpApi)
- app.use(hideNav)
- app.use(doubleTap)
- app.use(common)
- app.config.globalProperties.$getDicts = function (dictType, customFlag = true) {
- return store.dispatch('dict/getDicts', { dictType, customFlag })
- }
- app.mixin(globalMinxins)
- return { app }
- }
|