优化菁优网api接口

This commit is contained in:
“zouyf” 2024-11-25 17:23:31 +08:00
parent d26af6446a
commit 09e6bec69f
4 changed files with 32 additions and 12 deletions

View File

@ -108,4 +108,21 @@ export function pyOCRAPI(path) {
imageBas64: path, imageBas64: path,
} }
}) })
}
/**
* @desc: 菁优网转发
* @return: {*}
* @param {*} url
* @param {*} config
*/
export function getJYPath(url,config) {
config.params = config.params?config.params:{}
config.params["getjypath"] = url;
return request({
url: "/jy/proxy",
method: config.method||"get",
params: config.params
})
} }

View File

@ -1,3 +1,5 @@
import { getJYPath } from "@/api/education/entpcoursework";
const JY_TOKEN = 'CA82641DA86072DEFD39E287335E035FDA6AEEC0549B58F54F4408734C8683FFAF0585CFA3B25091E588A03A65C66A80F5FF613F539D600954007A35DFFBFDC3C7BB982771C5E13F0918642CFD7596CE3718F06E5579238D92EC809AC6F4C82A9FE4B0E232A67DD3594D4DAC1C219CCBC4A7A093344446107EB11DC317526D0594249DEBBD82B740C794CF5A7065E1982B7779AF16AD25D7'; const JY_TOKEN = 'CA82641DA86072DEFD39E287335E035FDA6AEEC0549B58F54F4408734C8683FFAF0585CFA3B25091E588A03A65C66A80F5FF613F539D600954007A35DFFBFDC3C7BB982771C5E13F0918642CFD7596CE3718F06E5579238D92EC809AC6F4C82A9FE4B0E232A67DD3594D4DAC1C219CCBC4A7A093344446107EB11DC317526D0594249DEBBD82B740C794CF5A7065E1982B7779AF16AD25D7';
const JY_SUBJECT = [ const JY_SUBJECT = [
{id: 10, subject: 'math3', name: '小学数学'}, {id: 10, subject: 'math3', name: '小学数学'},
@ -27,7 +29,7 @@ const JY_SUBJECT = [
]; ];
export const JYApiListCT = async (_this, name = '高中历史') => { export const JYApiListCT = async (name = '高中历史') => {
if (name === '初中政治') { if (name === '初中政治') {
name = '初中道德与法治'; name = '初中道德与法治';
} }
@ -35,7 +37,8 @@ export const JYApiListCT = async (_this, name = '高中历史') => {
if(obj.length < 1) { if(obj.length < 1) {
return []; return [];
} }
const res = await _this.$requestGetJYW(`/${obj[0].subject}/common`, { getJYPath
const res = await getJYPath(`/${obj[0].subject}/common`, {
headers: { headers: {
authorization: `Token ${JY_TOKEN}` authorization: `Token ${JY_TOKEN}`
}, },
@ -63,7 +66,7 @@ export const JYApiListCT = async (_this, name = '高中历史') => {
return arrCT; return arrCT;
} }
export const JYApiListOriginYear = () => { export const JYApiListOriginYear = async () => {
const arrYear = [{label: '不限', value: '-1'}]; const arrYear = [{label: '不限', value: '-1'}];
let i = 0; let i = 0;
for( ; i < 10; i++) { for( ; i < 10; i++) {
@ -78,7 +81,7 @@ export const JYApiListOriginYear = () => {
return arrYear; return arrYear;
} }
export const JYApiListSO = async (_this, name = '高中历史') => { export const JYApiListSO = async (name = '高中历史') => {
if (name === '初中政治') { if (name === '初中政治') {
name = '初中道德与法治'; name = '初中道德与法治';
} }
@ -87,7 +90,7 @@ export const JYApiListSO = async (_this, name = '高中历史') => {
if(obj.length < 1) { if(obj.length < 1) {
return []; return [];
} }
const res = await _this.$requestGetJYW(`/${obj[0].subject}/common`, { const res = await getJYPath(`/${obj[0].subject}/common`, {
headers: { headers: {
authorization: `Token ${JY_TOKEN}` authorization: `Token ${JY_TOKEN}`
}, },
@ -104,7 +107,7 @@ export const JYApiListSO = async (_this, name = '高中历史') => {
export const JYApiListPoint = async (_this, name = '高中历史') => { export const JYApiListPoint = async (name = '高中历史') => {
if (name === '初中政治') { if (name === '初中政治') {
name = '初中道德与法治'; name = '初中道德与法治';
} }
@ -113,7 +116,7 @@ export const JYApiListPoint = async (_this, name = '高中历史') => {
if(obj.length < 1) { if(obj.length < 1) {
return []; return [];
} }
const res = await _this.$requestGetJYW(`/${obj[0].subject}/point`, { const res = await getJYPath(`/${obj[0].subject}/point`, {
headers: { headers: {
authorization: `Token ${JY_TOKEN}` authorization: `Token ${JY_TOKEN}`
}, },
@ -129,7 +132,7 @@ export const JYApiListPoint = async (_this, name = '高中历史') => {
* @desc: 获取菁优网的版本内容 * @desc: 获取菁优网的版本内容
* @return: {*} * @return: {*}
*/ */
export const JYApiListVersion = async (_this, query, hasPoints=true) => { export const JYApiListVersion = async (query, hasPoints=true) => {
const listVersion = { const listVersion = {
status: 0, status: 0,
msg: '', msg: '',
@ -148,7 +151,7 @@ export const JYApiListVersion = async (_this, query, hasPoints=true) => {
listVersion.msg = `[${name}]未找到对应菁优网教材版本, 请检查学段或学科是否匹配!`; listVersion.msg = `[${name}]未找到对应菁优网教材版本, 请检查学段或学科是否匹配!`;
return listVersion; return listVersion;
} }
const JYBook = await _this.$requestGetJYW(`/${result[0].subject}/book2`, { const JYBook = await getJYPath(`/${result[0].subject}/book2`, {
headers: { headers: {
// JYToken仅占位, 实际后续已未使用该token // JYToken仅占位, 实际后续已未使用该token
authorization: `Token ${JY_TOKEN}` authorization: `Token ${JY_TOKEN}`

View File

@ -1008,7 +1008,7 @@ const initPageParams = () => {
onMounted(async() => { onMounted(async() => {
// //
const name = userStore.edustage + userStore.edusubject; const name = userStore.edustage + userStore.edusubject;
const jyCT = await JYApiListCT(proxy, name); const jyCT = await JYApiListCT(name);
if (jyCT.length == 0) { if (jyCT.length == 0) {
ElMessage.error('获取题型失败!'); ElMessage.error('获取题型失败!');
return; return;
@ -1016,7 +1016,7 @@ onMounted(async() => {
entpCourseWorkTypeList.value = jyCT; entpCourseWorkTypeList.value = jyCT;
// //
entpCourseWorkYearList.value = JYApiListOriginYear(); entpCourseWorkYearList.value = JYApiListOriginYear();
entpCourseWorkGroupList.value = await JYApiListSO(proxy, name); entpCourseWorkGroupList.value = await JYApiListSO(name);
}) })

View File

@ -187,7 +187,7 @@ const getWorkType = async (data) => {
if (selName === curName) { if (selName === curName) {
return; return;
} }
const jyCT = await JYApiListCT(proxy, selName); const jyCT = await JYApiListCT(selName);
if (jyCT.length == 0) { if (jyCT.length == 0) {
ElMessage.error('获取题型失败!'); ElMessage.error('获取题型失败!');
return; return;