Commit 8c33e90c by 杨铁龙

run ok

parent 59755b9a
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
"element-ui": "^2.15.7", "element-ui": "^2.15.7",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment": "^2.29.1", "moment": "^2.29.1",
"register-service-worker": "^1.7.2",
"uniplat-sdk": "^0.1.320-private", "uniplat-sdk": "^0.1.320-private",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-class-component": "^7.2.3", "vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2", "vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.1", "vue-router": "^3.5.1",
"vuex": "^3.6.2", "vuex": "^3.6.2",
"vuex-class": "^0.3.2" "vuex-class": "^0.3.2",
"xchat-client": "^2.2.4"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.14.178", "@types/lodash": "^4.14.178",
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
"@typescript-eslint/parser": "^5.4.0", "@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~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-router": "~5.0.0",
"@vue/cli-plugin-typescript": "~5.0.0", "@vue/cli-plugin-typescript": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0", "@vue/cli-plugin-vuex": "~5.0.0",
...@@ -76,6 +75,12 @@ ...@@ -76,6 +75,12 @@
"space-before-function-paren": "off", "space-before-function-paren": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/camelcase": "off", "@typescript-eslint/camelcase": "off",
"prefer-promise-reject-errors": [
"error",
{
"allowEmptyReject": true
}
],
"no-useless-constructor": "off", "no-useless-constructor": "off",
"@typescript-eslint/no-namespace": "off", "@typescript-eslint/no-namespace": "off",
"camelcase": [ "camelcase": [
......
...@@ -3,7 +3,7 @@ export const config = { ...@@ -3,7 +3,7 @@ export const config = {
passportApi: 'http://106.120.107.150:48090', passportApi: 'http://106.120.107.150:48090',
uniplatApi: 'http://hro.dev-xim-api.qqxb.jinsehuaqin.com:8800', uniplatApi: 'http://hro.dev-xim-api.qqxb.jinsehuaqin.com:8800',
clientId: 'daai_bijie_wechat_mini_app', clientId: 'daai_bijie_wechat_mini_app',
uniplatSocketUrl: 'ws://channel.jinsehuaqin.com:8080/ws', uniplatSocketUrl: 'ws://xchat-ds.jinsehuaqin.com:8010/ws',
clientSecret: '123456', clientSecret: '123456',
testAccount: process.env.VUE_APP_TEST_ACCOUNT, testAccount: process.env.VUE_APP_TEST_ACCOUNT,
testPassword: process.env.VUE_APP_TEST_PASSWORD, testPassword: process.env.VUE_APP_TEST_PASSWORD,
......
Subproject commit ecca9b6f0f69a1fb3b624bd5e8e1321dc1eba2a0 Subproject commit d2b53e6d39a9644556009561456b07d5253e4e8e
import Vue from 'vue' import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import './registerServiceWorker'
import router from './router' import router from './router'
import store from './store' import store from './store'
import element from 'element-ui' 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' ...@@ -5,13 +5,12 @@ import { ChatStore } from '@/customer-service/store/model'
import Chat from '@/customer-service/xim' import Chat from '@/customer-service/xim'
import store from '@/store' import store from '@/store'
import { throttle } from 'lodash' import { throttle } from 'lodash'
import { sdk } from './sdk' // import { sdk } from './sdk'
export function initChat() { export function initChat(token: string) {
console.log('初始化chat') console.log('初始化chat')
return Chat.setup({ return Chat.setup({
sdk: () => sdk.core, token,
orgId: () => sdk.orgId,
connection: config.uniplatSocketUrl, connection: config.uniplatSocketUrl,
serviceType: ServiceType.Backend, serviceType: ServiceType.Backend,
}).then(() => { }).then(() => {
......
import { metaRow, SdkListRowPredict, SdkListRowPredictObject, UniplatSdk, UniplatSdkExtender } from 'uniplat-sdk' // import { metaRow, SdkListRowPredict, SdkListRowPredictObject, UniplatSdk, UniplatSdkExtender } from 'uniplat-sdk'
import { config } from '@/config' // import { config } from '@/config'
class Sdk { // class Sdk {
private uniplatSdk!: UniplatSdk // private uniplatSdk!: UniplatSdk
private readonly handler = new UniplatSdkExtender() // private readonly handler = new UniplatSdkExtender()
private token!: string // private token!: string
public orgId!: string // public orgId!: string
constructor() { // constructor() {
// 从config获取目标服务器 // // 从config获取目标服务器
const baseUrl = config.uniplatApi // const baseUrl = config.uniplatApi
// 生成uniplat实例 // // 生成uniplat实例
this.uniplatSdk = new UniplatSdk({ sse: false }) // this.uniplatSdk = new UniplatSdk({ sse: false })
// 传入目标服务器以链接服务器 // // 传入目标服务器以链接服务器
this.uniplatSdk.connect({ // this.uniplatSdk.connect({
baseUrl: baseUrl, // baseUrl: baseUrl,
axiosTimeout: 2e3, // axiosTimeout: 2e3,
}) // })
} // }
public setup(token: string) { // public setup(token: string) {
this.token = 'Bearer ' + token // this.token = 'Bearer ' + token
// 设置实例根入口程序 // // 设置实例根入口程序
this.uniplatSdk.global.rootEntrance = config.rootEntrance // this.uniplatSdk.global.rootEntrance = config.rootEntrance
// 添加Token过期时的回调 // // 添加Token过期时的回调
this.uniplatSdk.events.addTokenExpiring(() => { // this.uniplatSdk.events.addTokenExpiring(() => {
console.log('token过期了') // console.log('token过期了')
}) // })
// 传入token登录业务平台 // // 传入token登录业务平台
return this.uniplatSdk // return this.uniplatSdk
.getPassportLogin() // .getPassportLogin()
.login(this.token) // .login(this.token)
.then(() => { // .then(() => {
return this.uniplatSdk // return this.uniplatSdk
.org() // .org()
.loadList({ name: '', itemIndex: 0, itemSize: 10 }) // .loadList({ name: '', itemIndex: 0, itemSize: 10 })
.then((org) => { // .then((org) => {
if (org.list.length) { // if (org.list.length) {
this.orgId = String(org.list[0].id) // this.orgId = String(org.list[0].id)
this.uniplatSdk.setInitData({ // this.uniplatSdk.setInitData({
orgId: org.list[0].id, // orgId: org.list[0].id,
}) // })
} else { // } else {
throw Error('no Org') // throw Error('no Org')
} // }
}) // })
}) // })
} // }
public get core() { // public get core() {
return this.uniplatSdk // return this.uniplatSdk
} // }
public buildRows<T>(rows: metaRow[], predicts: SdkListRowPredict[] | SdkListRowPredictObject) { // public buildRows<T>(rows: metaRow[], predicts: SdkListRowPredict[] | SdkListRowPredictObject) {
return this.handler.buildRows<T>(rows, predicts) // return this.handler.buildRows<T>(rows, predicts)
} // }
public buildRow<T>(item: metaRow, predicts: SdkListRowPredict[] | SdkListRowPredictObject) { // public buildRow<T>(item: metaRow, predicts: SdkListRowPredict[] | SdkListRowPredictObject) {
return this.handler.buildRow<T>(item, predicts) // return this.handler.buildRow<T>(item, predicts)
} // }
public buildActionParameter(parameter: { [key: string]: any }) { // public buildActionParameter(parameter: { [key: string]: any }) {
return this.handler.buildActionParameter(parameter) // return this.handler.buildActionParameter(parameter)
} // }
} // }
const sdk = new Sdk() // const sdk = new Sdk()
export { sdk } // export { sdk }
...@@ -23,11 +23,8 @@ ...@@ -23,11 +23,8 @@
<script lang="ts"> <script lang="ts">
import { Component } from "vue-property-decorator" 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 ChatList from "@/customer-service/components/controller/chat-list"
import { initChat } from "@/service/chat" import { initChat } from "@/service/chat"
import { sdk } from "@/service/sdk"
import { Chat } from "@/customer-service/xim/models/chat" import { Chat } from "@/customer-service/xim/models/chat"
import { ChatStore, chatStore } from "@/customer-service/store/model" import { ChatStore, chatStore } from "@/customer-service/store/model"
import ChatRoom from "@/customer-service/components/chat-room.vue" import ChatRoom from "@/customer-service/components/chat-room.vue"
...@@ -49,16 +46,23 @@ ...@@ -49,16 +46,23 @@
} }
private init() { private init() {
return initChat(
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiJ0ZWFtaXgtYXBwLWFuZHJvaWQiLCJjb21yb2xlcyI6WyJDUkVBVE9SIiwiTUVNQkVSIiwiU1VQRVJBRE1JTiJdLCJlaWQiOiIxMSIsImVtcG5hbWUiOiLlvKDkuIkiLCJleHAiOjE2NTA4ODgxMjEsIm5zIjoid29ya2FwcHMiLCJvaWQiOiIxMSIsInVpZCI6IjExIn0.W3LAL1KBBJF8M1btiIyCsm1aXQP8XTb08yn-aGYsTAU"
)
// 登录统一认证中心passport // 登录统一认证中心passport
return getPassportTokenByPassport(config.testAccount, config.testPassword) // return getPassportTokenByPassport(config.testAccount, config.testPassword).then((token) => {
.then((token) => { // // 使用passport Token初始化sdk
// 使用passport Token初始化sdk // })
return sdk.setup(token) // 登录统一认证中心passport
}) // return getPassportTokenByPassport(config.testAccount, config.testPassword)
.then(() => { // .then((token) => {
// sdk初始化完后,chat使用全局sdk实例去初始化会话链接以及会话列表 // // 使用passport Token初始化sdk
return initChat() // return sdk.setup(token)
}) // })
// .then(() => {
// // sdk初始化完后,chat使用全局sdk实例去初始化会话链接以及会话列表
// return initChat()
// })
} }
} }
</script> </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