Commit d5ea7570 by Lin

feat: 知识管理表单编辑接口联调/交互样式修改

1 parent d47fc120
import { gscPost} from '@/utils/gscRequest';
/**
* 质检规则列表查询
*/
export async function inspectionRuleList(data: any) {
try {
const response = await gscPost('/inspectionRule/findPageInspectionRule', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检规则新增
*/
export async function addInspectionRule(data: any) {
try {
const response = await gscPost('/inspectionRule/addInspectionRule', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检规则列表修改
*/
export async function updateInspectionRule(data: any) {
try {
const response = await gscPost('/inspectionRule/updateInspectionRule', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检规则列表删除
*/
export async function deleteInspectionRule(data: any) {
try {
const response = await gscPost('/inspectionRule/deleteInspectionRule', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检模版列表查询
*/
export async function inspectionTemplateList(data: any) {
try {
const response = await gscPost('/inspectionTemplate/findPageInspectionTemplate', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检模版新增
*/
export async function saveInspectionTemplate(data: any) {
try {
const response = await gscPost('/inspectionTemplate/saveInspectionTemplate', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检模版修改
*/
export async function updateInspectionTemplate(data: any) {
try {
const response = await gscPost('/inspectionTemplate/updateInspectionTemplate', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 质检模版删除
*/
export async function deleteInspectionTemplate(data: any) {
try {
const response = await gscPost('/inspectionTemplate/deleteInspectionTemplate', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 培训智能体列表查询
*/
export async function trainingPlanList(data: any) {
try {
const response = await gscPost('/trainingPlan/findPageTrainingPlan', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 培训智能体新增
*/
export async function addTrainingPlan(data: any) {
try {
const response = await gscPost('/trainingPlan/addTrainingPlan', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 培训智能体修改
*/
export async function updateTrainingPlan(data: any) {
try {
const response = await gscPost('/trainingPlan/updateTrainingPlan', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 培训智能体删除
*/
export async function deleteTrainingPlan(data: any) {
try {
const response = await gscPost('/trainingPlan/deleteTrainingPlan', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 培训智能体详情
*/
export async function ftrainingPlanDetail(data: any) {
try {
const response = await gscPost(`/trainingPlan/findTrainingPlanDetail/${data.planId}`, data);
return response;
} catch (error) {
throw error;
}
}
...@@ -66,7 +66,7 @@ export async function findPageKnowledgeMaterial(data: any) { ...@@ -66,7 +66,7 @@ export async function findPageKnowledgeMaterial(data: any) {
*/ */
export async function updateKnowledgeMaterial(data: any) { export async function updateKnowledgeMaterial(data: any) {
try { try {
const response = await gscPost('/knowledgeMaterial/updateKnowledgeMaterial', data); const response = await gscPost('/knowledgeMaterial/updateKnowledgeMaterial', data, { returnAll:true });
return response; return response;
} catch (error) { } catch (error) {
throw error; throw error;
......
...@@ -332,6 +332,12 @@ const handleEditMaterial = (item) => { ...@@ -332,6 +332,12 @@ const handleEditMaterial = (item) => {
drawer.value = true; drawer.value = true;
}; };
// 刷新列表数据
const handleRefreshList = () => {
getMaterialList();
getCategoryList();
};
// 预览素材 // 预览素材
const handlePreviewMaterial = (item) => { const handlePreviewMaterial = (item) => {
if (item.fileUrl) { if (item.fileUrl) {
...@@ -730,10 +736,12 @@ onMounted(() => { ...@@ -730,10 +736,12 @@ onMounted(() => {
<el-drawer v-model="drawer" :with-header="true" size="70%" :show-close="false"> <el-drawer v-model="drawer" :with-header="true" size="70%" :show-close="false">
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="flex items-center justify-between border-b border-[#E5E5E5] p-[20px]">
<p :id="titleId" :class="[titleClass, 'drawer-title']">编辑素材</p> <p :id="titleId" :class="[titleClass, 'drawer-title']">编辑素材</p>
<img src="/images/icon-close.png" alt="" srcset="" class="el-icon--left w-[20px] h-[20px] cursor-pointer" @click="close"> <img src="/images/icon-close.png" alt="" srcset="" class="el-icon--left w-[20px] h-[20px] cursor-pointer" @click="close">
</div>
</template> </template>
<AddUpdate :is-standalone="false" :material="currentMaterial" @close="drawer = false" /> <AddUpdate :is-standalone="false" :material="currentMaterial" @close="drawer = false" @refresh="handleRefreshList" />
</el-drawer> </el-drawer>
</div> </div>
</template> </template>
...@@ -755,7 +763,8 @@ onMounted(() => { ...@@ -755,7 +763,8 @@ onMounted(() => {
} }
:deep(.el-drawer__header) { :deep(.el-drawer__header) {
margin-bottom: 0; margin: 0;
padding: 0;
} }
.drawer-title { .drawer-title {
...@@ -763,4 +772,6 @@ onMounted(() => { ...@@ -763,4 +772,6 @@ onMounted(() => {
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
} }
</style> </style>
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* 配置中心管理 * 配置中心管理
* 使用 fetch 解决 axios 提前实例化导致 sign 里面的 secret 不能通过配置中心动态获取 * 使用 fetch 解决 axios 提前实例化导致 sign 里面的 secret 不能通过配置中心动态获取
*/ */
import { Request } from 'glsk-toolkit'; import { Request, Defaults } from 'glsk-toolkit';
import { getToken } from '@/utils/auth';
// 配置数据 // 配置数据
let baseConfig: any = {}; let baseConfig: any = {};
let routerConfig: any = {}; let routerConfig: any = {};
...@@ -38,8 +38,6 @@ export function getGscApi(): null | Request { ...@@ -38,8 +38,6 @@ export function getGscApi(): null | Request {
return gscApiInstance; return gscApiInstance;
} }
/** /**
* 等待配置加载完成 * 等待配置加载完成
* @returns Promise<void> * @returns Promise<void>
...@@ -69,18 +67,22 @@ export async function fetchConfig(): Promise<any> { ...@@ -69,18 +67,22 @@ export async function fetchConfig(): Promise<any> {
window.$fetchConfig = configData; window.$fetchConfig = configData;
// 统一初始化 GSC API(无论 code 是什么,只要有配置就初始化) // 统一初始化 GSC API(无论 code 是什么,只要有配置就初始化)
const gscConfig = configData?.gsc || configData; const gscConfig = configData?.gsc || configData;
if (gscConfig) { if(gscConfig){
// 创建请求实例,存储在模块级变量中,不挂载到 window // 创建全局默认配置
gscApiInstance = new Request({ const globalDefaults = new Defaults({
...gscConfig, ...gscConfig,
session: { session: {
requiresSession: false, requiresSession: false,
sessionId: 'd5629aee-28c7-4def-a8fa-95d76c978dc7', sessionId: 'd5629aee-28c7-4def-a8fa-95d76c978dc7',
}, },
headers: { headers: {
'Authorization': '472b403095cd439d81d258c89267c7db',
'X-App-Version': '1.0.0' 'X-App-Version': '1.0.0'
}, },
retry: {
retries: 2,
retryDelay: 500,
shouldResetTimeout: true
},
events: { events: {
error: (error: any, requestConfig: any) => { error: (error: any, requestConfig: any) => {
console.error('[配置中心] GSC API 错误:', error, requestConfig); console.error('[配置中心] GSC API 错误:', error, requestConfig);
...@@ -89,21 +91,71 @@ export async function fetchConfig(): Promise<any> { ...@@ -89,21 +91,71 @@ export async function fetchConfig(): Promise<any> {
console.log('[配置中心] GSC API 登出:', response, requestConfig); console.log('[配置中心] GSC API 登出:', response, requestConfig);
}, },
}, },
// Sentry 配置
// sentry: {
// enable: true, // 是否启用Sentry错误上报
// dsn: 'https://ace1d827739e4229887b78468bd8a385@sentry.glsx.com.cn/48'
// }
}); });
gscApiInstance = new Request(globalDefaults);
// 配置请求拦截器,动态添加 Authorization
gscApiInstance.interceptors.request.use(
(config: any) => {
// 动态获取 token 并添加到请求头
const token = getToken();
if (token) {
config.headers = {
...config.headers,
'Authorization': token
};
}
return config;
},
(error: any) => {
console.error('[配置中心] 请求拦截器错误:', error);
return Promise.reject(error);
}
);
// 通知配置已就绪
if (configReadyResolve) { if (configReadyResolve) {
configReadyResolve(); configReadyResolve();
configReadyResolve = null; configReadyResolve = null;
} }
} else { } else {
console.warn('[配置中心] 未找到 GSC 配置,无法初始化 API 实例'); console.warn('[配置中心] 未找到 GSC 配置,无法初始化 API 实例');
} }
// if (gscConfig) {
// // 创建请求实例,存储在模块级变量中,不挂载到 window
// gscApiInstance = new Request({
// ...gscConfig,
// session: {
// requiresSession: false,
// sessionId: 'd5629aee-28c7-4def-a8fa-95d76c978dc7',
// },
// headers: {
// 'Authorization': '237f1ca886db4a0fbde44ef446ec74bb',
// 'X-App-Version': '1.0.0'
// },
// events: {
// error: (error: any, requestConfig: any) => {
// console.error('[配置中心] GSC API 错误:', error, requestConfig);
// },
// logout: (response: any, requestConfig: any) => {
// console.log('[配置中心] GSC API 登出:', response, requestConfig);
// },
// },
// // Sentry 配置
// // sentry: {
// // enable: true, // 是否启用Sentry错误上报
// // dsn: 'https://ace1d827739e4229887b78468bd8a385@sentry.glsx.com.cn/48'
// // }
// });
// // 通知配置已就绪
// if (configReadyResolve) {
// configReadyResolve();
// configReadyResolve = null;
// }
// } else {
// console.warn('[配置中心] 未找到 GSC 配置,无法初始化 API 实例');
// }
return configData; return configData;
} catch (error) { } catch (error) {
......
/** /**
* GSC 请求封装 * GSC 请求封装
* Authorization 通过请求拦截器统一处理,无需手动添加
*/ */
import { getGscApi } from './center'; import { getGscApi } from './center';
import { getToken } from '@/utils/auth';
/** /**
* 方案1:在每次请求时动态添加 token(推荐) * GSC POST 请求
* 优点:简单直接,每次请求都使用最新的 token * @param url 请求地址
* @param data 请求数据
* @param config 请求配置(可选)
*/ */
export const gscPost = (url: string, data: any, _config: any = {}) => { export const gscPost = (url: string, data: any, config: any = {}) => {
const gscApi = getGscApi(); const gscApi = getGscApi();
if (!gscApi) { if (!gscApi) {
...@@ -19,18 +21,28 @@ export const gscPost = (url: string, data: any, _config: any = {}) => { ...@@ -19,18 +21,28 @@ export const gscPost = (url: string, data: any, _config: any = {}) => {
return Promise.reject(error); return Promise.reject(error);
} }
// 动态获取 token 并添加到请求配置中
const token = getToken();
const configWithAuth = {
..._config,
headers: {
...(_config.headers || {}),
...(token ? { Authorization: `${token}` } : {}),
},
};
console.log('[GSC请求] 发起请求:', url, data); console.log('[GSC请求] 发起请求:', url, data);
return gscApi.post(url, data, configWithAuth); return gscApi.post(url, data, config);
};
/**
* GSC GET 请求
* @param url 请求地址
* @param config 请求配置(可选)
*/
export const gscGet = (url: string, config: any = {}) => {
const gscApi = getGscApi();
if (!gscApi) {
const error = new Error(
'[GSC请求] GSC API 实例未初始化,请确保配置中心已加载完成',
);
console.error(error);
return Promise.reject(error);
}
console.log('[GSC请求] 发起请求:', url);
return gscApi.get(url, config);
}; };
// 默认导出 // 默认导出
......
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
registerMicroApps, registerMicroApps,
start, start,
} from 'qiankun'; } from 'qiankun';
import { ElMessage } from 'element-plus';
import { microApps } from './apps'; // 微应用信息配置 import { microApps } from './apps'; // 微应用信息配置
import { communicationManager } from './communication'; // 通信管理器 import { communicationManager } from './communication'; // 通信管理器
...@@ -47,8 +48,11 @@ export function setupQiankun() { ...@@ -47,8 +48,11 @@ export function setupQiankun() {
// 可以在这里做一些全局错误处理 // 可以在这里做一些全局错误处理
// 例如:错误上报、错误提示等 // 例如:错误上报、错误提示等
const { message } = event as any; const { message } = event as any;
console.log(message);
if (message && message.includes('died in status')) { if (message && message.includes('died in status')) {
console.error('[qiankun] 微应用加载失败,请检查微应用是否正常运行'); console.error('[qiankun] 微应用加载失败,请检查微应用是否正常运行');
// 显示错误弹框提示
ElMessage.error('微应用加载失败,请检查微应用是否正常运行');
} }
}); });
......
...@@ -29,7 +29,7 @@ service.interceptors.request.use( ...@@ -29,7 +29,7 @@ service.interceptors.request.use(
// 添加 token // 添加 token
const token = getToken(); const token = getToken();
if (token && config.headers) { if (token && config.headers) {
config.headers.Authorization = `Bearer ${token}`; config.headers.Authorization = `${token}`;
} }
// 添加时间戳防止缓存 // 添加时间戳防止缓存
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!