chat-app/src/main.js

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-11-11 06:46:14 +00:00
import { createSSRApp } from 'vue'
import App from './App.vue'
import dayjs from "dayjs";
import 'virtual:uno.css'
import VConsole from "vconsole";
import '@/utils/uni.webview.js'
import tmui from "@/uni_modules/tmui"
import {config} from "@/config/tmui/index.js";
import 'dayjs/locale/zh-cn';
import xLoaderror from '@/components/x-loaderror/index.vue'
import { vLoading } from "@/components/x-loading/index.js"
import messagePopup from '@/components/x-message/useMessagePopup'
import pageAnimation from '@/components/page-animation/index.vue'
2024-11-22 01:06:37 +00:00
import * as plugins from './plugins'
2024-11-11 06:46:14 +00:00
const {showMessage}=messagePopup()
dayjs.locale('zh-cn')
if (import.meta.env.VITE_SHOW_CONSOLE){
new VConsole()
}
export function createApp() {
const app = createSSRApp(App)
2024-11-22 01:06:37 +00:00
plugins.setPinia(app)
plugins.setComponents(app)
2024-11-28 08:55:45 +00:00
app.use(tmui,{...config})
2024-11-11 06:46:14 +00:00
app.directive("loading", vLoading)
app.mixin(pageAnimation)
app.component('x-loaderror',xLoaderror)
app.directive('no-space', {
mounted(el) {
el.addEventListener('input', (e) => {
const originalValue = e.target.value;
const newValue = originalValue.replace(/\s/g, '');
if (originalValue !== newValue) {
e.target.value = newValue;
e.target.dispatchEvent(new Event('input'));
}
});
}
})
window.message = ['success', 'error', 'warning'].reduce((acc, type) => {
acc[type] = (message) => {
if (typeof message === 'string') {
showMessage({ type, message });
} else if (typeof message === 'object') {
showMessage({ type, ...message });
}
};
return acc;
}, {});
return {
app,
}
}
createApp()