diff --git a/build/vite-plugin-code-version.js b/build/vite-plugin-code-version.js index 5869eb0..a88822d 100644 --- a/build/vite-plugin-code-version.js +++ b/build/vite-plugin-code-version.js @@ -1,3 +1,4 @@ +import process from 'process' import child_process from 'child_process' import fs from 'fs' import path from 'path' @@ -58,6 +59,34 @@ function getBranchName() { } return branchName } +function openFolderBySystem(folderPath) { + try { + if (process.platform === 'win32') { + child_process.spawn('cmd', ['/c', 'start', '', folderPath], { + detached: true, + stdio: 'ignore' + }) + return + } + + if (process.platform === 'darwin') { + child_process.spawn('open', [folderPath], { + detached: true, + stdio: 'ignore' + }) + return + } + + child_process.spawn('xdg-open', [folderPath], { + detached: true, + stdio: 'ignore' + }) + } catch (e) { + console.log('------------------打开输出目录失败---------------') + console.warn(e) + } +} + function getVersion(date, mode) { return `${parseTime(date, 'yyyy-MM-dd hh:mm:ss')} branch:${getBranchName()} ${getHash()} mode:${mode}` } @@ -149,6 +178,7 @@ export default function codeVersion() { console.error(err) }) } + openFolderBySystem(distPath) } } } diff --git a/src/api/系统支撑.js b/src/api/系统支撑.js index 30c0d72..9b32701 100644 --- a/src/api/系统支撑.js +++ b/src/api/系统支撑.js @@ -505,6 +505,57 @@ export function sysRsaPublic() { }) } +/** + * @typedef {Object} 内蒙古统一服务门户SSO登录返回信息 + * @property {string} authorizeUrl - 跳转URL + * @property {string} companyName - 企业名称 + * @property {string} errorCode - 错误码,为空表示成功 + * @property {string} errorMsg - 错误信息 + * @property {string} phone - 手机号 + * @property {string} uniscid - 统一社会信用代码 + * @property {string} userId - 用户ID(统一服务门户) + * @property {string} userName - 用户名 + */ +/** + * 1、获取统一服务门户授权跳转地址 + * 内蒙古统一服务门户单点登录接口 + * @param {string} params.redirectUri - 回调地址 + * @return {Promise<内蒙古统一服务门户SSO登录返回信息>} + */ +export function sysNmgSsoAuthorizeUrl(params) { + return request({ + method: 'get', + url: `/sys/nmg/sso/authorize/url`, + params + }) +} + +/** + * @typedef {Object} 内蒙古统一服务门户SSO登录返回信息 + * @property {string} authorizeUrl - 跳转URL + * @property {string} companyName - 企业名称 + * @property {string} errorCode - 错误码,为空表示成功 + * @property {string} errorMsg - 错误信息 + * @property {string} phone - 手机号 + * @property {string} uniscid - 统一社会信用代码 + * @property {string} userId - 用户ID(统一服务门户) + * @property {string} userName - 用户名 + */ +/** + * 2、统一服务门户授权回调 + * 内蒙古统一服务门户单点登录接口 + * @required @param {string} params.code - 授权码 + * @param {string} params.state - 状态码 + * @return {Promise<内蒙古统一服务门户SSO登录返回信息>} + */ +export function sysNmgSsoCallback(params) { + return request({ + method: 'get', + url: `/sys/nmg/sso/callback`, + params + }) +} + /** * @typedef {Object} */ diff --git a/src/router/permission.js b/src/router/permission.js index 0d83bc8..a80590b 100644 --- a/src/router/permission.js +++ b/src/router/permission.js @@ -4,10 +4,39 @@ import { getToken, setToken, removeToken } from '@/utils/auth' import { callMessage } from '@/utils/ui-merge' import { entRegisterInfoCurrent } from '@/api/市场主体信息相关' import { oauthLogin, oauthLoginByCerno } from '@/api/user' +import { sysNmgSsoCallback } from '@/api/系统支撑' const StartRoute = '/login' const skipToken = [] +const skipPortalCode = [] router.beforeEach(async (to, from, next) => { + if (to.query.code && to.query.state2 === 'portal') { + const portalCode = to.query.code + if (!skipPortalCode.includes(portalCode)) { + skipPortalCode.push(portalCode) + await sysNmgSsoCallback({ + code: to.query.code, + state: to.query.state + }).then(() => { + setToken('token') + next({ + path: '/business', + replace: true + }) + }).catch((error) => { + removeToken() + callMessage({ + type: 'error', + message: error?.message || '统一门户登录失败' + }) + next({ + path: StartRoute, + replace: true + }) + }) + return + } + } if (to.path === '/oauth' && !skipToken.includes(to.query.token)) { skipToken.push(to.query.token) if (to.query.cerno && to.query.tel) { diff --git a/src/router/routes.js b/src/router/routes.js index aba7da9..4384858 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -77,6 +77,15 @@ const constantRoutes = [ showNavBack: true } }, + { + path: '/login/unified', + component: () => handlerImport(import('@/views/user/unified.vue')), + meta: { + roles: ['guest'], + title: '统一门户登录', + showNavBack: true + } + }, { path: '/liaisonsRegister', component: () => handlerImport(import('@/views/user/LiaisonsRegister.vue')), diff --git a/src/views/Login.vue b/src/views/Login.vue index 14c9df8..a06be02 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -12,7 +12,7 @@ diff --git a/src/views/index.vue b/src/views/index.vue index d6eac6f..082d5c0 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -17,7 +17,7 @@ label="进入填报前,请先成为办事企业的法人代表或者联络员" @click="onHandleClickToLogin" /> - + /> --> +
+ + +