新增go服务token
This commit is contained in:
@ -5,8 +5,10 @@ VITE_APP_TITLE = 新能源项目管理平台
|
||||
VITE_APP_ENV = 'development'
|
||||
|
||||
# 开发环境
|
||||
# VITE_APP_BASE_API = 'http://192.168.110.119:8899'
|
||||
VITE_APP_BASE_API = 'http://58.17.134.85:8899'
|
||||
VITE_APP_BASE_API = 'http://192.168.110.119:8899'
|
||||
# VITE_APP_BASE_API = 'http://58.17.134.85:8899'
|
||||
# GO开发环境
|
||||
VITE_APP_BASE_API_GO = 'http://192.168.110.159:8919'
|
||||
|
||||
# 无人机接口地址
|
||||
|
||||
|
@ -2,6 +2,7 @@ import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { LoginData, LoginResult, TenantInfo, UserProject, VerifyCodeResult } from './types';
|
||||
import { UserInfo } from '@/api/system/user/types';
|
||||
import requestGo from '@/utils/request-go';
|
||||
|
||||
// pc端固定客户端授权id
|
||||
const clientId = import.meta.env.VITE_APP_CLIENT_ID;
|
||||
@ -119,3 +120,17 @@ export function getUserProject(): AxiosPromise<UserProject[]> {
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
//获取Go服务Token
|
||||
export function getGoToken(): AxiosPromise<any> {
|
||||
return requestGo({
|
||||
url: '/zm/api/v1/system/login',
|
||||
method: 'post',
|
||||
data: {
|
||||
status: 'yjdsj',
|
||||
verifyCode: '1111',
|
||||
username: 'admin',
|
||||
password: 'zmkg@2023A'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import request from '@/utils/request';
|
||||
// import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { LeaveVO, LeaveForm, LeaveQuery } from '@/api/project/leave/types';
|
||||
import { AuditReissueCardForm } from '../reissueCard/types';
|
||||
|
||||
import request from '@/utils/request-go';
|
||||
/**
|
||||
* 查询施工人员请假申请列表
|
||||
* @param query
|
||||
@ -11,7 +11,7 @@ import { AuditReissueCardForm } from '../reissueCard/types';
|
||||
|
||||
export const listLeave = (query?: LeaveQuery): AxiosPromise<LeaveVO[]> => {
|
||||
return request({
|
||||
url: '/project/leave/list',
|
||||
url: '/zm/api/v1/system/busAskforleave/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
|
@ -115,6 +115,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
roles.value = [];
|
||||
permissions.value = [];
|
||||
removeToken();
|
||||
$cache.local.remove('goToken'); // 清除Go服务Token缓存
|
||||
// 清除项目缓存
|
||||
$cache.local.remove('selectedProject');
|
||||
$cache.local.remove('ProjectTeamList');
|
||||
|
19
src/utils/request-go.ts
Normal file
19
src/utils/request-go.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import $cache from '@/plugins/cache';
|
||||
// src/utils/request-go.ts
|
||||
import request from '@/utils/request';
|
||||
|
||||
const BASE_GO_URL = import.meta.env.VITE_APP_BASE_API_GO;
|
||||
|
||||
/**
|
||||
* 包装 request 请求,统一使用 Go 服务地址作为 baseURL
|
||||
* @param config 原始请求配置
|
||||
*/
|
||||
export default function requestGo(config: any) {
|
||||
return request({
|
||||
baseURL: BASE_GO_URL,
|
||||
...config,
|
||||
headers: {
|
||||
'Authorization': `Bearer ${$cache.local.get('goToken') || ''}`
|
||||
}
|
||||
});
|
||||
}
|
@ -45,7 +45,7 @@ service.interceptors.request.use(
|
||||
// 是否需要加密
|
||||
const isEncrypt = config.headers?.isEncrypt === 'true';
|
||||
|
||||
if (getToken() && !isToken) {
|
||||
if (getToken() && !isToken && !config.headers?.Authorization) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
// get请求映射params参数
|
||||
|
@ -79,7 +79,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getCodeImg, getTenantList } from '@/api/login';
|
||||
import { getCodeImg, getGoToken, getTenantList } from '@/api/login';
|
||||
import { authBinding } from '@/api/system/social/auth';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { LoginData, TenantVO } from '@/api/types';
|
||||
@ -151,8 +151,12 @@ const handleLogin = () => {
|
||||
// 调用action的登录方法
|
||||
const [err] = await to(userStore.login(loginForm.value));
|
||||
if (!err) {
|
||||
//获取Go服务Token保存本地
|
||||
const goToken = await getGoToken();
|
||||
proxy.$cache.local.set('goToken', goToken.data.token);
|
||||
const redirectUrl = redirect.value || '/';
|
||||
await router.push(redirectUrl);
|
||||
|
||||
loading.value = false;
|
||||
} else {
|
||||
loading.value = false;
|
||||
|
@ -63,7 +63,7 @@
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" width="50" />
|
||||
<el-table-column label="申请人" align="center" prop="userName" />
|
||||
<el-table-column label="申请请假说明" align="center" prop="userExplain" />
|
||||
<el-table-column label="申请请假说明" align="center" prop="argument" />
|
||||
<!-- <el-table-column label="请假申请时间" align="center" prop="userTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.userTime, '{y}-{m}-{d}') }}</span>
|
||||
@ -74,9 +74,9 @@
|
||||
<dict-tag :options="user_leave_type" :value="scope.row.teamName" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<el-table-column label="状态" align="center" prop="cardNumber">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="user_review_status_type" :value="scope.row.status" />
|
||||
<dict-tag :options="user_review_status_type" :value="scope.row.cardNumber" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="班组长意见" align="center" prop="gangerOpinion">
|
||||
@ -189,7 +189,7 @@
|
||||
</el-step>
|
||||
<el-step title="结果" :status="resultsStatus">
|
||||
<template #description>
|
||||
<div>{{ user_review_status_type[parseInt(detailObj.status) - 1].label }}</div>
|
||||
<div>{{ user_review_status_type[parseInt(detailObj.cardNumber) - 1].label }}</div>
|
||||
</template>
|
||||
</el-step>
|
||||
</el-steps>
|
||||
@ -346,8 +346,8 @@ const resultsStatus = computed(() => {
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listLeave(queryParams.value);
|
||||
leaveList.value = res.rows;
|
||||
total.value = res.total;
|
||||
leaveList.value = res.data.list;
|
||||
total.value = res.data.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
|
@ -53,6 +53,12 @@ export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')
|
||||
},
|
||||
[env.VITE_APP_BASE_API_GO]: {
|
||||
target: 'http://192.168.110.159:8919',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API_GO), '')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user