Commit 8c33e90c by 杨铁龙

run ok

parent 59755b9a
......@@ -17,14 +17,14 @@
"element-ui": "^2.15.7",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"register-service-worker": "^1.7.2",
"uniplat-sdk": "^0.1.320-private",
"vue": "^2.6.14",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.1",
"vuex": "^3.6.2",
"vuex-class": "^0.3.2"
"vuex-class": "^0.3.2",
"xchat-client": "^2.2.4"
},
"devDependencies": {
"@types/lodash": "^4.14.178",
......@@ -32,7 +32,6 @@
"@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-pwa": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-typescript": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
......@@ -76,6 +75,12 @@
"space-before-function-paren": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/camelcase": "off",
"prefer-promise-reject-errors": [
"error",
{
"allowEmptyReject": true
}
],
"no-useless-constructor": "off",
"@typescript-eslint/no-namespace": "off",
"camelcase": [
......
......@@ -3,7 +3,7 @@ export const config = {
passportApi: 'http://106.120.107.150:48090',
uniplatApi: 'http://hro.dev-xim-api.qqxb.jinsehuaqin.com:8800',
clientId: 'daai_bijie_wechat_mini_app',
uniplatSocketUrl: 'ws://channel.jinsehuaqin.com:8080/ws',
uniplatSocketUrl: 'ws://xchat-ds.jinsehuaqin.com:8010/ws',
clientSecret: '123456',
testAccount: process.env.VUE_APP_TEST_ACCOUNT,
testPassword: process.env.VUE_APP_TEST_PASSWORD,
......
Subproject commit ecca9b6f0f69a1fb3b624bd5e8e1321dc1eba2a0
Subproject commit d2b53e6d39a9644556009561456b07d5253e4e8e
import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import element from 'element-ui'
......
/* eslint-disable no-console */
import { register } from 'register-service-worker'
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
ready() {
console.log('App is being served from cache by a service worker.\n' + 'For more details, visit https://goo.gl/AFskqB')
},
registered() {
console.log('Service worker has been registered.')
},
cached() {
console.log('Content has been cached for offline use.')
},
updatefound() {
console.log('New content is downloading.')
},
updated() {
console.log('New content is available; please refresh.')
},
offline() {
console.log('No internet connection found. App is running in offline mode.')
},
error(error) {
console.error('Error during service worker registration:', error)
},
})
}
......@@ -5,13 +5,12 @@ import { ChatStore } from '@/customer-service/store/model'
import Chat from '@/customer-service/xim'
import store from '@/store'
import { throttle } from 'lodash'
import { sdk } from './sdk'
// import { sdk } from './sdk'
export function initChat() {
export function initChat(token: string) {
console.log('初始化chat')
return Chat.setup({
sdk: () => sdk.core,
orgId: () => sdk.orgId,
token,
connection: config.uniplatSocketUrl,
serviceType: ServiceType.Backend,
}).then(() => {
......
import { metaRow, SdkListRowPredict, SdkListRowPredictObject, UniplatSdk, UniplatSdkExtender } from 'uniplat-sdk'
import { config } from '@/config'
// import { metaRow, SdkListRowPredict, SdkListRowPredictObject, UniplatSdk, UniplatSdkExtender } from 'uniplat-sdk'
// import { config } from '@/config'
class Sdk {
private uniplatSdk!: UniplatSdk
private readonly handler = new UniplatSdkExtender()
private token!: string
public orgId!: string
// class Sdk {
// private uniplatSdk!: UniplatSdk
// private readonly handler = new UniplatSdkExtender()
// private token!: string
// public orgId!: string
constructor() {
// 从config获取目标服务器
const baseUrl = config.uniplatApi
// 生成uniplat实例
this.uniplatSdk = new UniplatSdk({ sse: false })
// 传入目标服务器以链接服务器
this.uniplatSdk.connect({
baseUrl: baseUrl,
axiosTimeout: 2e3,
})
}
// constructor() {
// // 从config获取目标服务器
// const baseUrl = config.uniplatApi
// // 生成uniplat实例
// this.uniplatSdk = new UniplatSdk({ sse: false })
// // 传入目标服务器以链接服务器
// this.uniplatSdk.connect({
// baseUrl: baseUrl,
// axiosTimeout: 2e3,
// })
// }
public setup(token: string) {
this.token = 'Bearer ' + token
// 设置实例根入口程序
this.uniplatSdk.global.rootEntrance = config.rootEntrance
// 添加Token过期时的回调
this.uniplatSdk.events.addTokenExpiring(() => {
console.log('token过期了')
})
// 传入token登录业务平台
return this.uniplatSdk
.getPassportLogin()
.login(this.token)
.then(() => {
return this.uniplatSdk
.org()
.loadList({ name: '', itemIndex: 0, itemSize: 10 })
.then((org) => {
if (org.list.length) {
this.orgId = String(org.list[0].id)
this.uniplatSdk.setInitData({
orgId: org.list[0].id,
})
} else {
throw Error('no Org')
}
})
})
}
// public setup(token: string) {
// this.token = 'Bearer ' + token
// // 设置实例根入口程序
// this.uniplatSdk.global.rootEntrance = config.rootEntrance
// // 添加Token过期时的回调
// this.uniplatSdk.events.addTokenExpiring(() => {
// console.log('token过期了')
// })
// // 传入token登录业务平台
// return this.uniplatSdk
// .getPassportLogin()
// .login(this.token)
// .then(() => {
// return this.uniplatSdk
// .org()
// .loadList({ name: '', itemIndex: 0, itemSize: 10 })
// .then((org) => {
// if (org.list.length) {
// this.orgId = String(org.list[0].id)
// this.uniplatSdk.setInitData({
// orgId: org.list[0].id,
// })
// } else {
// throw Error('no Org')
// }
// })
// })
// }
public get core() {
return this.uniplatSdk
}
// public get core() {
// return this.uniplatSdk
// }
public buildRows<T>(rows: metaRow[], predicts: SdkListRowPredict[] | SdkListRowPredictObject) {
return this.handler.buildRows<T>(rows, predicts)
}
// public buildRows<T>(rows: metaRow[], predicts: SdkListRowPredict[] | SdkListRowPredictObject) {
// return this.handler.buildRows<T>(rows, predicts)
// }
public buildRow<T>(item: metaRow, predicts: SdkListRowPredict[] | SdkListRowPredictObject) {
return this.handler.buildRow<T>(item, predicts)
}
// public buildRow<T>(item: metaRow, predicts: SdkListRowPredict[] | SdkListRowPredictObject) {
// return this.handler.buildRow<T>(item, predicts)
// }
public buildActionParameter(parameter: { [key: string]: any }) {
return this.handler.buildActionParameter(parameter)
}
}
// public buildActionParameter(parameter: { [key: string]: any }) {
// return this.handler.buildActionParameter(parameter)
// }
// }
const sdk = new Sdk()
// const sdk = new Sdk()
export { sdk }
// export { sdk }
......@@ -23,11 +23,8 @@
<script lang="ts">
import { Component } from "vue-property-decorator"
import { getPassportTokenByPassport } from "@/service/passport"
import { config } from "@/config"
import ChatList from "@/customer-service/components/controller/chat-list"
import { initChat } from "@/service/chat"
import { sdk } from "@/service/sdk"
import { Chat } from "@/customer-service/xim/models/chat"
import { ChatStore, chatStore } from "@/customer-service/store/model"
import ChatRoom from "@/customer-service/components/chat-room.vue"
......@@ -49,16 +46,23 @@
}
private init() {
return initChat(
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiJ0ZWFtaXgtYXBwLWFuZHJvaWQiLCJjb21yb2xlcyI6WyJDUkVBVE9SIiwiTUVNQkVSIiwiU1VQRVJBRE1JTiJdLCJlaWQiOiIxMSIsImVtcG5hbWUiOiLlvKDkuIkiLCJleHAiOjE2NTA4ODgxMjEsIm5zIjoid29ya2FwcHMiLCJvaWQiOiIxMSIsInVpZCI6IjExIn0.W3LAL1KBBJF8M1btiIyCsm1aXQP8XTb08yn-aGYsTAU"
)
// 登录统一认证中心passport
return getPassportTokenByPassport(config.testAccount, config.testPassword)
.then((token) => {
// 使用passport Token初始化sdk
return sdk.setup(token)
})
.then(() => {
// sdk初始化完后,chat使用全局sdk实例去初始化会话链接以及会话列表
return initChat()
})
// return getPassportTokenByPassport(config.testAccount, config.testPassword).then((token) => {
// // 使用passport Token初始化sdk
// })
// 登录统一认证中心passport
// return getPassportTokenByPassport(config.testAccount, config.testPassword)
// .then((token) => {
// // 使用passport Token初始化sdk
// return sdk.setup(token)
// })
// .then(() => {
// // sdk初始化完后,chat使用全局sdk实例去初始化会话链接以及会话列表
// return initChat()
// })
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment