mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix: cache 没有 config 问题
This commit is contained in:
parent
dd83cfff3e
commit
4ccfebe986
@ -170,6 +170,7 @@ export default async (ctx, next) => {
|
|||||||
const cacheData = getCacheData({ key: ctx.key, cacheType: config.cache.cacheType });
|
const cacheData = getCacheData({ key: ctx.key, cacheType: config.cache.cacheType });
|
||||||
if (cacheData) {
|
if (cacheData) {
|
||||||
ctx.response = {
|
ctx.response = {
|
||||||
|
config,
|
||||||
data: cacheData,
|
data: cacheData,
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
|
@ -1,46 +1,43 @@
|
|||||||
import { defineRuntimeConfig } from '@fesjs/fes';
|
import { defineRuntimeConfig } from '@fesjs/fes';
|
||||||
|
|
||||||
export default defineRuntimeConfig({
|
export default defineRuntimeConfig({
|
||||||
// request: {},
|
request: {
|
||||||
|
baseURL: '/ras-mas',
|
||||||
|
dataHandler(data) {
|
||||||
|
console.log('data', data);
|
||||||
|
if (data?.code !== '0') {
|
||||||
|
if (data.code === '10000') {
|
||||||
|
console.log('code', data.code);
|
||||||
|
}
|
||||||
|
if (data?.code === '20000') {
|
||||||
|
console.log('code', data.code);
|
||||||
|
}
|
||||||
|
throw new Error(data);
|
||||||
|
}
|
||||||
|
return data.result ? data.result : data;
|
||||||
|
},
|
||||||
|
errorHandler(error) {
|
||||||
|
if (error.response) {
|
||||||
|
// 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
|
||||||
|
console.log(error.response.data);
|
||||||
|
console.log(error.response.status);
|
||||||
|
console.log(error.response.headers);
|
||||||
|
} else if (error.request) {
|
||||||
|
// 请求已经成功发起,但没有收到响应
|
||||||
|
// `error.request` 在浏览器中是 XMLHttpRequest 的实例,
|
||||||
|
// 而在node.js中是 http.ClientRequest 的实例
|
||||||
|
console.log(error.request);
|
||||||
|
} else if (error.type) {
|
||||||
|
// 插件异常
|
||||||
|
console.log(error.msg);
|
||||||
|
} else {
|
||||||
|
// 发送请求时出了点问题
|
||||||
|
console.log('Error', error.message);
|
||||||
|
}
|
||||||
|
console.log('error', error.config);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
patchRoutes: () => {
|
||||||
|
console.log('patchRoutes');
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default defineRuntimeConfig({
|
|
||||||
// request: {
|
|
||||||
// baseURL: '/ras-mas',
|
|
||||||
// dataHandler(data) {
|
|
||||||
// if (data?.code !== '0') {
|
|
||||||
// if (data.code === '10000') {
|
|
||||||
// console.log('code', data.code);
|
|
||||||
// }
|
|
||||||
// if (data?.code === '20000') {
|
|
||||||
// console.log('code', data.code);
|
|
||||||
// }
|
|
||||||
// throw new Error(data);
|
|
||||||
// }
|
|
||||||
// return data.result ? data.result : data;
|
|
||||||
// },
|
|
||||||
// errorHandler(error) {
|
|
||||||
// if (error.response) {
|
|
||||||
// // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
|
|
||||||
// console.log(error.response.data);
|
|
||||||
// console.log(error.response.status);
|
|
||||||
// console.log(error.response.headers);
|
|
||||||
// } else if (error.request) {
|
|
||||||
// // 请求已经成功发起,但没有收到响应
|
|
||||||
// // `error.request` 在浏览器中是 XMLHttpRequest 的实例,
|
|
||||||
// // 而在node.js中是 http.ClientRequest 的实例
|
|
||||||
// console.log(error.request);
|
|
||||||
// } else if (error.type) {
|
|
||||||
// // 插件异常
|
|
||||||
// console.log(error.msg);
|
|
||||||
// } else {
|
|
||||||
// // 发送请求时出了点问题
|
|
||||||
// console.log('Error', error.message);
|
|
||||||
// }
|
|
||||||
// console.log(error.config);
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// patchRoutes: () => {
|
|
||||||
// console.log('patchRoutes');
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineRouteMeta } from '@fesjs/fes';
|
import { defineRouteMeta, request } from '@fesjs/fes';
|
||||||
|
|
||||||
defineRouteMeta({
|
defineRouteMeta({
|
||||||
title: '首页',
|
title: '首页',
|
||||||
name: 'testIndex',
|
name: 'testIndex',
|
||||||
layout: false,
|
layout: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
request('http://f1.test-adm.weoa.com/rcs-cscm/user/checkAlddddive.do');
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user