提交 8c544a48 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 武汉软件工程职业学院对接第三方接口

上级 d128e96a
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# ============================================================ # ============================================================
# 产品系统(必填):ai | dml | default | x | game | swsjfxs | amo | nac # 产品系统(必填):ai | dml | default | x | game | swsjfxs | amo | nac
VITE_SYSTEM=ai VITE_SYSTEM=dml
# --- 以下为固定域名,无需修改 --- # --- 以下为固定域名,无需修改 ---
VITE_X_LEARNING_URL=https://x-learning.zijing.chat VITE_X_LEARNING_URL=https://x-learning.zijing.chat
......
...@@ -5,6 +5,17 @@ export function getUser() { ...@@ -5,6 +5,17 @@ export function getUser() {
return httpRequest.get('/api/lab/v1/common/permission/role') return httpRequest.get('/api/lab/v1/common/permission/role')
} }
// 第三方平台学生自动登录
export function thirdPartyLogin(params: {
token: string
code: string
un?: string
host?: string
sequenceCode?: string
}) {
return httpRequest.get('/api/lab/v1/common/permission/third-party-login', { params })
}
// 退出登录 // 退出登录
export function logout() { export function logout() {
return httpRequest.get('/api/passport/rest/logout') return httpRequest.get('/api/passport/rest/logout')
......
import { urls } from '@/utils/env' import { urls } from '@/utils/env'
const appConfigList = [ const appConfigList = [
{
system: 'dml',
title: '全媒体运营师一体化综合实训平台',
logo: '/images/logo.svg',
hosts: ['saas-dml-web'],
dmlURL: urls.dmlPro,
studentMenus: [
{ name: '首页', path: '/' },
{ name: '我的实验', path: '/student/lab' },
],
},
{ {
system: 'dml', system: 'dml',
title: '数字技能实践教学平台', title: '数字技能实践教学平台',
......
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useAppConfig } from '@/composables/useAppConfig' import { useAppConfig } from '@/composables/useAppConfig'
import { thirdPartyLogin } from '@/api/base'
const appConfig = useAppConfig() const appConfig = useAppConfig()
...@@ -9,6 +10,25 @@ const router = createRouter({ ...@@ -9,6 +10,25 @@ const router = createRouter({
routes: [{ path: '/:pathMatch(.*)*', redirect: '/' }], routes: [{ path: '/:pathMatch(.*)*', redirect: '/' }],
}) })
function queryValue(value: unknown) {
if (Array.isArray(value)) return String(value[0] || '')
return typeof value === 'string' ? value : ''
}
function getThirdPartyParams(query: Record<string, unknown>) {
const token = queryValue(query.token)
const code = queryValue(query.code)
if (!token || !code) return null
return {
token,
code,
un: queryValue(query.un),
host: queryValue(query.host),
sequenceCode: queryValue(query.sequenceCode),
}
}
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
if (window.location.host === 'dasai.ezijing.com') { if (window.location.host === 'dasai.ezijing.com') {
next() next()
...@@ -17,6 +37,10 @@ router.beforeEach(async (to, from, next) => { ...@@ -17,6 +37,10 @@ router.beforeEach(async (to, from, next) => {
const user = useUserStore() const user = useUserStore()
if (!user.isLogin && !whiteList.includes(to.path)) { if (!user.isLogin && !whiteList.includes(to.path)) {
try { try {
const thirdPartyParams = getThirdPartyParams(to.query)
if (thirdPartyParams) {
await thirdPartyLogin(thirdPartyParams)
}
await user.getUser() await user.getUser()
} catch (e) { } catch (e) {
console.error(e) console.error(e)
......
...@@ -24,17 +24,17 @@ export default defineConfig(({ mode }) => ({ ...@@ -24,17 +24,17 @@ export default defineConfig(({ mode }) => ({
open: true, open: true,
host: 'dev.ezijing.com', host: 'dev.ezijing.com',
proxy: { proxy: {
// '/api/resource': { '/api/resource': {
// target: 'http://localhost:20082', target: 'http://localhost:20082',
// changeOrigin: true, changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api\/resource/, ''), rewrite: (path) => path.replace(/^\/api\/resource/, ''),
// }, },
// '/api/lab': { '/api/lab': {
// target: 'http://localhost:20081', target: 'http://localhost:20081',
// changeOrigin: true, changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api\/lab/, ''), rewrite: (path) => path.replace(/^\/api\/lab/, ''),
// }, },
'/api': 'https://saas-lab.ezijing.com', // '/api': 'https://saas-lab.ezijing.com',
}, },
}, },
resolve: { resolve: {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论