From eaf9d508d41bfe31c8164473c757f1900e6b008d Mon Sep 17 00:00:00 2001 From: zdg Date: Fri, 27 Sep 2024 15:52:07 +0800 Subject: [PATCH] =?UTF-8?q?apt=E4=B8=8A=E8=AF=BE-=E6=97=A0=E9=9C=80?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/api/apiService.js | 10 +++++ .../views/prepare/container/class-start.vue | 41 +++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/api/apiService.js b/src/renderer/src/api/apiService.js index 0b28e0d..d5d1668 100644 --- a/src/renderer/src/api/apiService.js +++ b/src/renderer/src/api/apiService.js @@ -26,3 +26,13 @@ export class imChat { // 获取腾讯im-chat appid 签名 static getTxCloudSign = data => ApiService.publicHttp('/system/user/txCloudSign', data) } + +// zdg: url跳转-后端存储 +export class toLink { + // 设置链接-返回key(默认15分钟有效时间) + static setLink = url => ApiService.publicHttp(`/smarttalk/toLink`, {url}, 'post', null, 'form') + // 获取链接 + static getLink = key => ApiService.publicHttp(`/smarttalk/toLink/${key}`) + // 删除链接-缓存 + static delLink = key => ApiService.publicHttp(`/smarttalk/toLink/${key}`, null, 'delete') +} diff --git a/src/renderer/src/views/prepare/container/class-start.vue b/src/renderer/src/views/prepare/container/class-start.vue index f2a73e4..ed30234 100644 --- a/src/renderer/src/views/prepare/container/class-start.vue +++ b/src/renderer/src/views/prepare/container/class-start.vue @@ -85,12 +85,14 @@ import vueQr from 'vue-qr/src/packages/vue-qr.vue' // 插件: 二维码 import imChat from '@/views/tool/components/imChat.vue' // im-chat-子组件 import MsgEnum from '@/plugins/imChat/msgEnum' // 消息头-相关定义(nuem) import * as commUtil from '@/utils/comm' // 工具类-通用 -import { toLinkWeb, getStaticUrl } from '@/utils/tool' +import { toLinkWeb, getStaticUrl } from '@/utils/tool' // 工具类-主进程相关 import * as Http_ClassManage from '@/api/classManage' // api接口 import * as Http_Classcourse from '@/api/teaching/classcourse' // api接口 -import * as Http_Entpcoursefile from '@/api/education/entpcoursefile' // api接口 +import * as Http_Entpcoursefile from '@/api/education/entpcoursefile' // api接口 +import * as Http_api from '@/api/apiService' // api接口 import useUserStore from "@/store/modules/user" // 状态管理:user +import CryptoJS from 'crypto-js' const baseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH const userStore = useUserStore() @@ -189,9 +191,9 @@ const getClassList = async () => { }) if (res.code == 200) { listData.classList = (res.rows || []).map(o => { - if(!!o.classstudentlist) { // 学生列表转为数组 - o.classstudentlist = JSON.parse('[' + o.classstudentlist + ']') - } + // if(!!o.classstudentlist) { // 学生列表转为数组 + // o.classstudentlist = JSON.parse('[' + o.classstudentlist + ']') + // } return o }); // 默认选中第一项 @@ -277,11 +279,34 @@ const classTeachingStart = async () => { } } // 获取二维码地址 -const getQrUrl = () => { +const getQrUrl = async() => { const { classcourseid:id } = teacherForm.form - const { userName } = userStore.user + const { userName, userId } = userStore.user if (!id||!userName) return - const qrCodeUrl = `wxlogin?username=${userName}&nextaction=classteaching&id=${id}` + // 原始方法(需要wx登录) + // const qrCodeUrl = `wxlogin?username=${userName}&nextaction=classteaching&id=${id}` + // teacherForm.form.qrUrl = baseUrl + qrCodeUrl + // const baseUrl = 'https://localhost:7860' + // token跳转 + const url = `/teaching/classteachingonmobile?classcourseid=${id}` // 跳转移动端-上课 + let qrCodeUrl = '' // 移动端-二维码地址 + try { + // 走后端缓存url + const res = await Http_api.toLink.setLink(url) // 设置链接-缓存 + if (res.code == 200) { + const redisKey = res.data + const base64Key = CryptoJS.enc.Utf8.parse(redisKey).toString(CryptoJS.enc.Base64) // base64加密 + const enStrUrl = encodeURIComponent(base64Key) // url转码 + qrCodeUrl = `?_server=${enStrUrl}` + teacherForm.form.qrUrl = baseUrl + qrCodeUrl + } + } catch (error) { // 异常, 直接加密token + const jsonStr = JSON.stringify({ url, token: userStore.token }) // json数据:{url, token} + const key = `Ax19i14Ga6qEDOkGTo` // AES加密-key + const enStr = CryptoJS.AES.encrypt(jsonStr, key).toString() // AES加密-数据 + const enStrUrl = encodeURIComponent(enStr) // url转码 + qrCodeUrl = `?_web=${enStrUrl}` + } teacherForm.form.qrUrl = baseUrl + qrCodeUrl }