2025-01-24 03:18:26 +00:00
|
|
|
|
import customNavbar from '@/components/custom-navbar/index'
|
|
|
|
|
|
2024-11-11 06:46:14 +00:00
|
|
|
|
import { createSSRApp } from 'vue'
|
|
|
|
|
import App from './App.vue'
|
2025-01-24 03:18:26 +00:00
|
|
|
|
import dayjs from 'dayjs'
|
2024-11-11 06:46:14 +00:00
|
|
|
|
import 'virtual:uno.css'
|
2025-01-24 03:18:26 +00:00
|
|
|
|
import VConsole from 'vconsole'
|
2024-11-11 06:46:14 +00:00
|
|
|
|
import '@/utils/uni.webview.js'
|
2025-01-24 03:18:26 +00:00
|
|
|
|
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'
|
2025-03-30 08:22:29 +00:00
|
|
|
|
import asyncLoading from '@/components/async-loading/index.vue'
|
|
|
|
|
import asyncError from '@/components/async-error/index.vue'
|
2025-01-24 03:18:26 +00:00
|
|
|
|
import { vLoading } from '@/components/x-loading/index.js'
|
2024-11-11 06:46:14 +00:00
|
|
|
|
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'
|
2025-04-10 03:30:56 +00:00
|
|
|
|
import { useDialogueStore, useTalkStore, useUserStore, useDialogueListStore } from '@/store'
|
|
|
|
|
import {uniStorage} from "@/utils/uniStorage.js"
|
2025-04-07 06:10:16 +00:00
|
|
|
|
|
2025-01-24 03:18:26 +00:00
|
|
|
|
const { showMessage } = messagePopup()
|
2024-11-11 06:46:14 +00:00
|
|
|
|
dayjs.locale('zh-cn')
|
2025-03-10 02:59:45 +00:00
|
|
|
|
if (import.meta.env.VITE_SHOW_CONSOLE === 'true') {
|
2024-11-11 06:46:14 +00:00
|
|
|
|
new VConsole()
|
|
|
|
|
}
|
|
|
|
|
export function createApp() {
|
|
|
|
|
const app = createSSRApp(App)
|
2024-11-22 01:06:37 +00:00
|
|
|
|
plugins.setPinia(app)
|
|
|
|
|
plugins.setComponents(app)
|
2025-01-24 03:18:26 +00:00
|
|
|
|
app.use(tmui, { ...config })
|
|
|
|
|
app.directive('loading', vLoading)
|
2024-11-11 06:46:14 +00:00
|
|
|
|
app.mixin(pageAnimation)
|
2025-01-24 03:18:26 +00:00
|
|
|
|
app.component('customNavbar', customNavbar)
|
|
|
|
|
app.component('x-loaderror', xLoaderror)
|
2025-03-30 08:22:29 +00:00
|
|
|
|
app.component('AsyncLoading', asyncLoading)
|
|
|
|
|
app.component('AsyncError', asyncError)
|
2024-11-11 06:46:14 +00:00
|
|
|
|
app.directive('no-space', {
|
|
|
|
|
mounted(el) {
|
|
|
|
|
el.addEventListener('input', (e) => {
|
2025-01-24 03:18:26 +00:00
|
|
|
|
const originalValue = e.target.value
|
|
|
|
|
const newValue = originalValue.replace(/\s/g, '')
|
2024-11-11 06:46:14 +00:00
|
|
|
|
if (originalValue !== newValue) {
|
2025-01-24 03:18:26 +00:00
|
|
|
|
e.target.value = newValue
|
|
|
|
|
e.target.dispatchEvent(new Event('input'))
|
2024-11-11 06:46:14 +00:00
|
|
|
|
}
|
2025-01-24 03:18:26 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
2024-11-11 06:46:14 +00:00
|
|
|
|
})
|
2025-03-19 11:58:23 +00:00
|
|
|
|
|
|
|
|
|
//获取当前聊天页面所在页面,并通过当前的receiver_id判断是否要创建本地通知栏消息
|
|
|
|
|
window.getCurrentChatRoute = (msg) => {
|
|
|
|
|
let pushMsg = JSON.parse(decodeURIComponent(msg))
|
|
|
|
|
//当前所在聊天会话的receiver_id
|
|
|
|
|
const receiver_id = pushMsg?.payload?.receiver_id
|
|
|
|
|
// 获取当前页面路径
|
|
|
|
|
const pages = getCurrentPages()
|
|
|
|
|
const page = pages[pages.length - 1]
|
|
|
|
|
console.log(page.route)
|
|
|
|
|
|
|
|
|
|
const dialogueStore = useDialogueStore()
|
|
|
|
|
console.log(dialogueStore?.talk?.receiver_id)
|
|
|
|
|
if (
|
|
|
|
|
page?.route === 'pages/dialog/index' &&
|
|
|
|
|
receiver_id === dialogueStore?.talk?.receiver_id
|
|
|
|
|
) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-03-25 05:12:06 +00:00
|
|
|
|
console.log('===准备创建本地通知栏消息')
|
2025-03-19 11:58:23 +00:00
|
|
|
|
let OAWebView = plus.webview.all()
|
2025-03-25 05:12:06 +00:00
|
|
|
|
OAWebView.forEach((webview, index) => {
|
|
|
|
|
if (webview.id === 'webviewId1') {
|
|
|
|
|
webview.evalJS(`doCreatePushMessage('${msg}')`)
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-03-19 11:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理聊天推送弹窗点开
|
|
|
|
|
window.openUniPushMsg = (msg) => {
|
2025-03-25 05:12:06 +00:00
|
|
|
|
console.log('=====点击通知栏消息')
|
2025-03-19 11:58:23 +00:00
|
|
|
|
let pushMsg = JSON.parse(decodeURIComponent(msg))
|
2025-03-25 05:12:06 +00:00
|
|
|
|
console.log('=====pushMsg', pushMsg)
|
2025-03-19 11:58:23 +00:00
|
|
|
|
//由于弹窗前处理了不该弹窗的场景,因此这里弹窗可以一并处理
|
|
|
|
|
//也就是都跳转到聊天页面
|
|
|
|
|
const talkStore = useTalkStore()
|
|
|
|
|
talkStore.toTalk(pushMsg?.payload?.talk_type, pushMsg?.payload?.receiver_id)
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-07 06:10:16 +00:00
|
|
|
|
//处理当用户信息发生变化时,更新用户信息
|
|
|
|
|
window.updateUserInfo = () => {
|
|
|
|
|
useUserStore().loadSetting()
|
|
|
|
|
}
|
2025-04-24 01:48:52 +00:00
|
|
|
|
// 通讯录跳转
|
|
|
|
|
window.handleContacts = () => {
|
2025-06-04 09:05:49 +00:00
|
|
|
|
// 旧版本-按组织架构树的通讯录
|
|
|
|
|
// uni.navigateTo({
|
|
|
|
|
// url: '/pages/chooseByDeps/index?chooseMode=3&type=true'
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// 新版本-按公司别、好友、群组的通讯录
|
2025-04-24 01:48:52 +00:00
|
|
|
|
uni.navigateTo({
|
2025-06-04 09:05:49 +00:00
|
|
|
|
url: '/pages/addressBook/index?type=true',
|
2025-04-24 01:48:52 +00:00
|
|
|
|
});
|
|
|
|
|
};
|
2025-04-07 06:10:16 +00:00
|
|
|
|
|
2025-04-09 11:06:07 +00:00
|
|
|
|
//处理OA、墨册强制刷新时,聊天同步强制刷新
|
|
|
|
|
window.doLocationRefresh = () => {
|
2025-04-10 03:30:56 +00:00
|
|
|
|
uniStorage.removeItem('dialogueList')
|
2025-04-25 02:38:47 +00:00
|
|
|
|
uniStorage.removeItem('dialogue')
|
2025-04-28 05:13:55 +00:00
|
|
|
|
useUserStore().loadSetting()
|
|
|
|
|
useDialogueListStore().dialogueList.value = []
|
|
|
|
|
// location.reload(true)
|
2025-04-09 11:06:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-23 05:39:25 +00:00
|
|
|
|
//检查聊天页面是否可用
|
|
|
|
|
window.checkChatWebviewAvailable = () => {
|
|
|
|
|
let OAWebView = plus.webview.all()
|
|
|
|
|
OAWebView.forEach((webview, index) => {
|
|
|
|
|
if (webview.id === 'webviewId1') {
|
|
|
|
|
webview.evalJS(`doneCheckChatWebviewAvailable()`)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 11:13:16 +00:00
|
|
|
|
//获取从base传来的多选视频列表
|
|
|
|
|
window.getBaseMulVideo = (videoList) => {
|
|
|
|
|
const videos = JSON.parse(decodeURIComponent(videoList))
|
|
|
|
|
console.error('=====videos', videos)
|
|
|
|
|
if(videos.length > 0){
|
|
|
|
|
const videoUri = videos[0]
|
|
|
|
|
console.error('=====videoUri', videoUri)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 06:46:14 +00:00
|
|
|
|
window.message = ['success', 'error', 'warning'].reduce((acc, type) => {
|
|
|
|
|
acc[type] = (message) => {
|
|
|
|
|
if (typeof message === 'string') {
|
2025-01-24 03:18:26 +00:00
|
|
|
|
showMessage({ type, message })
|
2024-11-11 06:46:14 +00:00
|
|
|
|
} else if (typeof message === 'object') {
|
2025-01-24 03:18:26 +00:00
|
|
|
|
showMessage({ type, ...message })
|
2024-11-11 06:46:14 +00:00
|
|
|
|
}
|
2025-01-24 03:18:26 +00:00
|
|
|
|
}
|
|
|
|
|
return acc
|
|
|
|
|
}, {})
|
2024-11-11 06:46:14 +00:00
|
|
|
|
return {
|
|
|
|
|
app,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
createApp()
|