5 files modified
2 files added
| | |
| | | #接口地址 |
| | | VITE_APP_API=/api |
| | | |
| | | #接口地址-xt |
| | | VITE_APP_API_XT=/apiXT |
| | | |
| | | #页面基础路径 |
| | | VITE_APP_BASE=/task-work-order |
| | | |
| | |
| | | # @LastEditors : yuan |
| | | # @LastEditTime : 2026-01-16 11:02:24 |
| | | # @FilePath : \applications\task-work-order\env\.env.development |
| | | # @Description : |
| | | # Copyright 2026 OBKoro1, All Rights Reserved. |
| | | # @Description : |
| | | # Copyright 2026 OBKoro1, All Rights Reserved. |
| | | # 2026-01-07 14:58:30 |
| | | ### |
| | | ### |
| | | NODE_ENV = 'development' |
| | | |
| | | #开发环境配置 |
| | |
| | | # VITE_APP_URL = https://wrj.shuixiongit.com/api |
| | | VITE_APP_URL= http://192.168.1.204 |
| | | |
| | | VITE_APP_URL_XT=http://218.202.104.82:8200 |
| | | |
| | | #新大屏地址 |
| | | VITE_APP_DASHBOARD_URL = 'https://wrj.shuixiongit.com/command-center-dashboard/' |
| | | |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { loginWithMiniProgramApi } from '@/api/zkxt' |
| | | |
| | | |
| | | function getToken() { |
| | | loginWithMiniProgramApi({username: 'admin'}).then(res => { |
| | | console.log(res) |
| | | }) |
| | | } |
| | | getToken() |
| | | setInterval(() => { |
| | | getToken() |
| | | }, 600000) |
| | | </script> |
| | | |
| | | <style> |
| New file |
| | |
| | | import request from '@/axiosXT' |
| | | |
| | | export const loginWithMiniProgramApi = (data) => { |
| | | return request({ |
| | | url: `/auth/loginWithMiniProgram`, |
| | | method: 'post', |
| | | data, |
| | | }) |
| | | } |
| | |
| | | if (!authorization) { |
| | | config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` |
| | | } |
| | | // 后端的要求 |
| | | if (router.currentRoute.value.path === '/job/jobstatistics') { |
| | | const userAreaCode = store?.state?.user?.userInfo?.detail?.areaCode |
| | | const paramsKey = config.method === 'get' ? 'params' : 'data' |
| | | const codeKey = config.method === 'get' ? 'areaCode' : 'area_code' |
| | | const paramCode = config?.params?.areaCode || config?.data?.area_code |
| | | try { |
| | | if (paramCode) { |
| | | if (paramCode === userAreaCode) { |
| | | config[paramsKey][codeKey] = config.method === 'get' ? '' : undefined |
| | | } else { |
| | | if (!Array.isArray(config[paramsKey])) { |
| | | config[paramsKey] = { ...config[paramsKey], [codeKey]: paramCode } |
| | | } |
| | | } |
| | | } |
| | | } catch (e) {} |
| | | } |
| | | |
| | | //headers判断请求是否携带token |
| | | const meta = config.meta || {} |
| New file |
| | |
| | | import axios from 'axios' |
| | | import store from '@/store/' |
| | | import { serialize } from '@/utils/util' |
| | | import { getToken, removeToken, removeRefreshToken } from '@/utils/auth' |
| | | import { isURL, validatenull } from '@/utils/validate' |
| | | import { ElMessage } from 'element-plus' |
| | | import website from '@/config/website' |
| | | import { Base64 } from 'js-base64' |
| | | import { baseUrl } from '@/config/env' |
| | | import crypto from '@/utils/crypto' |
| | | // 全局未授权错误提示状态,只提示一次 |
| | | const { VITE_APP_API_XT } = import.meta.env |
| | | |
| | | // 创建作用域的 axios 实例 |
| | | const serviceXT = axios.create({ |
| | | // 超时时间设置为10分钟,部分接口上传比较慢,如固件上传 |
| | | timeout: 600000, |
| | | baseURL: VITE_APP_API_XT, |
| | | //返回其他状态码 |
| | | validateStatus: function (status) { |
| | | return status >= 200 && status <= 500 // 默认的 |
| | | }, |
| | | //跨域请求,允许保存cookie |
| | | withCredentials: true, |
| | | }) |
| | | |
| | | //http request拦截 |
| | | serviceXT.interceptors.request.use( |
| | | config => { |
| | | //headers判断是否需要 |
| | | const authorization = config.authorization === false |
| | | if (!authorization) { |
| | | config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` |
| | | } |
| | | const meta = config.meta || {} |
| | | |
| | | //headers中配置text请求 |
| | | if (config.text === true) { |
| | | config.headers['Content-Type'] = 'text/plain' |
| | | } |
| | | //headers中配置serialize为true开启序列化 |
| | | if (config.method === 'post' && meta.isSerialize === true) { |
| | | config.data = serialize(config.data) |
| | | } |
| | | return config |
| | | }, |
| | | error => { |
| | | return Promise.reject(error) |
| | | } |
| | | ) |
| | | //http response拦截 |
| | | serviceXT.interceptors.response.use( |
| | | res => { |
| | | const status = res.data.error_code || res.data.code || res.status |
| | | const statusWhiteList = website.statusWhiteList || [] |
| | | const message = res?.data?.msg || res?.data?.message || '系统错误' |
| | | //如果在白名单里则自行catch逻辑处理 |
| | | if (statusWhiteList.includes(status)) return Promise.reject(res) |
| | | // 如果请求为非200默认统一处理 |
| | | if (status !== 200 && status !== 0) { |
| | | ElMessage({ |
| | | message: message, |
| | | type: 'error', |
| | | }) |
| | | return Promise.reject(new Error(message)) |
| | | } |
| | | return res |
| | | }, |
| | | error => { |
| | | return Promise.reject(new Error(error)) |
| | | } |
| | | ) |
| | | export default serviceXT |
| | |
| | | // https://vitejs.dev/config/ |
| | | export default ({ mode, command }) => { |
| | | const env = loadEnv(mode, fileURLToPath(new URL("./env", import.meta.url))) |
| | | const { VITE_APP_ENV, VITE_APP_BASE, VITE_APP_URL } = env |
| | | const { VITE_APP_ENV, VITE_APP_BASE, VITE_APP_URL,VITE_APP_API_XT,VITE_APP_URL_XT } = env |
| | | // 判断是打生产环境包 |
| | | const isProd = VITE_APP_ENV === 'production' |
| | | |
| | |
| | | port: 5178, |
| | | // host: '192.168.1.178', |
| | | proxy: { |
| | | '/apiXT': { |
| | | target: VITE_APP_URL_XT, |
| | | changeOrigin: true, |
| | | rewrite: path => path.replace(/^\/apiXT/, ''), |
| | | }, |
| | | '/api': { |
| | | target: VITE_APP_URL, |
| | | changeOrigin: true, |
| | | rewrite: path => path.replace(/^\/api/, ''), |
| | | } |
| | | }, |
| | | |
| | | }, |
| | | }, |
| | | assetsInclude: ['**/*.gltf','**/*.docx','**/*.pdf'], |