2023-02-21 20:05:25 +08:00
|
|
|
import { Component, DefineComponent, Component, App } from 'vue';
|
2022-11-10 19:08:35 +08:00
|
|
|
import { RouteRecordRaw, Router, RouterHistory, createMemoryHistory, createWebHashHistory, createWebHistory } from 'vue-router';
|
2022-04-15 22:54:51 +08:00
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
import { Plugin } from '@fesjs/runtime';
|
|
|
|
|
|
|
|
interface BeforeRenderConfig {
|
|
|
|
loading: Component;
|
|
|
|
action: () => Promise<any>;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ClientRenderOption {
|
|
|
|
routes: RouteRecordRaw[];
|
|
|
|
rootElement: string;
|
|
|
|
defaultTitle: string;
|
|
|
|
plugin: Plugin;
|
|
|
|
}
|
|
|
|
|
2023-02-21 20:05:25 +08:00
|
|
|
type RenderFunc = () => Promise<App>;
|
2022-04-15 22:54:51 +08:00
|
|
|
|
2023-02-21 20:05:25 +08:00
|
|
|
interface Route {
|
|
|
|
base: string;
|
|
|
|
mode: string;
|
2023-02-27 14:29:37 +08:00
|
|
|
routes: RouteRecordRaw[];
|
2022-11-10 19:08:35 +08:00
|
|
|
createHistory: createMemoryHistory | createWebHashHistory | createWebHistory;
|
|
|
|
}
|
2022-04-15 22:54:51 +08:00
|
|
|
|
2022-11-10 17:48:34 +08:00
|
|
|
export function getRouter(): Router;
|
|
|
|
export function getHistory(): RouterHistory;
|
|
|
|
export function destroyRouter(): void;
|
|
|
|
|
|
|
|
declare module '@fesjs/fes' {
|
|
|
|
interface PluginRuntimeConfig {
|
2023-02-21 20:05:25 +08:00
|
|
|
beforeRender?: BeforeRenderConfig;
|
2022-11-10 17:48:34 +08:00
|
|
|
patchRoutes?: ({ routes }: { routes: RouteRecordRaw[] }) => void;
|
2023-02-27 14:29:37 +08:00
|
|
|
modifyRoute?: ({ base, mode, routes, createHistory }: Route) => Route;
|
2022-11-10 17:48:34 +08:00
|
|
|
modifyClientRenderOpts?: (option: ClientRenderOption) => ClientRenderOption;
|
2023-02-21 20:05:25 +08:00
|
|
|
rootContainer?: (component: DefineComponent, option: { routes: RouteRecordRaw[]; plugin: Plugin }) => Component;
|
|
|
|
onAppCreated?: ({ app, routes }: { app: App; routes: RouteRecordRaw[] }) => void;
|
2022-11-10 17:48:34 +08:00
|
|
|
render?: (defaultRender: RenderFunc) => RenderFunc;
|
|
|
|
onRouterCreated?: ({ router }: { router: Router }) => void;
|
|
|
|
}
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
interface PluginBuildConfig {
|
2023-02-21 20:05:25 +08:00
|
|
|
alias?: Record<string, string>;
|
2022-06-22 19:24:49 +08:00
|
|
|
autoprefixer?: {
|
|
|
|
/** environment for `Browserslist` */
|
2023-02-21 20:05:25 +08:00
|
|
|
env?: string;
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** should Autoprefixer use Visual Cascade, if CSS is uncompressed */
|
2023-02-21 20:05:25 +08:00
|
|
|
cascade?: boolean;
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** should Autoprefixer add prefixes. */
|
2023-02-21 20:05:25 +08:00
|
|
|
add?: boolean;
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** should Autoprefixer [remove outdated] prefixes */
|
2023-02-21 20:05:25 +08:00
|
|
|
remove?: boolean;
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** should Autoprefixer add prefixes for @supports parameters. */
|
2023-02-21 20:05:25 +08:00
|
|
|
supports?: boolean;
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** should Autoprefixer add prefixes for flexbox properties */
|
2023-02-21 20:05:25 +08:00
|
|
|
flexbox?: boolean | 'no-2009';
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */
|
2023-02-21 20:05:25 +08:00
|
|
|
grid?: boolean;
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2023-02-21 20:05:25 +08:00
|
|
|
overrideBrowserslist?: string | string[];
|
|
|
|
|
2022-06-22 19:24:49 +08:00
|
|
|
/** do not raise error on unknown browser version in `Browserslist` config. */
|
2023-02-21 20:05:25 +08:00
|
|
|
ignoreUnknownVersions?: boolean;
|
2022-06-22 19:24:49 +08:00
|
|
|
};
|
2023-02-21 20:05:25 +08:00
|
|
|
define?: Record<string, string | object>;
|
2022-06-22 19:24:49 +08:00
|
|
|
router?: {
|
|
|
|
base?: string;
|
|
|
|
routes?: RouteRecordRaw[];
|
2023-02-21 20:05:25 +08:00
|
|
|
mode?: 'hash' | 'history' | 'memory';
|
2022-06-22 19:24:49 +08:00
|
|
|
};
|
|
|
|
dynamicImport?: boolean;
|
|
|
|
inlineLimit?: number;
|
2023-02-21 20:05:25 +08:00
|
|
|
mock?:
|
|
|
|
| boolean
|
|
|
|
| {
|
|
|
|
prefix?: string;
|
|
|
|
};
|
2022-06-22 19:24:49 +08:00
|
|
|
mountElementId?: string;
|
|
|
|
plugins?: string[];
|
|
|
|
presets?: string[];
|
|
|
|
proxy?: {
|
|
|
|
[apiPrefix: string]: {
|
|
|
|
target: string;
|
|
|
|
changeOrigin?: boolean;
|
2023-02-21 20:05:25 +08:00
|
|
|
};
|
2022-06-22 19:24:49 +08:00
|
|
|
};
|
|
|
|
publicPath?: string;
|
|
|
|
singular?: boolean;
|
|
|
|
targets?: object;
|
|
|
|
terserOptions?: object;
|
|
|
|
title?: string;
|
|
|
|
}
|
|
|
|
}
|