diff --git a/packages/fes-builder-vite/src/registerType.js b/packages/fes-builder-vite/src/registerType.js index d9dbaca4..a771cb04 100644 --- a/packages/fes-builder-vite/src/registerType.js +++ b/packages/fes-builder-vite/src/registerType.js @@ -3,6 +3,5 @@ import { name } from '../package.json'; export default function (api) { api.addConfigType(() => ({ source: name, - build: ['ViteBuildConfig'], })); } diff --git a/packages/fes-builder-vite/types.d.ts b/packages/fes-builder-vite/types.d.ts index 4008e2b3..e1fcc185 100644 --- a/packages/fes-builder-vite/types.d.ts +++ b/packages/fes-builder-vite/types.d.ts @@ -4,11 +4,12 @@ import {Options as PolyfillOptions } from '@vitejs/plugin-legacy' import createPlugin from '@vitejs/plugin-vue-jsx' import {createHtmlPlugin} from 'vite-plugin-html' - -export interface ViteBuildConfig { - viteOption?: UserConfig; - viteVuePlugin?: Options; - viteVueJsx?: Parameters[0]; - viteLegacy?: PolyfillOptions; - viteHtml?: Parameters[0] -} +declare module "@fesjs/fes" { + interface PluginBuildConfig { + viteOption?: UserConfig; + viteVuePlugin?: Options; + viteVueJsx?: Parameters[0]; + viteLegacy?: PolyfillOptions; + viteHtml?: Parameters[0] + } +} \ No newline at end of file diff --git a/packages/fes-builder-webpack/src/plugins/registerType.js b/packages/fes-builder-webpack/src/plugins/registerType.js index 2e8c1139..265efede 100644 --- a/packages/fes-builder-webpack/src/plugins/registerType.js +++ b/packages/fes-builder-webpack/src/plugins/registerType.js @@ -3,6 +3,5 @@ import { name } from '../../package.json'; export default function (api) { api.addConfigType(() => ({ source: name, - build: ['WebpackBuildConfig'], })); } diff --git a/packages/fes-builder-webpack/types.d.ts b/packages/fes-builder-webpack/types.d.ts index bdd3b1c2..fb96f4bb 100644 --- a/packages/fes-builder-webpack/types.d.ts +++ b/packages/fes-builder-webpack/types.d.ts @@ -7,51 +7,52 @@ interface CopyFileType { to: string; } -export interface WebpackBuildConfig { - analyze?: { - analyzerMode?: 'server' | 'static' | 'disabled'; - analyzerHost?: string; - analyzerPort?: number | 'auto'; - openAnalyzer?: boolean; - generateStatsFile?: boolean; - statsFilename?: string; - logLevel?: 'info' | 'warn' | 'error' | 'silent'; - defaultSizes?: 'stat' | 'parsed' | 'gzip' - }; - chainWebpack?: (memo: Config, args: {env: string, webpack: typeof webpack}) => void; - copy?: CopyFileType | CopyFileType[]; - cssLoader?: { - url?: boolean | ((url: string, resourcePath: string) => boolean); - import?: boolean | ({ filter: (url: string, media: string, resourcePath: string) => boolean }); - modules?: boolean | string | object; - sourceMap?: boolean; - importLoaders?: number; - onlyLocals?: boolean; - esModule?: boolean; - localsConvention?: 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'; - }; - devServer?: { - port?: number; - host?: string; - https?: boolean; - headers?: object; - [key: string]: any; - }; - devtool?: string; - exportStatic?: { - htmlSuffix?: boolean; - dynamicRoot?: boolean; - }; - externals?: object | string | Function; - extraBabelPlugins?: []; - extraBabelPresets?: []; - extraPostCSSPlugins?: []; - html?: HtmlWebpackPlugin.Options; - lessLoader?: Record; - nodeModulesTransform?: { - exclude: string[] - }; - postcssLoader?: Record; - vueLoader?: object; - -} \ No newline at end of file +declare module "@fesjs/fes" { + interface PluginBuildConfig { + analyze?: { + analyzerMode?: 'server' | 'static' | 'disabled'; + analyzerHost?: string; + analyzerPort?: number | 'auto'; + openAnalyzer?: boolean; + generateStatsFile?: boolean; + statsFilename?: string; + logLevel?: 'info' | 'warn' | 'error' | 'silent'; + defaultSizes?: 'stat' | 'parsed' | 'gzip' + }; + chainWebpack?: (memo: Config, args: {env: string, webpack: typeof webpack}) => void; + copy?: CopyFileType | CopyFileType[]; + cssLoader?: { + url?: boolean | ((url: string, resourcePath: string) => boolean); + import?: boolean | ({ filter: (url: string, media: string, resourcePath: string) => boolean }); + modules?: boolean | string | object; + sourceMap?: boolean; + importLoaders?: number; + onlyLocals?: boolean; + esModule?: boolean; + localsConvention?: 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'; + }; + devServer?: { + port?: number; + host?: string; + https?: boolean; + headers?: object; + [key: string]: any; + }; + devtool?: string; + exportStatic?: { + htmlSuffix?: boolean; + dynamicRoot?: boolean; + }; + externals?: object | string | Function; + extraBabelPlugins?: []; + extraBabelPresets?: []; + extraPostCSSPlugins?: []; + html?: HtmlWebpackPlugin.Options; + lessLoader?: Record; + nodeModulesTransform?: { + exclude: string[] + }; + postcssLoader?: Record; + vueLoader?: object; + } +} diff --git a/packages/fes-plugin-access/src/index.js b/packages/fes-plugin-access/src/index.js index ea01cd50..da94e032 100644 --- a/packages/fes-plugin-access/src/index.js +++ b/packages/fes-plugin-access/src/index.js @@ -56,7 +56,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - runtime: ['AccessRuntimeConfig'], - build: ['AccessBuildConfig'], })); }; diff --git a/packages/fes-plugin-access/types.d.ts b/packages/fes-plugin-access/types.d.ts index 9caa7d8a..551f3bb8 100644 --- a/packages/fes-plugin-access/types.d.ts +++ b/packages/fes-plugin-access/types.d.ts @@ -1,14 +1,16 @@ import { Router, NavigationGuard } from 'vue-router'; -export interface AccessBuildConfig { - access: { - rules: Record; - }; -} +declare module "@fesjs/fes" { + interface PluginBuildConfig { + access: { + rules: Record; + }; + } -export interface AccessRuntimeConfig { - access: { - noFoundHandler: (param: { router: Router } & NavigationGuard) => void; - unAccessHandler: (param: { router: Router } & NavigationGuard) => void; - }; + interface PluginRuntimeConfig { + access: { + noFoundHandler: (param: { router: Router } & NavigationGuard) => void; + unAccessHandler: (param: { router: Router } & NavigationGuard) => void; + }; + } } diff --git a/packages/fes-plugin-enums/src/index.js b/packages/fes-plugin-enums/src/index.js index c63ae77f..1c0ecb6e 100644 --- a/packages/fes-plugin-enums/src/index.js +++ b/packages/fes-plugin-enums/src/index.js @@ -46,6 +46,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - build: ['EnumsBuildConfig'], })); }; diff --git a/packages/fes-plugin-enums/types.d.ts b/packages/fes-plugin-enums/types.d.ts index 338b119a..5e466dec 100644 --- a/packages/fes-plugin-enums/types.d.ts +++ b/packages/fes-plugin-enums/types.d.ts @@ -1,7 +1,9 @@ -export interface EnumsBuildConfig { - enums: { - [key: string]: [string | number, string | number][] +declare module "@fesjs/fes" { + interface PluginBuildConfig { + enums: { + [key: string]: [string | number, string | number][] + } } } diff --git a/packages/fes-plugin-layout/src/index.js b/packages/fes-plugin-layout/src/index.js index eff1a9f5..6b2317b0 100644 --- a/packages/fes-plugin-layout/src/index.js +++ b/packages/fes-plugin-layout/src/index.js @@ -78,7 +78,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - runtime: ['LayoutRuntimeConfig'], - build: ['LayoutBuildConfig'], })); }; diff --git a/packages/fes-plugin-layout/types.d.ts b/packages/fes-plugin-layout/types.d.ts index d90459cb..4a906bda 100644 --- a/packages/fes-plugin-layout/types.d.ts +++ b/packages/fes-plugin-layout/types.d.ts @@ -10,29 +10,28 @@ interface Menu { children?: Menu[] } -export interface LayoutBuildConfig { - layout: { - title: string; - footer: string; - theme: 'dark' | 'light'; - multiTabs: boolean; - navigation: 'side' | 'top' | 'mixin'; - fixedHeader: boolean; - fixedSideBar: boolean; - sideWidth: number; - menus: Menu[]; - }; -} - - - -export interface LayoutRuntimeConfig { - layout: { - header: boolean; - sidebar: boolean; - logo: boolean; - customHeader: Component, - noFoundHandler: (param: { router: Router } & NavigationGuard) => void; - unAccessHandler: (param: { router: Router } & NavigationGuard) => void; - }; -} +declare module "@fesjs/fes" { + interface PluginBuildConfig { + layout: { + title: string; + footer: string; + theme: 'dark' | 'light'; + multiTabs: boolean; + navigation: 'side' | 'top' | 'mixin'; + fixedHeader: boolean; + fixedSideBar: boolean; + sideWidth: number; + menus: Menu[]; + }; + } + interface PluginRuntimeConfig { + layout: { + header: boolean; + sidebar: boolean; + logo: boolean; + customHeader: Component, + noFoundHandler: (param: { router: Router } & NavigationGuard) => void; + unAccessHandler: (param: { router: Router } & NavigationGuard) => void; + }; + } +} \ No newline at end of file diff --git a/packages/fes-plugin-locale/src/index.js b/packages/fes-plugin-locale/src/index.js index 44e55456..055906a2 100644 --- a/packages/fes-plugin-locale/src/index.js +++ b/packages/fes-plugin-locale/src/index.js @@ -85,6 +85,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - build: ['LocalBuildConfig'], })); }; diff --git a/packages/fes-plugin-locale/types.d.ts b/packages/fes-plugin-locale/types.d.ts index 7b9020d3..6221e3ad 100644 --- a/packages/fes-plugin-locale/types.d.ts +++ b/packages/fes-plugin-locale/types.d.ts @@ -1,8 +1,10 @@ -export interface LocalBuildConfig { - locale: { - locale: string; - fallbackLocale: string; - baseNavigator: boolean; - legacy: boolean; - }; +declare module "@fesjs/fes" { + interface PluginBuildConfig { + locale: { + locale: string; + fallbackLocale: string; + baseNavigator: boolean; + legacy: boolean; + }; + } } diff --git a/packages/fes-plugin-monaco-editor/src/index.js b/packages/fes-plugin-monaco-editor/src/index.js index 9155731f..025ad594 100644 --- a/packages/fes-plugin-monaco-editor/src/index.js +++ b/packages/fes-plugin-monaco-editor/src/index.js @@ -89,6 +89,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - build: ['MonacoEditorBuildConfig'], })); }; diff --git a/packages/fes-plugin-monaco-editor/types.d.ts b/packages/fes-plugin-monaco-editor/types.d.ts index dbc512b5..b3dd44a5 100644 --- a/packages/fes-plugin-monaco-editor/types.d.ts +++ b/packages/fes-plugin-monaco-editor/types.d.ts @@ -1,12 +1,14 @@ import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages'; import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features'; -export interface MonacoEditorBuildConfig { - monacoEditor: { - filename: string; - publicPath: string; - languages: EditorLanguage[]; - features: EditorFeature[]; - globalAPI: boolean; - }; +declare module "@fesjs/fes" { + interface PluginBuildConfig { + monacoEditor: { + filename: string; + publicPath: string; + languages: EditorLanguage[]; + features: EditorFeature[]; + globalAPI: boolean; + }; + } } diff --git a/packages/fes-plugin-qiankun/types.d.ts b/packages/fes-plugin-qiankun/types.d.ts index a92744ef..bbcf2912 100644 --- a/packages/fes-plugin-qiankun/types.d.ts +++ b/packages/fes-plugin-qiankun/types.d.ts @@ -6,14 +6,16 @@ interface AppOption { props: Record; } -export interface QiankunBuildConfig { - qiankun: { - main: { - apps: AppOption[]; - lifeCycles?: FrameworkLifeCycles; - [key: string]: any; - }; - micro: {} - }; +declare module "@fesjs/fes" { + interface PluginBuildConfig { + qiankun: { + main: { + apps: AppOption[]; + lifeCycles?: FrameworkLifeCycles; + [key: string]: any; + }; + micro: {} + }; + } } diff --git a/packages/fes-plugin-request/src/index.js b/packages/fes-plugin-request/src/index.js index 0e4fcef5..019b2d40 100644 --- a/packages/fes-plugin-request/src/index.js +++ b/packages/fes-plugin-request/src/index.js @@ -26,6 +26,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - runtime: ['RequestRuntimeConfig'], })); }; diff --git a/packages/fes-plugin-request/types.d.ts b/packages/fes-plugin-request/types.d.ts index 02aefaf2..2e03955a 100644 --- a/packages/fes-plugin-request/types.d.ts +++ b/packages/fes-plugin-request/types.d.ts @@ -1,18 +1,27 @@ -import { AxiosRequestConfig, AxiosResponse } from 'axios'; +import { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'; +import {Ref} from 'vue'; type RequestInterceptor = (value: AxiosRequestConfig) => AxiosRequestConfig | [(value: AxiosRequestConfig) => AxiosRequestConfig, (error: any) => any]; type ResponseInterceptor = (value: AxiosResponse) => AxiosResponse | [(value: AxiosResponse) => AxiosResponse, (error: any) => any]; +interface RequestPluginOption { + mergeRequest: boolean; + cache: boolean | { + type: 'ram' | 'sessionStorage' | 'localStorage', + cacheTime: number; + } +} -export interface RequestRuntimeConfig { - request: { - responseDataAdaptor?(data: T): T; - closeResDataCheck?: boolean; - requestInterceptors?: RequestInterceptor[]; - responseInterceptors?: ResponseInterceptor[]; - errorHandler?: { - [key: string]: (error: { response: AxiosResponse } | AxiosResponse) => void; - }; - } & AxiosRequestConfig; +declare module "@fesjs/fes" { + interface PluginRuntimeConfig { + request: { + dataHandler?(data: any, response: AxiosResponse): any; + errorHandler?(error: AxiosError | {type: string, msg: string, [key: string]: string}): void; + requestInterceptors?: RequestInterceptor[]; + responseInterceptors?: ResponseInterceptor[]; + } & AxiosRequestConfig; + } + export function request(url: string, data: null | Record, options: AxiosRequestConfig & RequestPluginOption ): Promise + export function useRequest(url: string, data: null | Record, options: AxiosRequestConfig & RequestPluginOption ): {loadingRef: Ref; errorRef: Ref; dataRef: Ref} } \ No newline at end of file diff --git a/packages/fes-plugin-vuex/src/index.js b/packages/fes-plugin-vuex/src/index.js index 3c1c1c52..a9d1363c 100644 --- a/packages/fes-plugin-vuex/src/index.js +++ b/packages/fes-plugin-vuex/src/index.js @@ -61,6 +61,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - build: ['VuexBuildConfig'], })); }; diff --git a/packages/fes-plugin-vuex/types.d.ts b/packages/fes-plugin-vuex/types.d.ts index 475eeac3..6ece6132 100644 --- a/packages/fes-plugin-vuex/types.d.ts +++ b/packages/fes-plugin-vuex/types.d.ts @@ -1,8 +1,11 @@ -export interface VuexBuildConfig { - vuex: { - strict: boolean; - devtools: boolean; + +declare module "@fesjs/fes" { + interface PluginBuildConfig { + vuex: { + strict: boolean; + devtools: boolean; + } } } diff --git a/packages/fes-plugin-windicss/src/index.js b/packages/fes-plugin-windicss/src/index.js index 3e998f98..a1e3ef66 100644 --- a/packages/fes-plugin-windicss/src/index.js +++ b/packages/fes-plugin-windicss/src/index.js @@ -69,6 +69,5 @@ export default (api) => { api.addConfigType(() => ({ source: name, - build: ['WindicssBuildConfig'], })); }; diff --git a/packages/fes-plugin-windicss/types.d.ts b/packages/fes-plugin-windicss/types.d.ts index b516787c..12ae8e4b 100644 --- a/packages/fes-plugin-windicss/types.d.ts +++ b/packages/fes-plugin-windicss/types.d.ts @@ -1,7 +1,9 @@ import type { Config } from 'windicss/types/interfaces'; -export interface WindicssBuildConfig { - windicss: { - config: Config +declare module "@fesjs/fes" { + interface PluginBuildConfig { + windicss: { + config: Config + } } } diff --git a/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js b/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js index e21f0eb0..375ecdbc 100644 --- a/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js +++ b/packages/fes-preset-built-in/src/plugins/generateFiles/genType.js @@ -1,14 +1,12 @@ function importsToStr(imports) { return imports.map((imp) => { - const { source, build = [], runtime = [] } = imp; - return `import {${build.concat(runtime).join(', ')}} from '${source}';`; + const { source } = imp; + return `import '${source}';`; }); } function genTypeContent(imports) { return { - RUNTIME_TYPES: imports.reduce((previousValue, currentValue) => previousValue.concat(currentValue.runtime || []), []).join(' & '), - BUILD_TYPES: imports.reduce((previousValue, currentValue) => previousValue.concat(currentValue.build || []), []).join(' & '), imports: importsToStr(imports).join('\n'), }; } @@ -21,9 +19,6 @@ export default function (api) { api.onGenerateFiles(async () => { const typeTpl = ` {{{ imports }}} - -export type PluginRuntimeConfig = {{{RUNTIME_TYPES}}}; -export type PluginBuildConfig = {{{BUILD_TYPES}}}; `; const importSources = await api.applyPlugins({ key: 'addConfigType', diff --git a/packages/fes-preset-built-in/types.d.ts b/packages/fes-preset-built-in/types.d.ts index a6e38aad..6156f1b0 100644 --- a/packages/fes-preset-built-in/types.d.ts +++ b/packages/fes-preset-built-in/types.d.ts @@ -18,75 +18,78 @@ interface ClientRenderOption { type RenderFunc = () => Promise -export interface InnerRuntimeConfig { - beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig; - patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void; - modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption; - rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => DefineComponent; - onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void; - render?: (defaultRender: RenderFunc) => RenderFunc; - onRouterCreated?: ({ router }: { router: Router }) => void; + +declare module "@fesjs/fes" { + interface PluginBuildConfig { + alias?: Record, + autoprefixer?: { + /** environment for `Browserslist` */ + env?: string + + /** should Autoprefixer use Visual Cascade, if CSS is uncompressed */ + cascade?: boolean + + /** should Autoprefixer add prefixes. */ + add?: boolean + + /** should Autoprefixer [remove outdated] prefixes */ + remove?: boolean + + /** should Autoprefixer add prefixes for @supports parameters. */ + supports?: boolean + + /** should Autoprefixer add prefixes for flexbox properties */ + flexbox?: boolean | 'no-2009' + + /** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */ + grid?: boolean + + /** + * list of queries for target browsers. + * Try to not use it. + * The best practice is to use `.browserslistrc` config or `browserslist` key in `package.json` + * to share target browsers with Babel, ESLint and Stylelint + */ + overrideBrowserslist?: string | string[] + + /** do not raise error on unknown browser version in `Browserslist` config. */ + ignoreUnknownVersions?: boolean + }; + define?: Record, + router?: { + base?: string; + routes?: RouteRecordRaw[]; + mode?: 'hash' | 'history' | 'memory' + }; + dynamicImport?: boolean; + inlineLimit?: number; + mock?: boolean | { + prefix?: string; + }; + mountElementId?: string; + plugins?: string[]; + presets?: string[]; + proxy?: { + [apiPrefix: string]: { + target: string; + changeOrigin?: boolean; + } + }; + publicPath?: string; + singular?: boolean; + targets?: object; + terserOptions?: object; + title?: string; + } + interface PluginRuntimeConfig { + beforeRender?: (option: BeforeRenderConfig) => BeforeRenderConfig; + patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void; + modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption; + rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[], plugin: Plugin }) => DefineComponent; + onAppCreated?: ({ app, routes }: { app: App, routes: RouteRecordRaw[] }) => void; + render?: (defaultRender: RenderFunc) => RenderFunc; + onRouterCreated?: ({ router }: { router: Router }) => void; + } + + export function getRouter(): Router; } - - -export interface InnerBuildConfig { - alias?: Record, - autoprefixer?: { - /** environment for `Browserslist` */ - env?: string - - /** should Autoprefixer use Visual Cascade, if CSS is uncompressed */ - cascade?: boolean - - /** should Autoprefixer add prefixes. */ - add?: boolean - - /** should Autoprefixer [remove outdated] prefixes */ - remove?: boolean - - /** should Autoprefixer add prefixes for @supports parameters. */ - supports?: boolean - - /** should Autoprefixer add prefixes for flexbox properties */ - flexbox?: boolean | 'no-2009' - - /** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */ - grid?: boolean - - /** - * list of queries for target browsers. - * Try to not use it. - * The best practice is to use `.browserslistrc` config or `browserslist` key in `package.json` - * to share target browsers with Babel, ESLint and Stylelint - */ - overrideBrowserslist?: string | string[] - - /** do not raise error on unknown browser version in `Browserslist` config. */ - ignoreUnknownVersions?: boolean - }; - define?: Record, - router?: { - base?: string; - routes?: RouteRecordRaw[]; - mode?: 'hash' | 'history' | 'memory' - }; - dynamicImport?: boolean; - inlineLimit?: number; - mock?: boolean | { - prefix?: string; - }; - mountElementId?: string; - plugins?: string[]; - presets?: string[]; - proxy?: { - [apiPrefix: string]: { - target: string; - changeOrigin?: boolean; - } - }; - publicPath?: string; - singular?: boolean; - targets?: object; - terserOptions?: object; - title?: string; -} \ No newline at end of file diff --git a/packages/fes-template-h5/src/app.js b/packages/fes-template-h5/src/app.js index cbb3e52d..fd26745d 100644 --- a/packages/fes-template-h5/src/app.js +++ b/packages/fes-template-h5/src/app.js @@ -1,42 +1,46 @@ import { defineRuntimeConfig } from '@fesjs/fes'; 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'); - }, + request: {}, }); + +// 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'); +// }, +// }); diff --git a/packages/fes/types.d.ts b/packages/fes/types.d.ts index 8921d265..e42083d0 100644 --- a/packages/fes/types.d.ts +++ b/packages/fes/types.d.ts @@ -1,17 +1,21 @@ // @ts-ignore -import type { PluginRuntimeConfig, PluginBuildConfig } from '@@/configType'; +import '@@/configType'; -// @ts-ignore -export * from '@@/core/coreExports'; -// @ts-ignore -export * from '@@/core/pluginExports'; +// // @ts-ignore +// export * from '@@/core/coreExports'; +// // @ts-ignore +// export * from '@@/core/pluginExports'; -interface RouteMeta { +export interface RouteMeta { name?: string; title?: string; layout?: boolean | { sidebar?: boolean; header?: boolean; logo?: boolean }; } +export interface PluginRuntimeConfig {} + +export interface PluginBuildConfig {} + export declare function defineRouteMeta(routeMeta: RouteMeta): RouteMeta; export function defineBuildConfig(config: PluginBuildConfig ): PluginBuildConfig;