From fd93190ee1804d724d5b34458e2c58f9acf0cae9 Mon Sep 17 00:00:00 2001 From: harrywan Date: Fri, 23 Apr 2021 17:16:59 +0800 Subject: [PATCH 1/6] =?UTF-8?q?docs:=20readme=E5=A2=9E=E5=8A=A0plugin-sass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bb326fc6..6916ef32 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Fes.js 是一个好用的前端应用解决方案。Fes.js 以 Vue 3.0 和路由 | [@fesjs/plugin-request](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/request.html#%E5%90%AF%E7%94%A8%E6%96%B9%E5%BC%8F) | 基于 `Axios` 封装的 request,内置防止重复请求、请求节流、错误处理等功能 | | [@fesjs/plugin-vuex](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/vuex.html#%E5%90%AF%E7%94%A8%E6%96%B9%E5%BC%8F) | 基于 `Vuex`, 提供状态管理能力 | | [@fesjs/plugin-qiankun](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/qiankun.html#%E4%BB%8B%E7%BB%8D) | 基于 `qiankun`,提供微服务能力 | +| @fesjs/plugin-sass | 样式支持sass | ## 像数 1, 2, 3 一样容易 使用 `yarn`: From 2dc949f9ca211adc3e5d5081c7d49a7ed4b0f33b Mon Sep 17 00:00:00 2001 From: harrywan Date: Mon, 26 Apr 2021 17:28:41 +0800 Subject: [PATCH 2/6] docs: plugin-sass --- README.md | 2 +- docs/.vuepress/configs/sidebar/en.ts | 21 +++++++++--------- docs/.vuepress/configs/sidebar/zh.ts | 21 +++++++++--------- docs/reference/plugin/plugins/sass.md | 27 ++++++++++++++++++++++++ docs/zh/reference/plugin/plugins/sass.md | 27 ++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 docs/reference/plugin/plugins/sass.md create mode 100644 docs/zh/reference/plugin/plugins/sass.md diff --git a/README.md b/README.md index 6916ef32..debc1a7a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Fes.js 是一个好用的前端应用解决方案。Fes.js 以 Vue 3.0 和路由 | [@fesjs/plugin-request](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/request.html#%E5%90%AF%E7%94%A8%E6%96%B9%E5%BC%8F) | 基于 `Axios` 封装的 request,内置防止重复请求、请求节流、错误处理等功能 | | [@fesjs/plugin-vuex](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/vuex.html#%E5%90%AF%E7%94%A8%E6%96%B9%E5%BC%8F) | 基于 `Vuex`, 提供状态管理能力 | | [@fesjs/plugin-qiankun](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/qiankun.html#%E4%BB%8B%E7%BB%8D) | 基于 `qiankun`,提供微服务能力 | -| @fesjs/plugin-sass | 样式支持sass | +| [@fesjs/plugin-sass]((https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/sass.html#%E4%BB%8B%E7%BB%8D) ) | 样式支持sass | ## 像数 1, 2, 3 一样容易 使用 `yarn`: diff --git a/docs/.vuepress/configs/sidebar/en.ts b/docs/.vuepress/configs/sidebar/en.ts index 33ffac35..2f53a7e7 100644 --- a/docs/.vuepress/configs/sidebar/en.ts +++ b/docs/.vuepress/configs/sidebar/en.ts @@ -7,22 +7,22 @@ export const en: SidebarConfig = { text: '介绍', children: [ '/guide/README.md', - '/guide/getting-started.md', + '/guide/getting-started.md', ], }, { isGroup: true, text: '基础', children: [ - '/guide/directory-structure.md', - '/guide/config.md', - '/guide/runtime-config.md', - '/guide/route.md', - '/guide/plugin.md', - '/guide/template.md', - '/guide/mock.md', - '/guide/env.md', - '/guide/css.md', + '/guide/directory-structure.md', + '/guide/config.md', + '/guide/runtime-config.md', + '/guide/route.md', + '/guide/plugin.md', + '/guide/template.md', + '/guide/mock.md', + '/guide/env.md', + '/guide/css.md', ] }, { @@ -61,6 +61,7 @@ export const en: SidebarConfig = { '/reference/plugin/plugins/request.md', '/reference/plugin/plugins/vuex.md', '/reference/plugin/plugins/qiankun.md', + '/reference/plugin/plugins/sass.md', ], }, { diff --git a/docs/.vuepress/configs/sidebar/zh.ts b/docs/.vuepress/configs/sidebar/zh.ts index 60fa945a..a87ca98b 100644 --- a/docs/.vuepress/configs/sidebar/zh.ts +++ b/docs/.vuepress/configs/sidebar/zh.ts @@ -7,22 +7,22 @@ export const zh: SidebarConfig = { text: '介绍', children: [ '/zh/guide/README.md', - '/zh/guide/getting-started.md', + '/zh/guide/getting-started.md', ], }, { isGroup: true, text: '基础', children: [ - '/zh/guide/directory-structure.md', - '/zh/guide/config.md', - '/zh/guide/runtime-config.md', - '/zh/guide/route.md', - '/zh/guide/plugin.md', - '/zh/guide/template.md', - '/zh/guide/mock.md', - '/zh/guide/env.md', - '/zh/guide/css.md', + '/zh/guide/directory-structure.md', + '/zh/guide/config.md', + '/zh/guide/runtime-config.md', + '/zh/guide/route.md', + '/zh/guide/plugin.md', + '/zh/guide/template.md', + '/zh/guide/mock.md', + '/zh/guide/env.md', + '/zh/guide/css.md', ] }, { @@ -61,6 +61,7 @@ export const zh: SidebarConfig = { '/zh/reference/plugin/plugins/request.md', '/zh/reference/plugin/plugins/vuex.md', '/zh/reference/plugin/plugins/qiankun.md', + '/zh/reference/plugin/plugins/sass.md', ], }, { diff --git a/docs/reference/plugin/plugins/sass.md b/docs/reference/plugin/plugins/sass.md new file mode 100644 index 00000000..172460f1 --- /dev/null +++ b/docs/reference/plugin/plugins/sass.md @@ -0,0 +1,27 @@ +# @fesjs/plugin-access + + + +## 介绍 +Fes.js 默认只支持 `less`,通过此插件扩展支持 `sass` + +## 启用方式 +在 `package.json` 中引入依赖: +```json +{ + "dependencies": { + "@fesjs/fes": "^2.0.0", + "@fesjs/plugin-sass": "^2.0.0" + }, +} +``` + +## global css +添加 `src/global.scss` 和 `src/global.sass` 为全局CSS入口,添加一些通用样式内容。 + +## Vue 单文件组件 +Vue 单文件组件的 `` 添加 `lang='scss'`,例如: +```vue + +``` \ No newline at end of file diff --git a/docs/zh/reference/plugin/plugins/sass.md b/docs/zh/reference/plugin/plugins/sass.md new file mode 100644 index 00000000..172460f1 --- /dev/null +++ b/docs/zh/reference/plugin/plugins/sass.md @@ -0,0 +1,27 @@ +# @fesjs/plugin-access + + + +## 介绍 +Fes.js 默认只支持 `less`,通过此插件扩展支持 `sass` + +## 启用方式 +在 `package.json` 中引入依赖: +```json +{ + "dependencies": { + "@fesjs/fes": "^2.0.0", + "@fesjs/plugin-sass": "^2.0.0" + }, +} +``` + +## global css +添加 `src/global.scss` 和 `src/global.sass` 为全局CSS入口,添加一些通用样式内容。 + +## Vue 单文件组件 +Vue 单文件组件的 `` 添加 `lang='scss'`,例如: +```vue + +``` \ No newline at end of file From a20b40cbbce5a9dbeddce156756383b0d1f513a7 Mon Sep 17 00:00:00 2001 From: harrywan Date: Mon, 26 Apr 2021 17:31:48 +0800 Subject: [PATCH 3/6] docs: plugin-sass --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index debc1a7a..547ee4d5 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Fes.js 是一个好用的前端应用解决方案。Fes.js 以 Vue 3.0 和路由 | [@fesjs/plugin-request](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/request.html#%E5%90%AF%E7%94%A8%E6%96%B9%E5%BC%8F) | 基于 `Axios` 封装的 request,内置防止重复请求、请求节流、错误处理等功能 | | [@fesjs/plugin-vuex](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/vuex.html#%E5%90%AF%E7%94%A8%E6%96%B9%E5%BC%8F) | 基于 `Vuex`, 提供状态管理能力 | | [@fesjs/plugin-qiankun](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/qiankun.html#%E4%BB%8B%E7%BB%8D) | 基于 `qiankun`,提供微服务能力 | -| [@fesjs/plugin-sass]((https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/sass.html#%E4%BB%8B%E7%BB%8D) ) | 样式支持sass | +| [@fesjs/plugin-sass](https://winixt.gitee.io/fesjs/zh/reference/plugin/plugins/sass.html#%E4%BB%8B%E7%BB%8D) | 样式支持sass | ## 像数 1, 2, 3 一样容易 使用 `yarn`: From c6c133ca5afacdf9a16e676568915ce92b9f232a Mon Sep 17 00:00:00 2001 From: bac-joker Date: Mon, 26 Apr 2021 17:34:01 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20request=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=85=B3=E9=97=ADcode=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh/reference/plugin/plugins/request.md | 2 ++ .../src/template/resErrorProcess.js | 5 +++-- packages/fes-template-h5/src/app.js | 12 +++++++++++- packages/fes-template-h5/src/pages/index.vue | 12 ++++++------ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/zh/reference/plugin/plugins/request.md b/docs/zh/reference/plugin/plugins/request.md index 777ad34e..b4c557f5 100644 --- a/docs/zh/reference/plugin/plugins/request.md +++ b/docs/zh/reference/plugin/plugins/request.md @@ -51,6 +51,8 @@ export const request = { responseDataAdaptor: (data) => { }, + // 关闭 response data 校验(只判断 xhr status) + closeResDataCheck: false, // 请求拦截器 requestInterceptors: [], // 相应拦截器 diff --git a/packages/fes-plugin-request/src/template/resErrorProcess.js b/packages/fes-plugin-request/src/template/resErrorProcess.js index d0f6db42..370c5511 100644 --- a/packages/fes-plugin-request/src/template/resErrorProcess.js +++ b/packages/fes-plugin-request/src/template/resErrorProcess.js @@ -25,9 +25,10 @@ export default async (ctx, next) => { const { error, errorHandler = {}, - response + response, + config } = ctx; - if (response && isObject(response.data)) { + if (!config.closeResDataCheck && response && isObject(response.data)) { const code = response.data.code; if (code !== '0') { handleAbnormalCode(errorHandler, code, response); diff --git a/packages/fes-template-h5/src/app.js b/packages/fes-template-h5/src/app.js index f5074050..f340fe58 100644 --- a/packages/fes-template-h5/src/app.js +++ b/packages/fes-template-h5/src/app.js @@ -1,4 +1,14 @@ export const request = { + responseInterceptors: [(response) => { + console.log(response); + if (response.data !== '0') { + return Promise.reject({ + response + }); + } + return response; + }], + closeResDataCheck: true, errorHandler: { 111(responseData) { console.log(responseData); @@ -7,7 +17,7 @@ export const request = { console.log('to 404 page'); }, default(error) { - console.log(error.response.data); + console.log(error); } } }; diff --git a/packages/fes-template-h5/src/pages/index.vue b/packages/fes-template-h5/src/pages/index.vue index 29e5530c..b412e89b 100644 --- a/packages/fes-template-h5/src/pages/index.vue +++ b/packages/fes-template-h5/src/pages/index.vue @@ -2,8 +2,6 @@
fes & 拉夫德鲁
-
loading
-
{{data}}
@@ -14,7 +12,7 @@