diff --git a/package.json b/package.json
index 1b357cff..691717da 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"docs:dev": "vuepress dev docs --clean-cache",
"docs:build": "vuepress build docs --clean-cache",
"test": "fes test",
- "lint": "eslint -c ./.eslintrc.js --ext .js,.jsx,.vue,.ts",
+ "lint": "eslint -c ./.eslintrc.js --ignore-pattern='templates' --ext .js,.jsx,.vue,.ts",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"license": "MIT",
@@ -57,7 +57,7 @@
},
"lint-staged": {
"*.{js,jsx,vue,ts}": [
- "eslint"
+ "npm run lint"
]
},
"husky": {
@@ -71,4 +71,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
-}
+}
\ No newline at end of file
diff --git a/packages/create-fes-app/templates/app/h5/.eslintrc.js b/packages/create-fes-app/templates/app/h5/.eslintrc.js
index 74c6bf29..9847c436 100644
--- a/packages/create-fes-app/templates/app/h5/.eslintrc.js
+++ b/packages/create-fes-app/templates/app/h5/.eslintrc.js
@@ -1,19 +1,16 @@
-
module.exports = {
- extends: [
- '@webank/eslint-config-webank/vue.js'
- ],
+ extends: ['@webank/eslint-config-webank/vue.js'],
globals: {
// 这里填入你的项目需要的全局变量
// 这里值为 false 表示这个全局变量不允许被重新赋值,比如:
//
// Vue: false
- __DEV__: false
+ __DEV__: false,
},
rules: {
'vue/comment-directive': 'off',
'global-require': 'off',
'import/no-unresolved': 'off',
- 'no-restricted-syntax': 'off'
- }
+ 'no-restricted-syntax': 'off',
+ },
};
diff --git a/packages/create-fes-app/templates/app/h5/.fes.js b/packages/create-fes-app/templates/app/h5/.fes.js
index 6b90b7d6..c8fd19f6 100644
--- a/packages/create-fes-app/templates/app/h5/.fes.js
+++ b/packages/create-fes-app/templates/app/h5/.fes.js
@@ -1,18 +1,18 @@
// fes.config.js 只负责管理 cli 相关的配置
+import { defineBuildConfig } from '@fesjs/fes';
import pxtoviewport from '@ttou/postcss-px-to-viewport';
-
-export default {
+export default defineBuildConfig({
define: {
// __VUE_OPTIONS_API__: true,
// __VUE_PROD_DEVTOOLS__: false
},
html: {
- title: '拉夫德鲁'
+ title: '拉夫德鲁',
},
targets: {
chrome: '61',
- ios: '10'
+ ios: '10',
},
extraPostCSSPlugins: [
pxtoviewport({
@@ -28,7 +28,7 @@ export default {
replace: true,
exclude: [],
landscape: false,
- landscapeUnit: 'vw'
- })
- ]
-};
+ landscapeUnit: 'vw',
+ }),
+ ],
+});
diff --git a/packages/create-fes-app/templates/app/h5/package.json b/packages/create-fes-app/templates/app/h5/package.json
index 4a0cbb5e..dbe6dd11 100644
--- a/packages/create-fes-app/templates/app/h5/package.json
+++ b/packages/create-fes-app/templates/app/h5/package.json
@@ -44,12 +44,12 @@
"@ttou/postcss-px-to-viewport": "1.1.1"
},
"dependencies": {
- "@fesjs/fes": "^3.0.0-rc.0",
+ "@fesjs/fes": "^3.0.0-rc.1",
"@fesjs/plugin-icon": "^3.0.0-rc.0",
- "@fesjs/plugin-request": "^3.0.0-rc.0",
- "@fesjs/builder-webpack": "^3.0.0-rc.0",
+ "@fesjs/plugin-request": "^3.0.0-rc.3",
+ "@fesjs/builder-webpack": "^3.0.0-rc.1",
"vue": "^3.2.37",
- "core-js": "^3.19.2"
+ "core-js": "^3.26.1"
},
"private": true
}
\ No newline at end of file
diff --git a/packages/create-fes-app/templates/app/h5/src/app.js b/packages/create-fes-app/templates/app/h5/src/app.js
index d508ce12..fb0e2fd9 100644
--- a/packages/create-fes-app/templates/app/h5/src/app.js
+++ b/packages/create-fes-app/templates/app/h5/src/app.js
@@ -1,7 +1,44 @@
-export const request = {
- errorConfig: {
- 404() {
- console.log('to 404 page');
+import { defineRuntimeConfig } from '@fesjs/fes';
+
+export default defineRuntimeConfig({
+ request: {
+ // API 前缀
+ baseURL: '',
+ dataHandler(data, response) {
+ // 处理响应内容异常
+ if (data.code !== '0') {
+ if (data.code === '20000') {
+ console.log('hello world');
+ }
+ throw new Error(response);
+ }
+ // 响应数据格式化
+ return data?.result ? data.result : data;
},
+ // http 异常,和插件异常
+ 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);
+ },
+ // 请求拦截器
+ requestInterceptors: [],
+ // 响应拦截器
+ responseInterceptors: [],
},
-};
+});
diff --git a/packages/create-fes-app/templates/app/h5/src/common/utils.js b/packages/create-fes-app/templates/app/h5/src/common/utils.js
index 97d6e99c..27bf8a19 100644
--- a/packages/create-fes-app/templates/app/h5/src/common/utils.js
+++ b/packages/create-fes-app/templates/app/h5/src/common/utils.js
@@ -4,7 +4,6 @@
// 手机号、身份证号 等的校验
// 数字分割
-
export function resetContainerHeight(dom) {
const originalHeight = document.body.clientHeight || document.documentElement.clientHeight;
@@ -18,12 +17,11 @@ export function resetContainerHeight(dom) {
};
}
-
export function resetInputBlur() {
const isWechat = window.navigator.userAgent.match(/MicroMessenger\/([\d.]+)/i);
if (!isWechat) return;
const wechatVersion = isWechat[1];
- const version = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
+ const version = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
// 如果设备类型为iOS 12+ 和wechat 6.7.4+,恢复成原来的视口
if (+wechatVersion.replace(/\./g, '') >= 674 && +version[1] >= 12) {
diff --git a/packages/create-fes-app/templates/app/h5/src/icons/hello.svg b/packages/create-fes-app/templates/app/h5/src/icons/hello.svg
deleted file mode 100644
index a382e266..00000000
--- a/packages/create-fes-app/templates/app/h5/src/icons/hello.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
diff --git a/packages/create-fes-app/templates/app/h5/src/models/user.js b/packages/create-fes-app/templates/app/h5/src/models/user.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/packages/create-fes-app/templates/app/h5/src/pages/index.vue b/packages/create-fes-app/templates/app/h5/src/pages/index.vue
index 75098745..5b275aa0 100644
--- a/packages/create-fes-app/templates/app/h5/src/pages/index.vue
+++ b/packages/create-fes-app/templates/app/h5/src/pages/index.vue
@@ -3,18 +3,16 @@
fes & 拉夫德鲁