You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
3.0 KiB

import App from './App'
import request from './common/request';
import emotion from './common/emotion.js';
import url from './common/url.js';
import str from './common/str.js';
import * as enums from './common/enums.js';
import * as date from './common/date';
import * as socketApi from './common/wssocket';
import * as messageType from './common/messageType';
import { createSSRApp } from 'vue'
import uviewPlus from '@/uni_modules/uview-plus'
import * as pinia from 'pinia';
// i18n
import { createI18n } from 'vue-i18n'
import zh from './static/i18n/zh.json';
import en from './static/i18n/en.json'
import jp from './static/i18n/jp.json';
import kor from './static/i18n/kor.json'
import vie from './static/i18n/vie.json';
import ru from './static/i18n/ru.json'
import de from './static/i18n/de.json'
import fra from './static/i18n/fra.json'
import pt from './static/i18n/pt.json'
import ara from './static/i18n/ara.json'
const savedLang = uni.getStorageSync('app_language') || 'zh'
const i18n = createI18n({
legacy: false,
locale: savedLang,
messages: { zh, en, jp, kor, vie, ru, de, fra, pt, ara }
})
import useChatStore from '@/store/chatStore.js'
import useFriendStore from '@/store/friendStore.js'
import useGroupStore from '@/store/groupStore.js'
import useConfigStore from '@/store/configStore.js'
import useUserStore from '@/store/userStore.js'
import barGroup from '@/components/bar/bar-group'
import arrowBar from '@/components/bar/arrow-bar'
import btnBar from '@/components/bar/btn-bar'
import switchBar from '@/components/bar/switch-bar'
// #ifdef H5
import * as recorder from './common/recorder-h5';
import ImageResize from "quill-image-resize-mp";
import Quill from "quill";
window.Quill = Quill;
window.ImageResize = { default: ImageResize };
// #endif
// #ifndef H5
import * as recorder from './common/recorder-app';
// #endif
export function createApp() {
const app = createSSRApp(App)
app.use(uviewPlus);
app.use(pinia.createPinia());
app.use(i18n);
app.component('bar-group', barGroup);
app.component('arrow-bar', arrowBar);
app.component('btn-bar', btnBar);
app.component('switch-bar', switchBar);
app.config.globalProperties.$http = request;
app.config.globalProperties.$wsApi = socketApi;
app.config.globalProperties.$msgType = messageType;
app.config.globalProperties.$emo = emotion;
app.config.globalProperties.$url = url;
app.config.globalProperties.$str = str;
app.config.globalProperties.$enums = enums;
app.config.globalProperties.$date = date;
app.config.globalProperties.$rc = recorder;
app.config.globalProperties.$t = i18n.global.t;
// 把 i18n 挂到全局,让页面能访问到
app.config.globalProperties.$i18n = i18n.global;
app.config.globalProperties.$mountStore = () => {
app.config.globalProperties.chatStore = useChatStore();
app.config.globalProperties.friendStore = useFriendStore();
app.config.globalProperties.groupStore = useGroupStore();
app.config.globalProperties.configStore = useConfigStore();
app.config.globalProperties.userStore = useUserStore();
}
return { app, pinia }
}