Commit 6547881d by 杨铁龙

step commit

parent 8c33e90c
VUE_APP_TEST_ACCOUNT="15132146321" VUE_APP_TEST_ACCOUNT="15132146321"
VUE_APP_TEST_PASSWORD="erhao521" VUE_APP_TEST_PASSWORD="erhao521"
VUE_APP_ROOT_ENTRANCE="城市就业服务平台-求职招聘服务" \ No newline at end of file
\ No newline at end of file
VUE_APP_TEST_ACCOUNT="18040417207" VUE_APP_TEST_ACCOUNT="18040417207"
VUE_APP_TEST_PASSWORD="y1234567" VUE_APP_TEST_PASSWORD="y1234567"
VUE_APP_ROOT_ENTRANCE="大爱毕节小程序" \ No newline at end of file
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"axios": "^0.26.0", "axios": "^0.26.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"element-ui": "^2.15.7", "element-ui": "^2.15.7",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment": "^2.29.1", "moment": "^2.29.1",
"uniplat-sdk": "^0.1.320-private", "uniplat-sdk": "^0.1.320-private",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"axios": "^0.26.0", "axios": "^0.26.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"element-ui": "^2.15.7", "element-ui": "^2.15.7",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment": "^2.29.1", "moment": "^2.29.1",
"uniplat-sdk": "^0.1.320-private", "uniplat-sdk": "^0.1.320-private",
...@@ -96,4 +97,4 @@ ...@@ -96,4 +97,4 @@
"last 2 versions", "last 2 versions",
"not dead" "not dead"
] ]
} }
\ No newline at end of file
export const config = { export const config = {
passportUrl: 'http://106.120.107.150:45000', chatApi: 'http://xchat-ds.jinsehuaqin.com:8020/chat/api',
passportApi: 'http://106.120.107.150:48090', SocketUrl: 'ws://xchat-ds.jinsehuaqin.com:8010/ws',
uniplatApi: 'http://hro.dev-xim-api.qqxb.jinsehuaqin.com:8800',
clientId: 'daai_bijie_wechat_mini_app',
uniplatSocketUrl: 'ws://xchat-ds.jinsehuaqin.com:8010/ws',
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,
rootEntrance: process.env.VUE_APP_ROOT_ENTRANCE,
} }
Subproject commit d2b53e6d39a9644556009561456b07d5253e4e8e Subproject commit ea7926705a5bec75deda2d2faa7ad5477c0fec26
/* eslint-disable */
import axios from 'axios'
// create an axios instance
const service = axios.create({
timeout: 5000,
})
service.interceptors.request.use(
(config: any) => {
config.headers.Authorization = localStorage.JWT_TOKEN || ''
return config
},
(error: any) => {
return Promise.reject(error)
}
)
service.interceptors.response.use(
(response: any) => {
const res = response.data
if (res.rescode !== 0) {
console.log(res.msg || 'Error')
return Promise.reject(new Error(res.msg || 'Error'))
} else {
return res.data
}
},
(error: string) => {
return Promise.reject(error)
}
)
export default service
...@@ -5,13 +5,18 @@ import { ChatStore } from '@/customer-service/store/model' ...@@ -5,13 +5,18 @@ 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 { cache } from './user'
// import { sdk } from './sdk' // import { sdk } from './sdk'
export function initChat(token: string) { export function initChat() {
console.log('初始化chat') console.log('初始化chat')
const token = localStorage.getItem(cache.chatApiToken)
if (!token) {
return Promise.reject()
}
return Chat.setup({ return Chat.setup({
token, token,
connection: config.uniplatSocketUrl, connection: config.SocketUrl,
serviceType: ServiceType.Backend, serviceType: ServiceType.Backend,
}).then(() => { }).then(() => {
console.log('初始化chat✅ 开始获取和监听消息列表') console.log('初始化chat✅ 开始获取和监听消息列表')
......
import { config } from '@/config'
import axios from 'axios'
import qs from 'qs'
const baseAuthParams = {
client_id: config.clientId,
client_secret: config.clientSecret,
}
export interface TokenResponse {
access_token: string
}
function getAnonymousToken() {
return axios
.post<TokenResponse>(
`${config.passportUrl}/connect/token`,
qs.stringify({
...baseAuthParams,
grant_type: 'anonymous',
scope: 'api.workapps.open',
}),
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}
)
.then((r) => r.data.access_token)
}
export function getPassportTokenByPassport(username: string, password: string) {
return getAnonymousToken().then((token) => {
return axios
.post<TokenResponse>(
`${config.passportUrl}/connect/token`,
qs.stringify({
...baseAuthParams,
grant_type: 'password',
scope: 'openid workapps.client api.workapps.open api.workapps.user',
username,
password,
}),
{
headers: {
'content-type': 'application/x-www-form-urlencoded',
Authorization: 'Bearer ' + token,
},
}
)
.then((r) => r.data.access_token)
})
}
// 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
// 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 get core() {
// return this.uniplatSdk
// }
// 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 buildActionParameter(parameter: { [key: string]: any }) {
// return this.handler.buildActionParameter(parameter)
// }
// }
// const sdk = new Sdk()
// export { sdk }
import { config } from '@/config'
import { randomString } from '@/utils'
import axios from 'axios'
export const cache = {
chatApiOrgId: 'chatApiOrgId',
chatApiToken: 'chatApiToken',
}
export function buildHeaders() {
return {
headers: {
'content-type': 'application/x-www-form-urlencoded',
Authorization: 'Bearer ' + localStorage.getItem(cache.chatApiToken),
},
}
}
export interface CreateChat {
// 成员uid
members: string[]
title: string
}
function createChat(data: CreateChat) {
const d = {
members: data.members.map((i) => {
return {
uid: i,
eid: i,
oid: i,
}
}),
title: data.title,
org_id: localStorage.getItem(cache.chatApiOrgId),
chat_type: 'users',
biz_id: randomString(32),
}
return axios
.post(`${config.chatApi}/add_xchat`, d, buildHeaders())
.then((r) => r.data.access_token)
}
import { cache } from '@/service/user'
import jwtDecode from 'jwt-decode'
export function randomString(e: number) {
e = e || 32
const t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
const a = t.length
let n = ''
for (let i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a))
return n
}
export function getUid() {
const token = localStorage.getItem(cache.chatApiToken)
if (!token) {
return ''
}
return jwtDecode<{ eid: string }>(token).eid
}
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
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"
import { getUid } from "@/utils"
@Component({ @Component({
components: { ChatRoom }, components: { ChatRoom },
}) })
...@@ -42,27 +43,15 @@ ...@@ -42,27 +43,15 @@
private openChat(item: Chat) { private openChat(item: Chat) {
this.dislogVisible = true this.dislogVisible = true
this.saveChatId(item.id) // 打开会话
this.saveChatId({
chatId: item.id,
uid: +getUid(),
})
} }
private init() { private init() {
return initChat( return initChat()
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiJ0ZWFtaXgtYXBwLWFuZHJvaWQiLCJjb21yb2xlcyI6WyJDUkVBVE9SIiwiTUVNQkVSIiwiU1VQRVJBRE1JTiJdLCJlaWQiOiIxMSIsImVtcG5hbWUiOiLlvKDkuIkiLCJleHAiOjE2NTA4ODgxMjEsIm5zIjoid29ya2FwcHMiLCJvaWQiOiIxMSIsInVpZCI6IjExIn0.W3LAL1KBBJF8M1btiIyCsm1aXQP8XTb08yn-aGYsTAU"
)
// 登录统一认证中心passport
// 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> </script>
......
...@@ -5,11 +5,13 @@ const pro = process.env.NODE_ENV === 'production' ...@@ -5,11 +5,13 @@ const pro = process.env.NODE_ENV === 'production'
module.exports = defineConfig({ module.exports = defineConfig({
transpileDependencies: true, transpileDependencies: true,
// chainWebpack: (config) => { chainWebpack: (config) => {
// config.plugin('ignoreMoment').use(webpack.ContextReplacementPlugin, [/moment[/\\]locale$/, /zh-cn/]) config
.plugin('ignoreMoment')
.use(webpack.ContextReplacementPlugin, [/moment[/\\]locale$/, /zh-cn/])
// config.plugin('lodash').use(webpack.ProvidePlugin, [{ _: 'lodash' }]) config.plugin('lodash').use(webpack.ProvidePlugin, [{ _: 'lodash' }])
// }, },
configureWebpack: (config) => { configureWebpack: (config) => {
// 配置别名等放到这里 // 配置别名等放到这里
...@@ -17,7 +19,10 @@ module.exports = defineConfig({ ...@@ -17,7 +19,10 @@ module.exports = defineConfig({
if (!pro) { if (!pro) {
config.output.devtoolModuleFilenameTemplate = (info) => { config.output.devtoolModuleFilenameTemplate = (info) => {
const resPath = info.resourcePath const resPath = info.resourcePath
if ((/\.vue$/.test(resPath) && !/type=script/.test(info.identifier)) || /node_modules/.test(resPath)) { if (
(/\.vue$/.test(resPath) && !/type=script/.test(info.identifier)) ||
/node_modules/.test(resPath)
) {
return `webpack:///${resPath}?${info.hash}` return `webpack:///${resPath}?${info.hash}`
} }
return `webpack:///${resPath.replace('./src', 'my-code/src')}` return `webpack:///${resPath.replace('./src', 'my-code/src')}`
......
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