diff --git a/packages/fes-plugin-request/build.config.js b/packages/fes-plugin-request/build.config.js
index 6936129d..3f24a7e2 100644
--- a/packages/fes-plugin-request/build.config.js
+++ b/packages/fes-plugin-request/build.config.js
@@ -1,4 +1,3 @@
-
module.exports = {
- copy: ['template']
+ copy: ['template'],
};
diff --git a/packages/fes-plugin-request/src/index.js b/packages/fes-plugin-request/src/index.js
index d8407a19..a0e0d680 100644
--- a/packages/fes-plugin-request/src/index.js
+++ b/packages/fes-plugin-request/src/index.js
@@ -17,16 +17,14 @@ export default (api) => {
.string()
.pattern(/^[a-zA-Z]*$/)
.allow(''),
- base: joi
- .string()
- .allow('')
+ base: joi.string().allow(''),
});
},
default: {
base: '',
- dataField: ''
- }
- }
+ dataField: '',
+ },
+ },
});
const namespace = 'plugin-request';
@@ -40,12 +38,13 @@ export default (api) => {
// DEPRECATED
logger.warn('[DEPRECATED]: reqeust base 即将废弃,建议使用 axios baseURL代替:https://github.com/axios/axios');
}
+
api.writeTmpFile({
path: absoluteFilePath,
content: requestTemplate
.replace('REPLACE_DATA_FIELD', JSON.stringify(dataField))
.replace('REPLACE_BASE', base || '')
- .replace('AXIOS_PATH', resolvePkg('axios'))
+ .replace('AXIOS_PATH', resolvePkg('axios')),
});
});
@@ -56,14 +55,14 @@ export default (api) => {
api.copyTmpFiles({
namespace,
path: join(__dirname, 'template'),
- ignore: ['request.js']
+ ignore: ['request.js'],
});
});
api.addPluginExports(() => [
{
exportAll: true,
- source: absoluteFilePath
- }
+ source: absoluteFilePath,
+ },
]);
};
diff --git a/packages/fes-plugin-request/src/template/request.js b/packages/fes-plugin-request/src/template/request.js
index 88aa7517..abe392a6 100644
--- a/packages/fes-plugin-request/src/template/request.js
+++ b/packages/fes-plugin-request/src/template/request.js
@@ -2,10 +2,7 @@ import axios from 'AXIOS_PATH';
import { ApplyPluginsType, plugin } from '@fesjs/fes';
import { ref } from 'vue';
import scheduler from './scheduler';
-import {
- checkHttpRequestHasBody,
- isFunction
-} from './helpers';
+import { checkHttpRequestHasBody, isFunction } from './helpers';
import setDataField from './setDataField';
import paramsProcess from './paramsProcess';
@@ -53,13 +50,16 @@ function getRequestInstance() {
} = plugin.applyPlugins({
key: 'request',
type: ApplyPluginsType.modify,
- initialValue: {}
+ initialValue: {},
});
- const defaultConfig = Object.assign({
- timeout: 10000,
- withCredentials: true
- }, otherConfigs);
+ const defaultConfig = Object.assign(
+ {
+ timeout: 10000,
+ withCredentials: true,
+ },
+ otherConfigs,
+ );
const instance = axios.create(defaultConfig);
addRequestInterceptors(instance, requestInterceptors);
@@ -83,9 +83,9 @@ function getRequestInstance() {
defaultConfig,
dataField: REPLACE_DATA_FIELD, // eslint-disable-line
responseDataAdaptor,
- errorHandler
+ errorHandler,
},
- request: scheduler.compose()
+ request: scheduler.compose(),
};
}
@@ -117,12 +117,11 @@ function createContext(userConfig) {
...currentRequestInstance.context,
config: {
...currentRequestInstance.context.defaultConfig,
- ...userConfig
- }
+ ...userConfig,
+ },
};
}
-
function getResponseCode(response) {
if (response) {
if (response._rawData) return response._rawData.code;
@@ -142,12 +141,7 @@ function skipErrorHandlerToObj(skipErrorHandler = []) {
}, {});
}
-function handleRequestError({
- errorHandler = {},
- error,
- response,
- config
-}) {
+function handleRequestError({ errorHandler = {}, error, response, config }) {
// 跳过所有错误类型处理
if (config.skipErrorHandler === true) return;
@@ -171,7 +165,7 @@ function handleRequestError({
export const request = (url, data, options = {}) => {
if (typeof options === 'string') {
options = {
- method: options
+ method: options,
};
}
if (!currentRequestInstance) {
@@ -203,16 +197,19 @@ export const useRequest = (url, data, options = {}) => {
} else {
promise = request(url, data, options);
}
- promise.then((res) => {
- dataRef.value = res;
- }).catch((error) => {
- errorRef.value = error;
- }).finally(() => {
- loadingRef.value = false;
- });
+ promise
+ .then((res) => {
+ dataRef.value = res;
+ })
+ .catch((error) => {
+ errorRef.value = error;
+ })
+ .finally(() => {
+ loadingRef.value = false;
+ });
return {
loading: loadingRef,
error: errorRef,
- data: dataRef
+ data: dataRef,
};
};
diff --git a/packages/fes-preset-built-in/package.json b/packages/fes-preset-built-in/package.json
index 08ae5c8a..76f0467a 100644
--- a/packages/fes-preset-built-in/package.json
+++ b/packages/fes-preset-built-in/package.json
@@ -35,7 +35,6 @@
"@babel/preset-typescript": "^7.15.0",
"@fesjs/compiler": "^2.0.5",
"@fesjs/utils": "^2.0.4",
- "@originjs/vite-plugin-commonjs": "^1.0.3",
"@soda/friendly-errors-webpack-plugin": "^1.8.0",
"@vitejs/plugin-vue": "^2.2.4",
"@vitejs/plugin-vue-jsx": "^1.3.8",
diff --git a/packages/fes-preset-built-in/src/plugins/commands/dev/index.js b/packages/fes-preset-built-in/src/plugins/commands/dev/index.js
index c2581edf..1e14d9b6 100644
--- a/packages/fes-preset-built-in/src/plugins/commands/dev/index.js
+++ b/packages/fes-preset-built-in/src/plugins/commands/dev/index.js
@@ -5,7 +5,6 @@
import { createServer } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
-import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
import SFCConfigBlockPlugin from './SFCConfigBlockPlugin';
const assert = require('assert');
@@ -138,14 +137,18 @@ export default (api) => {
server = await createServer({
mode: 'development',
- plugins: [vue(), SFCConfigBlockPlugin, vueJsx(), viteCommonjs()],
+ plugins: [vue(), SFCConfigBlockPlugin, vueJsx()],
configFile: false,
resolve: {
alias: {
'@': paths.absSrcPath,
'@@': paths.absTmpPath,
+ '@fesInner': '/',
},
},
+ optimizeDeps: {
+ // exclude: ['@fesjs/fes'],
+ },
server: {
port: 8000,
},
diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl b/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl
index e2577c64..b4076973 100644
--- a/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl
+++ b/packages/fes-preset-built-in/src/plugins/generateFiles/core/exports/coreExports.tpl
@@ -14,4 +14,9 @@ export {
ApplyPluginsType
} from 'RUNTIME_PATH';
-CORE_EXPORTS
\ No newline at end of file
+CORE_EXPORTS
+
+// TODO 优化,放到合适的位置,不能放在 routes,会造成循环依赖
+export const defineRouteMeta = (param)=>{
+ return param
+}
diff --git a/packages/fes-preset-built-in/src/plugins/misc/route/index.js b/packages/fes-preset-built-in/src/plugins/misc/route/index.js
index 42a1f663..2a662c34 100644
--- a/packages/fes-preset-built-in/src/plugins/misc/route/index.js
+++ b/packages/fes-preset-built-in/src/plugins/misc/route/index.js
@@ -347,7 +347,7 @@ export default function (api) {
api.addCoreExports(() => [
{
- specifiers: ['getRoutes', 'getRouter', 'getHistory', 'destroyRouter', 'defineRouteMeta'],
+ specifiers: ['getRoutes', 'getRouter', 'getHistory', 'destroyRouter'],
source: absCoreFilePath,
},
]);
diff --git a/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl b/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl
index 1faed13e..28b6d24a 100644
--- a/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl
+++ b/packages/fes-preset-built-in/src/plugins/misc/route/template/routes.tpl
@@ -1,5 +1,5 @@
import { createRouter as createVueRouter, {{{ CREATE_HISTORY }}}, ApplyPluginsType } from '{{{ runtimePath }}}';
-import { plugin } from '@@/core/coreExports';
+import { plugin } from '../plugin';
{{{ COMPONENTS_IMPORT }}}
@@ -62,7 +62,3 @@ export const destroyRouter = ()=>{
router = null;
history = null;
}
-
-export const defineRouteMeta = (param)=>{
- return param
-}
diff --git a/packages/fes-template-h5/src/components/helloTS.ts b/packages/fes-template-h5/src/components/helloTS.ts
deleted file mode 100644
index 44f321d6..00000000
--- a/packages/fes-template-h5/src/components/helloTS.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { defineComponent } from 'vue';
-
-export default defineComponent({
- setup() {
- return () => 'hello ts';
- }
-});
diff --git a/packages/fes-template-h5/src/components/helloTSX.tsx b/packages/fes-template-h5/src/components/helloTSX.tsx
deleted file mode 100644
index 8a723c57..00000000
--- a/packages/fes-template-h5/src/components/helloTSX.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import {defineComponent} from 'vue';
-
-export default defineComponent({
- setup() {
- return () => {
- return 'hello tsx'
- }
- }
-})
\ No newline at end of file
diff --git a/packages/fes-template-h5/src/pages/index.vue b/packages/fes-template-h5/src/pages/index.vue
index 7b52bee6..3afa6f69 100644
--- a/packages/fes-template-h5/src/pages/index.vue
+++ b/packages/fes-template-h5/src/pages/index.vue
@@ -3,16 +3,12 @@
fes h5 & 拉夫德鲁