diff --git a/.env.development b/.env.development index 999f6db..a322e76 100644 --- a/.env.development +++ b/.env.development @@ -39,3 +39,4 @@ VITE_APP_SSE = true VITE_AMAP_KEY = '' # 高德地图安全密钥(JSAPI 2.0 配合 key 使用) VITE_AMAP_SECURITYCODE = '' +VITE_DINGTALK_CORP_ID = 'dingac2932b8bc38a94735c2f4657eb6378f' diff --git a/.env.production b/.env.production index ac60d76..2b4035f 100644 --- a/.env.production +++ b/.env.production @@ -42,3 +42,4 @@ VITE_APP_SSE = true VITE_AMAP_KEY = '' # 高德地图安全密钥(JSAPI 2.0 配合 key 使用) VITE_AMAP_SECURITYCODE = '' +VITE_DINGTALK_CORP_ID = 'dingac2932b8bc38a94735c2f4657eb6378f' diff --git a/package.json b/package.json index 91d725e..ed4a627 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "await-to-js": "3.0.0", "axios": "1.13.6", "crypto-js": "4.2.0", + "dingtalk-jsapi": "^3.2.9", "echarts": "6.0.0", "element-plus": "2.13.5", "file-saver": "2.0.5", diff --git a/src/api/sbgl/ding/index.ts b/src/api/sbgl/ding/index.ts new file mode 100644 index 0000000..175ab4f --- /dev/null +++ b/src/api/sbgl/ding/index.ts @@ -0,0 +1,19 @@ +import request from '@/utils/request'; + +// 钉钉免登:authCode 换系统 token +export function dingLogin(code: string) { + return request({ + url: '/sbgl/ding/login', + method: 'post', + data: { code } + }); +} + +// dd.config 鉴权签名(JSAPI 需鉴权能力用,如手机定位 device.geolocation.get) +export function jsapiSign(url: string) { + return request({ + url: '/sbgl/ding/jsapiSign', + method: 'get', + params: { url } + }); +} diff --git a/src/components/SbMap/index.vue b/src/components/SbMap/index.vue index c04a75a..4bff286 100644 --- a/src/components/SbMap/index.vue +++ b/src/components/SbMap/index.vue @@ -67,9 +67,11 @@ function initMap() { map = L.map(mapRef.value, { center: [center[1], center[0]], // Leaflet 是 [lat, lng] zoom: props.zoom ?? 12, - zoomControl: true, + zoomControl: false, attributionControl: false }); + // 缩放控件放右下角:左上角常被图层面板/标题栏遮挡 + L.control.zoom({ position: 'bottomright' }).addTo(map); L.tileLayer(TILE_URLS[props.base ?? 'road'], TILE_OPTS).addTo(map); markerLayer = L.layerGroup().addTo(map); map.on('click', (e: L.LeafletMouseEvent) => { diff --git a/src/permission.ts b/src/permission.ts index f5b0d30..cf1a499 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -11,7 +11,7 @@ import { usePermissionStore } from '@/store/modules/permission'; import { ElMessage } from 'element-plus/es'; NProgress.configure({ showSpinner: false }); -const whiteList = ['/login', '/register', '/register*', '/register/*']; +const whiteList = ['/login', '/register', '/register*', '/register/*', '/h5/order', '/h5/*']; const isWhiteList = (path: string) => { return whiteList.some((pattern) => isPathMatch(pattern, path)); diff --git a/src/router/index.ts b/src/router/index.ts index 58ef2ef..cc17436 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -77,6 +77,13 @@ export const constantRoutes: RouteRecordRaw[] = [ name: 'SbScreen', meta: { title: '设备资产大屏', noCache: true } }, + { + path: '/h5/order', + component: () => import('@/views/sbgl/h5/order.vue'), + hidden: true, + name: 'H5Order', + meta: { title: '运维工单', noCache: true } + }, { path: '/user', component: Layout, diff --git a/src/utils/request.ts b/src/utils/request.ts index cd16fb1..9fa8705 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,6 +1,6 @@ import axios, { AxiosResponse, InternalAxiosRequestConfig } from 'axios'; import { useUserStore } from '@/store/modules/user'; -import { getToken } from '@/utils/auth'; +import { getToken, setToken } from '@/utils/auth'; import { tansParams, blobValidate } from '@/utils/ruoyi'; import cache from '@/plugins/cache'; import { HttpStatus } from '@/enums/RespEnum'; @@ -16,6 +16,31 @@ const encryptHeader = 'encrypt-key'; let downloadLoadingInstance: LoadingInstance; // 是否显示重新登录 export const isRelogin = { show: false }; + +/** + * 钉钉环境静默免登:401 会话过期时,用钉钉授权码重新换取系统 token 并刷新页面, + * 全程无弹窗无感续期;corpId 未配置或免登失败时抛错(由调用方降级处理)。 + */ +const dingSilentRelogin = async (): Promise => { + const corpId = import.meta.env.VITE_DINGTALK_CORP_ID as string; + if (!corpId) { + throw new Error('corpId 未配置'); + } + const dd = (await import('dingtalk-jsapi')).default; + const authCode = await new Promise((resolve, reject) => { + dd.ready(() => { + dd.runtime.permission.requestAuthCode({ + corpId, + onSuccess: (result: any) => resolve(result.code), + onFail: (err: any) => reject(err) + }); + }); + }); + const { dingLogin } = await import('@/api/sbgl/ding'); + const res = await dingLogin(authCode); + setToken(res.data.accessToken); +}; + export const globalHeaders = () => { return { Authorization: 'Bearer ' + getToken(), @@ -129,8 +154,18 @@ service.interceptors.response.use( return res.data; } if (code === 401) { - // prettier-ignore - if (!isRelogin.show) { + // 钉钉环境:静默免登续期后刷新页面,无感重试,不弹重新登录确认框 + if (!isRelogin.show && navigator.userAgent.includes('DingTalk')) { + isRelogin.show = true; + dingSilentRelogin() + .then(() => { + location.reload(); + }) + .catch(() => { + isRelogin.show = false; + ElMessage.warning('钉钉免登续期失败,请退出应用后重新进入'); + }); + } else if (!isRelogin.show) { isRelogin.show = true; ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', diff --git a/src/views/sbgl/h5/order.vue b/src/views/sbgl/h5/order.vue new file mode 100644 index 0000000..e77e145 --- /dev/null +++ b/src/views/sbgl/h5/order.vue @@ -0,0 +1,1051 @@ + + + + + diff --git a/src/views/sbgl/screen/index.vue b/src/views/sbgl/screen/index.vue index 08abdaa..d29adce 100644 --- a/src/views/sbgl/screen/index.vue +++ b/src/views/sbgl/screen/index.vue @@ -1,17 +1,29 @@ @@ -249,6 +252,8 @@ + +