forked from Lesin/reposync
chore: stop tracking .umi and update .gitignore
This commit is contained in:
parent
e2835f7c59
commit
50e3259693
|
@ -0,0 +1,13 @@
|
||||||
|
/node_modules
|
||||||
|
/.env.local
|
||||||
|
/.umirc.local.ts
|
||||||
|
/config/config.local.ts
|
||||||
|
/src/.umi
|
||||||
|
/src/.umi-production
|
||||||
|
/src/.umi-test
|
||||||
|
/.umi
|
||||||
|
/.umi-production
|
||||||
|
/.umi-test
|
||||||
|
/dist
|
||||||
|
/.mfsu
|
||||||
|
.swc
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,21 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import { createBrowserHistory, History } from '/root/ob-repository-synchronize/web/node_modules/umi/node_modules/@umijs/runtime';
|
|
||||||
|
|
||||||
let options = {
|
|
||||||
"basename": "/"
|
|
||||||
};
|
|
||||||
if ((<any>window).routerBase) {
|
|
||||||
options.basename = (<any>window).routerBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove initial history because of ssr
|
|
||||||
let history: History = process.env.__IS_SERVER ? null : createBrowserHistory(options);
|
|
||||||
export const createHistory = (hotReload = false) => {
|
|
||||||
if (!hotReload) {
|
|
||||||
history = createBrowserHistory(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return history;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { history };
|
|
|
@ -1,8 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import { Plugin } from '/root/ob-repository-synchronize/web/node_modules/umi/node_modules/@umijs/runtime';
|
|
||||||
|
|
||||||
const plugin = new Plugin({
|
|
||||||
validKeys: ['modifyClientRenderOpts','patchRoutes','rootContainer','render','onRouteChange','__mfsu','getInitialState','initialStateConfig','request',],
|
|
||||||
});
|
|
||||||
|
|
||||||
export { plugin };
|
|
|
@ -1,303 +0,0 @@
|
||||||
// Created by Umi Plugin
|
|
||||||
|
|
||||||
export interface IConfigFromPlugins {
|
|
||||||
"404"?: boolean
|
|
||||||
routes?: {
|
|
||||||
/**
|
|
||||||
* Any valid URL path
|
|
||||||
*/
|
|
||||||
path?: string
|
|
||||||
/**
|
|
||||||
* A React component to render only when the location matches.
|
|
||||||
*/
|
|
||||||
component?: (string | (() => any))
|
|
||||||
wrappers?: string[]
|
|
||||||
/**
|
|
||||||
* navigate to a new location
|
|
||||||
*/
|
|
||||||
redirect?: string
|
|
||||||
/**
|
|
||||||
* When true, the active class/style will only be applied if the location is matched exactly.
|
|
||||||
*/
|
|
||||||
exact?: boolean
|
|
||||||
routes?: any[]
|
|
||||||
[k: string]: any
|
|
||||||
}[]
|
|
||||||
history?: {
|
|
||||||
type?: ("browser" | "hash" | "memory")
|
|
||||||
options?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
polyfill?: {
|
|
||||||
imports?: string[]
|
|
||||||
}
|
|
||||||
alias?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
analyze?: {
|
|
||||||
analyzerMode?: ("server" | "static" | "disabled")
|
|
||||||
analyzerHost?: string
|
|
||||||
analyzerPort?: any
|
|
||||||
openAnalyzer?: boolean
|
|
||||||
generateStatsFile?: boolean
|
|
||||||
statsFilename?: string
|
|
||||||
logLevel?: ("info" | "warn" | "error" | "silent")
|
|
||||||
defaultSizes?: ("stat" | "parsed" | "gzip")
|
|
||||||
[k: string]: any
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* postcss autoprefixer, default flexbox: no-2009
|
|
||||||
*/
|
|
||||||
autoprefixer?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
base?: string
|
|
||||||
chainWebpack?: (() => any)
|
|
||||||
chunks?: string[]
|
|
||||||
/**
|
|
||||||
* more css-loader options see https://webpack.js.org/loaders/css-loader/#options
|
|
||||||
*/
|
|
||||||
cssLoader?: {
|
|
||||||
url?: (boolean | (() => any))
|
|
||||||
import?: (boolean | (() => any))
|
|
||||||
modules?: (boolean | string | {
|
|
||||||
|
|
||||||
})
|
|
||||||
sourceMap?: boolean
|
|
||||||
importLoaders?: number
|
|
||||||
onlyLocals?: boolean
|
|
||||||
esModule?: boolean
|
|
||||||
localsConvention?: ("asIs" | "camelCase" | "camelCaseOnly" | "dashes" | "dashesOnly")
|
|
||||||
}
|
|
||||||
cssModulesTypescriptLoader?: {
|
|
||||||
mode?: ("emit" | "verify")
|
|
||||||
}
|
|
||||||
cssnano?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
copy?: any[]
|
|
||||||
define?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
devScripts?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* devServer configs
|
|
||||||
*/
|
|
||||||
devServer?: {
|
|
||||||
/**
|
|
||||||
* devServer port, default 8000
|
|
||||||
*/
|
|
||||||
port?: number
|
|
||||||
host?: string
|
|
||||||
https?: ({
|
|
||||||
key?: string
|
|
||||||
cert?: string
|
|
||||||
[k: string]: any
|
|
||||||
} | boolean)
|
|
||||||
headers?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
writeToDisk?: (boolean | (() => any))
|
|
||||||
[k: string]: any
|
|
||||||
}
|
|
||||||
devtool?: string
|
|
||||||
/**
|
|
||||||
* Code splitting for performance optimization
|
|
||||||
*/
|
|
||||||
dynamicImport?: {
|
|
||||||
/**
|
|
||||||
* loading the component before loaded
|
|
||||||
*/
|
|
||||||
loading?: string
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Code splitting for import statement syntax
|
|
||||||
*/
|
|
||||||
dynamicImportSyntax?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
exportStatic?: {
|
|
||||||
htmlSuffix?: boolean
|
|
||||||
dynamicRoot?: boolean
|
|
||||||
supportWin?: boolean
|
|
||||||
/**
|
|
||||||
* extra render paths only enable in ssr
|
|
||||||
*/
|
|
||||||
extraRoutePaths?: (() => any)
|
|
||||||
}
|
|
||||||
externals?: ({
|
|
||||||
|
|
||||||
} | string | (() => any))
|
|
||||||
extraBabelIncludes?: any[]
|
|
||||||
extraBabelPlugins?: any[]
|
|
||||||
extraBabelPresets?: any[]
|
|
||||||
extraPostCSSPlugins?: any[]
|
|
||||||
/**
|
|
||||||
* fork-ts-checker-webpack-plugin options see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#options
|
|
||||||
*/
|
|
||||||
forkTSChecker?: {
|
|
||||||
async?: boolean
|
|
||||||
typescript?: (boolean | {
|
|
||||||
|
|
||||||
})
|
|
||||||
eslint?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
issue?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
formatter?: (string | {
|
|
||||||
|
|
||||||
})
|
|
||||||
logger?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
[k: string]: any
|
|
||||||
}
|
|
||||||
fastRefresh?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
hash?: boolean
|
|
||||||
ignoreMomentLocale?: boolean
|
|
||||||
inlineLimit?: number
|
|
||||||
lessLoader?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
manifest?: {
|
|
||||||
fileName?: string
|
|
||||||
publicPath?: ""
|
|
||||||
basePath?: string
|
|
||||||
writeToFileEmit?: boolean
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* open mfsu feature
|
|
||||||
*/
|
|
||||||
mfsu?: {
|
|
||||||
development?: {
|
|
||||||
output?: string
|
|
||||||
}
|
|
||||||
production?: {
|
|
||||||
output?: string
|
|
||||||
}
|
|
||||||
mfName?: string
|
|
||||||
exportAllMembers?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
chunks?: string[]
|
|
||||||
ignoreNodeBuiltInModules?: boolean
|
|
||||||
}
|
|
||||||
mountElementId?: ""
|
|
||||||
mpa?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
nodeModulesTransform?: {
|
|
||||||
type?: ("all" | "none")
|
|
||||||
exclude?: string[]
|
|
||||||
}
|
|
||||||
outputPath?: ""
|
|
||||||
plugins?: string[]
|
|
||||||
postcssLoader?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
presets?: string[]
|
|
||||||
proxy?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
publicPath?: string
|
|
||||||
runtimePublicPath?: boolean
|
|
||||||
ssr?: {
|
|
||||||
/**
|
|
||||||
* force execing Page getInitialProps functions
|
|
||||||
*/
|
|
||||||
forceInitial?: boolean
|
|
||||||
/**
|
|
||||||
* remove window.g_initialProps in html
|
|
||||||
*/
|
|
||||||
removeWindowInitialProps?: boolean
|
|
||||||
/**
|
|
||||||
* disable serve-side render in umi dev mode.
|
|
||||||
*/
|
|
||||||
devServerRender?: boolean
|
|
||||||
mode?: ("stream" | "string")
|
|
||||||
/**
|
|
||||||
* static markup in static site
|
|
||||||
*/
|
|
||||||
staticMarkup?: boolean
|
|
||||||
}
|
|
||||||
singular?: boolean
|
|
||||||
styleLoader?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
targets?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
terserOptions?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
theme?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
runtimeHistory?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
webpack5?: {
|
|
||||||
lazyCompilation?: {
|
|
||||||
entries?: boolean
|
|
||||||
imports?: boolean
|
|
||||||
test?: any
|
|
||||||
}
|
|
||||||
}
|
|
||||||
workerLoader?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
favicon?: string
|
|
||||||
headScripts?: any[]
|
|
||||||
links?: any[]
|
|
||||||
metas?: any[]
|
|
||||||
scripts?: any[]
|
|
||||||
styles?: any[]
|
|
||||||
title?: string
|
|
||||||
mock?: {
|
|
||||||
exclude?: string[]
|
|
||||||
}
|
|
||||||
antd?: {
|
|
||||||
dark?: boolean
|
|
||||||
compact?: boolean
|
|
||||||
mobile?: boolean
|
|
||||||
disableBabelPluginImport?: boolean
|
|
||||||
config?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dva?: {
|
|
||||||
disableModelsReExport?: boolean
|
|
||||||
/**
|
|
||||||
* lazy load dva model avoiding the import modules from umi undefined
|
|
||||||
*/
|
|
||||||
lazyLoad?: boolean
|
|
||||||
extraModels?: string[]
|
|
||||||
hmr?: boolean
|
|
||||||
immer?: (boolean | {
|
|
||||||
|
|
||||||
})
|
|
||||||
skipModelValidate?: boolean
|
|
||||||
}
|
|
||||||
locale?: {
|
|
||||||
default?: string
|
|
||||||
useLocalStorage?: boolean
|
|
||||||
baseNavigator?: boolean
|
|
||||||
title?: boolean
|
|
||||||
antd?: boolean
|
|
||||||
baseSeparator?: string
|
|
||||||
}
|
|
||||||
layout?: {
|
|
||||||
|
|
||||||
}
|
|
||||||
request?: {
|
|
||||||
dataField?: ""
|
|
||||||
}
|
|
||||||
[k: string]: any
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import { plugin } from './plugin';
|
|
||||||
import * as Plugin_0 from '../../app.ts';
|
|
||||||
import * as Plugin_1 from '../plugin-initial-state/runtime';
|
|
||||||
import * as Plugin_2 from '../plugin-model/runtime';
|
|
||||||
|
|
||||||
plugin.register({
|
|
||||||
apply: Plugin_0,
|
|
||||||
path: '../../app.ts',
|
|
||||||
});
|
|
||||||
plugin.register({
|
|
||||||
apply: Plugin_1,
|
|
||||||
path: '../plugin-initial-state/runtime',
|
|
||||||
});
|
|
||||||
plugin.register({
|
|
||||||
apply: Plugin_2,
|
|
||||||
path: '../plugin-model/runtime',
|
|
||||||
});
|
|
||||||
|
|
||||||
export const __mfsu = 1;
|
|
|
@ -1,4 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import 'core-js';
|
|
||||||
import 'regenerator-runtime/runtime';
|
|
||||||
export {};
|
|
|
@ -1,58 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import React from 'react';
|
|
||||||
import { ApplyPluginsType } from '/root/ob-repository-synchronize/web/node_modules/umi/node_modules/@umijs/runtime';
|
|
||||||
import * as umiExports from './umiExports';
|
|
||||||
import { plugin } from './plugin';
|
|
||||||
|
|
||||||
export function getRoutes() {
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
"path": "/",
|
|
||||||
"component": require('@/layouts/index').default,
|
|
||||||
"routes": [
|
|
||||||
{
|
|
||||||
"path": "/",
|
|
||||||
"redirect": "/obrobot/project",
|
|
||||||
"exact": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "同步工程管理",
|
|
||||||
"path": "/obrobot/project",
|
|
||||||
"component": require('@/pages/project/index').default,
|
|
||||||
"exact": true,
|
|
||||||
"icon": "project"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "同步流",
|
|
||||||
"path": "/obrobot/project/process",
|
|
||||||
"component": require('@/pages/process/index').default,
|
|
||||||
"exact": true,
|
|
||||||
"hideInMenu": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Pull Request",
|
|
||||||
"path": "/obrobot/project/pull_request",
|
|
||||||
"component": require('@/pages/pullRequest/index').default,
|
|
||||||
"exact": true,
|
|
||||||
"hideInMenu": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Github 关联账号管理",
|
|
||||||
"path": "/obrobot/account",
|
|
||||||
"component": require('@/pages/account/index').default,
|
|
||||||
"exact": true,
|
|
||||||
"icon": "account"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
// allow user to extend routes
|
|
||||||
plugin.applyPlugins({
|
|
||||||
key: 'patchRoutes',
|
|
||||||
type: ApplyPluginsType.event,
|
|
||||||
args: { routes },
|
|
||||||
});
|
|
||||||
|
|
||||||
return routes;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
export { history } from './history';
|
|
||||||
export { plugin } from './plugin';
|
|
||||||
export * from '../plugin-initial-state/exports';
|
|
||||||
export * from '../plugin-model/useModel';
|
|
||||||
export * from '../plugin-request/request';
|
|
||||||
export * from '../plugin-helmet/exports';
|
|
|
@ -1,3 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
// @ts-ignore
|
|
||||||
export { Helmet } from '/root/ob-repository-synchronize/web/node_modules/react-helmet';
|
|
|
@ -1,37 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
|
|
||||||
import React, { useRef, useEffect } from "react";
|
|
||||||
import { plugin } from "../core/umiExports";
|
|
||||||
import { ApplyPluginsType } from 'umi';
|
|
||||||
import { useModel } from "../plugin-model/useModel";
|
|
||||||
if (typeof useModel !== "function") {
|
|
||||||
throw new Error(
|
|
||||||
"[plugin-initial-state]: useModel is not a function, @umijs/plugin-model is required."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}
|
|
||||||
export default (props: Props) => {
|
|
||||||
const { children } = props;
|
|
||||||
const appLoaded = useRef(false);
|
|
||||||
// 获取用户的配置,暂时只支持 loading
|
|
||||||
const useRuntimeConfig =
|
|
||||||
plugin.applyPlugins({
|
|
||||||
key: "initialStateConfig",
|
|
||||||
type: ApplyPluginsType.modify,
|
|
||||||
initialValue: {},
|
|
||||||
}) || {};
|
|
||||||
const { loading = false } = useModel("@@initialState") || {};
|
|
||||||
useEffect(() => {
|
|
||||||
if (!loading) {
|
|
||||||
appLoaded.current = true;
|
|
||||||
}
|
|
||||||
}, [loading]);
|
|
||||||
// initial state loading 时,阻塞渲染
|
|
||||||
if (loading && !appLoaded.current) {
|
|
||||||
return useRuntimeConfig.loading || null;
|
|
||||||
}
|
|
||||||
return children;
|
|
||||||
};
|
|
|
@ -1,7 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
import { InitialState as InitialStateType } from '../plugin-initial-state/models/initialState';
|
|
||||||
|
|
||||||
export type InitialState = InitialStateType;
|
|
||||||
export const __PLUGIN_INITIAL_STATE = 1;
|
|
|
@ -1,2 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
export default () => ({ loading: false, refresh: () => {} })
|
|
|
@ -1,13 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import React from 'react';
|
|
||||||
import Provider from './Provider';
|
|
||||||
|
|
||||||
export function rootContainer(container: React.ReactNode) {
|
|
||||||
return React.createElement(
|
|
||||||
// 这里的 plugin-initial-state 不能从 constant 里取,里面有 path 依赖
|
|
||||||
// 但 webpack-5 没有 node 补丁(包括 path)
|
|
||||||
Provider,
|
|
||||||
null,
|
|
||||||
container,
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import React from 'react';
|
|
||||||
import initialState from '/root/ob-repository-synchronize/web/src/.umi/plugin-initial-state/models/initialState';
|
|
||||||
import model0 from "/root/ob-repository-synchronize/web/src/models/global";
|
|
||||||
// @ts-ignore
|
|
||||||
import Dispatcher from './helpers/dispatcher';
|
|
||||||
// @ts-ignore
|
|
||||||
import Executor from './helpers/executor';
|
|
||||||
// @ts-ignore
|
|
||||||
import { UmiContext } from './helpers/constant';
|
|
||||||
|
|
||||||
export const models = { '@@initialState': initialState, 'global': model0 };
|
|
||||||
|
|
||||||
export type Model<T extends keyof typeof models> = {
|
|
||||||
[key in keyof typeof models]: ReturnType<typeof models[T]>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Models<T extends keyof typeof models> = Model<T>[T]
|
|
||||||
|
|
||||||
const dispatcher = new Dispatcher!();
|
|
||||||
const Exe = Executor!;
|
|
||||||
|
|
||||||
export default ({ children }: { children: React.ReactNode }) => {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<UmiContext.Provider value={dispatcher}>
|
|
||||||
{
|
|
||||||
Object.entries(models).map(pair => (
|
|
||||||
<Exe key={pair[0]} namespace={pair[0]} hook={pair[1] as any} onUpdate={(val: any) => {
|
|
||||||
const [ns] = pair as [keyof typeof models, any];
|
|
||||||
dispatcher.data[ns] = val;
|
|
||||||
dispatcher.update(ns);
|
|
||||||
}} />
|
|
||||||
))
|
|
||||||
}
|
|
||||||
{children}
|
|
||||||
</UmiContext.Provider>
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
export const UmiContext = React.createContext({});
|
|
|
@ -1,19 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
export default class Dispatcher {
|
|
||||||
callbacks = {};
|
|
||||||
|
|
||||||
data = {};
|
|
||||||
|
|
||||||
update = (namespace: string) => {
|
|
||||||
(this.callbacks[namespace] || []).forEach(
|
|
||||||
(callback: (val: any) => void) => {
|
|
||||||
try {
|
|
||||||
const data = this.data[namespace];
|
|
||||||
callback(data);
|
|
||||||
} catch (e) {
|
|
||||||
callback(undefined);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import React, { useEffect, useRef, useMemo } from 'react';
|
|
||||||
|
|
||||||
interface ExecutorProps {
|
|
||||||
hook: () => any;
|
|
||||||
onUpdate: (val: any) => void;
|
|
||||||
namespace: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default (props: ExecutorProps) => {
|
|
||||||
const { hook, onUpdate, namespace } = props;
|
|
||||||
|
|
||||||
const updateRef = useRef(onUpdate);
|
|
||||||
updateRef.current = onUpdate;
|
|
||||||
const initialLoad = useRef(false);
|
|
||||||
|
|
||||||
let data: any;
|
|
||||||
try {
|
|
||||||
data = hook();
|
|
||||||
if (
|
|
||||||
process.env.NODE_ENV === 'development' &&
|
|
||||||
typeof document !== 'undefined'
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
let count = Object.keys(
|
|
||||||
((window as any)._umi_useModel_dev_tool_log || {})[namespace] || {},
|
|
||||||
).length;
|
|
||||||
(window as any)._umi_useModel_dev_tool = Object.assign(
|
|
||||||
(window as any)._umi_useModel_dev_tool || {},
|
|
||||||
{
|
|
||||||
[namespace]: data,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
(window as any)._umi_useModel_dev_tool_log = Object.assign(
|
|
||||||
(window as any)._umi_useModel_dev_tool_log || {},
|
|
||||||
{
|
|
||||||
[namespace]: Object.assign(
|
|
||||||
((window as any)._umi_useModel_dev_tool_log || {})[namespace] ||
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
[count]: data,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
window.dispatchEvent(
|
|
||||||
new CustomEvent('_umi_useModel_update', {
|
|
||||||
detail: {
|
|
||||||
namespace,
|
|
||||||
time: Date.now(),
|
|
||||||
data,
|
|
||||||
index: count,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
// dev tool 记录失败、可能是低版本浏览器,忽略
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(
|
|
||||||
`plugin-model: Invoking '${namespace || 'unknown'}' model failed:`,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 首次执行时立刻返回初始值
|
|
||||||
useMemo(() => {
|
|
||||||
updateRef.current(data);
|
|
||||||
initialLoad.current = false;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// React 16.13 后 update 函数用 useEffect 包裹
|
|
||||||
useEffect(() => {
|
|
||||||
if (initialLoad.current) {
|
|
||||||
updateRef.current(data);
|
|
||||||
} else {
|
|
||||||
initialLoad.current = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return <></>;
|
|
||||||
};
|
|
|
@ -1,12 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
/* eslint-disable import/no-dynamic-require */
|
|
||||||
import React from 'react';
|
|
||||||
import Provider from './Provider';
|
|
||||||
|
|
||||||
export function rootContainer(container: React.ReactNode) {
|
|
||||||
return React.createElement(
|
|
||||||
Provider,
|
|
||||||
null,
|
|
||||||
container,
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import { useState, useEffect, useContext, useRef } from 'react';
|
|
||||||
// @ts-ignore
|
|
||||||
import isEqual from '/root/ob-repository-synchronize/web/node_modules/@umijs/plugin-model/node_modules/fast-deep-equal/index.js';
|
|
||||||
// @ts-ignore
|
|
||||||
import { UmiContext } from './helpers/constant';
|
|
||||||
import { Model, models } from './Provider';
|
|
||||||
|
|
||||||
export type Models<T extends keyof typeof models> = Model<T>[T]
|
|
||||||
|
|
||||||
export function useModel<T extends keyof Model<T>>(model: T): Model<T>[T]
|
|
||||||
export function useModel<T extends keyof Model<T>, U>(model: T, selector: (model: Model<T>[T]) => U): U
|
|
||||||
|
|
||||||
export function useModel<T extends keyof Model<T>, U>(
|
|
||||||
namespace: T,
|
|
||||||
updater?: (model: Model<T>[T]) => U
|
|
||||||
) : typeof updater extends undefined ? Model<T>[T] : ReturnType<NonNullable<typeof updater>>{
|
|
||||||
|
|
||||||
type RetState = typeof updater extends undefined ? Model<T>[T] : ReturnType<NonNullable<typeof updater>>
|
|
||||||
const dispatcher = useContext<any>(UmiContext);
|
|
||||||
const updaterRef = useRef(updater);
|
|
||||||
updaterRef.current = updater;
|
|
||||||
const [state, setState] = useState<RetState>(
|
|
||||||
() => updaterRef.current ? updaterRef.current(dispatcher.data![namespace]) : dispatcher.data![namespace]
|
|
||||||
);
|
|
||||||
const stateRef = useRef<any>(state);
|
|
||||||
stateRef.current = state;
|
|
||||||
|
|
||||||
const isMount = useRef(false);
|
|
||||||
useEffect(() => {
|
|
||||||
isMount.current = true;
|
|
||||||
return () => {
|
|
||||||
isMount.current = false;
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handler = (e: any) => {
|
|
||||||
if(!isMount.current) {
|
|
||||||
// 如果 handler 执行过程中,组件被卸载了,则强制更新全局 data
|
|
||||||
setTimeout(() => {
|
|
||||||
dispatcher.data![namespace] = e;
|
|
||||||
dispatcher.update(namespace);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if(updater && updaterRef.current){
|
|
||||||
const currentState = updaterRef.current(e);
|
|
||||||
const previousState = stateRef.current
|
|
||||||
if(!isEqual(currentState, previousState)){
|
|
||||||
setState(currentState);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setState(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
dispatcher.callbacks![namespace]!.add(handler);
|
|
||||||
dispatcher.update(namespace);
|
|
||||||
} catch (e) {
|
|
||||||
dispatcher.callbacks![namespace] = new Set();
|
|
||||||
dispatcher.callbacks![namespace]!.add(handler);
|
|
||||||
dispatcher.update(namespace);
|
|
||||||
}
|
|
||||||
return () => {
|
|
||||||
dispatcher.callbacks![namespace]!.delete(handler);
|
|
||||||
}
|
|
||||||
}, [namespace]);
|
|
||||||
|
|
||||||
return state;
|
|
||||||
};
|
|
|
@ -1,278 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
/**
|
|
||||||
* Base on https://github.com/umijs//root/ob-repository-synchronize/web/node_modules/umi-request
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
extend,
|
|
||||||
Context,
|
|
||||||
RequestOptionsInit,
|
|
||||||
OnionMiddleware,
|
|
||||||
RequestOptionsWithoutResponse,
|
|
||||||
RequestMethod,
|
|
||||||
RequestOptionsWithResponse,
|
|
||||||
RequestResponse,
|
|
||||||
RequestInterceptor,
|
|
||||||
ResponseInterceptor,
|
|
||||||
} from '/root/ob-repository-synchronize/web/node_modules/umi-request';
|
|
||||||
// @ts-ignore
|
|
||||||
|
|
||||||
import { ApplyPluginsType } from 'umi';
|
|
||||||
import { history, plugin } from '../core/umiExports';
|
|
||||||
|
|
||||||
// decoupling with antd UI library, you can using `alias` modify the ui methods
|
|
||||||
// @ts-ignore
|
|
||||||
import { message, notification } from '@umijs/plugin-request/lib/ui';
|
|
||||||
import useUmiRequest, { UseRequestProvider } from '/root/ob-repository-synchronize/web/node_modules/@ahooksjs/use-request';
|
|
||||||
import {
|
|
||||||
BaseOptions,
|
|
||||||
BasePaginatedOptions,
|
|
||||||
BaseResult,
|
|
||||||
CombineService,
|
|
||||||
LoadMoreFormatReturn,
|
|
||||||
LoadMoreOptions,
|
|
||||||
LoadMoreOptionsWithFormat,
|
|
||||||
LoadMoreParams,
|
|
||||||
LoadMoreResult,
|
|
||||||
OptionsWithFormat,
|
|
||||||
PaginatedFormatReturn,
|
|
||||||
PaginatedOptionsWithFormat,
|
|
||||||
PaginatedParams,
|
|
||||||
PaginatedResult,
|
|
||||||
} from '/root/ob-repository-synchronize/web/node_modules/@ahooksjs/use-request/lib/types';
|
|
||||||
|
|
||||||
type ResultWithData<T = any> = { data?: T; [key: string]: any };
|
|
||||||
|
|
||||||
function useRequest<
|
|
||||||
R = any,
|
|
||||||
P extends any[] = any,
|
|
||||||
U = any,
|
|
||||||
UU extends U = any,
|
|
||||||
>(
|
|
||||||
service: CombineService<R, P>,
|
|
||||||
options: OptionsWithFormat<R, P, U, UU>,
|
|
||||||
): BaseResult<U, P>;
|
|
||||||
function useRequest<R extends ResultWithData = any, P extends any[] = any>(
|
|
||||||
service: CombineService<R, P>,
|
|
||||||
options?: BaseOptions<R['data'], P>,
|
|
||||||
): BaseResult<R['data'], P>;
|
|
||||||
function useRequest<R extends LoadMoreFormatReturn = any, RR = any>(
|
|
||||||
service: CombineService<RR, LoadMoreParams<R>>,
|
|
||||||
options: LoadMoreOptionsWithFormat<R, RR>,
|
|
||||||
): LoadMoreResult<R>;
|
|
||||||
function useRequest<
|
|
||||||
R extends ResultWithData<LoadMoreFormatReturn | any> = any,
|
|
||||||
RR extends R = any,
|
|
||||||
>(
|
|
||||||
service: CombineService<R, LoadMoreParams<R['data']>>,
|
|
||||||
options: LoadMoreOptions<RR['data']>,
|
|
||||||
): LoadMoreResult<R['data']>;
|
|
||||||
|
|
||||||
function useRequest<R = any, Item = any, U extends Item = any>(
|
|
||||||
service: CombineService<R, PaginatedParams>,
|
|
||||||
options: PaginatedOptionsWithFormat<R, Item, U>,
|
|
||||||
): PaginatedResult<Item>;
|
|
||||||
function useRequest<Item = any, U extends Item = any>(
|
|
||||||
service: CombineService<
|
|
||||||
ResultWithData<PaginatedFormatReturn<Item>>,
|
|
||||||
PaginatedParams
|
|
||||||
>,
|
|
||||||
options: BasePaginatedOptions<U>,
|
|
||||||
): PaginatedResult<Item>;
|
|
||||||
function useRequest(service: any, options: any = {}) {
|
|
||||||
return useUmiRequest(service, {
|
|
||||||
formatResult: result => result?.data,
|
|
||||||
requestMethod: (requestOptions: any) => {
|
|
||||||
if (typeof requestOptions === 'string') {
|
|
||||||
return request(requestOptions);
|
|
||||||
}
|
|
||||||
if (typeof requestOptions === 'object') {
|
|
||||||
const { url, ...rest } = requestOptions;
|
|
||||||
return request(url, rest);
|
|
||||||
}
|
|
||||||
throw new Error('request options error');
|
|
||||||
},
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RequestConfig extends RequestOptionsInit {
|
|
||||||
errorConfig?: {
|
|
||||||
errorPage?: string;
|
|
||||||
adaptor?: (resData: any, ctx: Context) => ErrorInfoStructure;
|
|
||||||
};
|
|
||||||
middlewares?: OnionMiddleware[];
|
|
||||||
requestInterceptors?: RequestInterceptor[];
|
|
||||||
responseInterceptors?: ResponseInterceptor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ErrorShowType {
|
|
||||||
SILENT = 0,
|
|
||||||
WARN_MESSAGE = 1,
|
|
||||||
ERROR_MESSAGE = 2,
|
|
||||||
NOTIFICATION = 4,
|
|
||||||
REDIRECT = 9,
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ErrorInfoStructure {
|
|
||||||
success: boolean;
|
|
||||||
data?: any;
|
|
||||||
errorCode?: string;
|
|
||||||
errorMessage?: string;
|
|
||||||
showType?: ErrorShowType;
|
|
||||||
traceId?: string;
|
|
||||||
host?: string;
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RequestError extends Error {
|
|
||||||
data?: any;
|
|
||||||
info?: ErrorInfoStructure;
|
|
||||||
request?: Context['req'];
|
|
||||||
response?: Context['res'];
|
|
||||||
}
|
|
||||||
|
|
||||||
const DEFAULT_ERROR_PAGE = '/exception';
|
|
||||||
|
|
||||||
let requestMethodInstance: RequestMethod;
|
|
||||||
const getRequestMethod = () => {
|
|
||||||
if (requestMethodInstance) {
|
|
||||||
// request method 已经示例化
|
|
||||||
return requestMethodInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// runtime 配置可能应为依赖顺序的问题在模块初始化的时候无法获取,所以需要封装一层在异步调用后初始化相关方法
|
|
||||||
// 当用户的 app.ts 中依赖了该文件的情况下就该模块的初始化时间就会被提前,无法获取到运行时配置
|
|
||||||
const requestConfig: RequestConfig = plugin.applyPlugins({
|
|
||||||
key: 'request',
|
|
||||||
type: ApplyPluginsType.modify,
|
|
||||||
initialValue: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
const errorAdaptor =
|
|
||||||
requestConfig.errorConfig?.adaptor || ((resData) => resData);
|
|
||||||
|
|
||||||
requestMethodInstance = extend({
|
|
||||||
errorHandler: (error: RequestError) => {
|
|
||||||
// @ts-ignore
|
|
||||||
if (error?.request?.options?.skipErrorHandler) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
let errorInfo: ErrorInfoStructure | undefined;
|
|
||||||
if (error.name === 'ResponseError' && error.data && error.request) {
|
|
||||||
const ctx: Context = {
|
|
||||||
req: error.request,
|
|
||||||
res: error.response,
|
|
||||||
};
|
|
||||||
errorInfo = errorAdaptor(error.data, ctx);
|
|
||||||
error.message = errorInfo?.errorMessage || error.message;
|
|
||||||
error.data = error.data;
|
|
||||||
error.info = errorInfo;
|
|
||||||
}
|
|
||||||
errorInfo = error.info;
|
|
||||||
|
|
||||||
if (errorInfo) {
|
|
||||||
const errorMessage = errorInfo?.errorMessage;
|
|
||||||
const errorCode = errorInfo?.errorCode;
|
|
||||||
const errorPage =
|
|
||||||
requestConfig.errorConfig?.errorPage || DEFAULT_ERROR_PAGE;
|
|
||||||
|
|
||||||
switch (errorInfo?.showType) {
|
|
||||||
case ErrorShowType.SILENT:
|
|
||||||
// do nothing
|
|
||||||
break;
|
|
||||||
case ErrorShowType.WARN_MESSAGE:
|
|
||||||
message.warn(errorMessage);
|
|
||||||
break;
|
|
||||||
case ErrorShowType.ERROR_MESSAGE:
|
|
||||||
message.error(errorMessage);
|
|
||||||
break;
|
|
||||||
case ErrorShowType.NOTIFICATION:
|
|
||||||
notification.open({
|
|
||||||
description: errorMessage,
|
|
||||||
message: errorCode,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case ErrorShowType.REDIRECT:
|
|
||||||
// @ts-ignore
|
|
||||||
history.push({
|
|
||||||
pathname: errorPage,
|
|
||||||
query: { errorCode, errorMessage },
|
|
||||||
});
|
|
||||||
// redirect to error page
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message.error(errorMessage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
message.error(error.message || 'Request error, please retry.');
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
},
|
|
||||||
...requestConfig,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 中间件统一错误处理
|
|
||||||
// 后端返回格式 { success: boolean, data: any }
|
|
||||||
// 按照项目具体情况修改该部分逻辑
|
|
||||||
requestMethodInstance.use(async (ctx, next) => {
|
|
||||||
await next();
|
|
||||||
const { req, res } = ctx;
|
|
||||||
// @ts-ignore
|
|
||||||
if (req.options?.skipErrorHandler) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const { options } = req;
|
|
||||||
const { getResponse } = options;
|
|
||||||
const resData = getResponse ? res.data : res;
|
|
||||||
const errorInfo = errorAdaptor(resData, ctx);
|
|
||||||
if (errorInfo.success === false) {
|
|
||||||
// 抛出错误到 errorHandler 中处理
|
|
||||||
const error: RequestError = new Error(errorInfo.errorMessage);
|
|
||||||
error.name = 'BizError';
|
|
||||||
error.data = resData;
|
|
||||||
error.info = errorInfo;
|
|
||||||
error.response = res;
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add user custom middlewares
|
|
||||||
const customMiddlewares = requestConfig.middlewares || [];
|
|
||||||
customMiddlewares.forEach((mw) => {
|
|
||||||
requestMethodInstance.use(mw);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add user custom interceptors
|
|
||||||
const requestInterceptors = requestConfig.requestInterceptors || [];
|
|
||||||
const responseInterceptors = requestConfig.responseInterceptors || [];
|
|
||||||
requestInterceptors.map((ri) => {
|
|
||||||
requestMethodInstance.interceptors.request.use(ri);
|
|
||||||
});
|
|
||||||
responseInterceptors.map((ri) => {
|
|
||||||
requestMethodInstance.interceptors.response.use(ri);
|
|
||||||
});
|
|
||||||
|
|
||||||
return requestMethodInstance;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface RequestMethodInUmi<R = false> {
|
|
||||||
<T = any>(
|
|
||||||
url: string,
|
|
||||||
options: RequestOptionsWithResponse & { skipErrorHandler?: boolean },
|
|
||||||
): Promise<RequestResponse<T>>;
|
|
||||||
<T = any>(
|
|
||||||
url: string,
|
|
||||||
options: RequestOptionsWithoutResponse & { skipErrorHandler?: boolean },
|
|
||||||
): Promise<T>;
|
|
||||||
<T = any>(
|
|
||||||
url: string,
|
|
||||||
options?: RequestOptionsInit & { skipErrorHandler?: boolean },
|
|
||||||
): R extends true ? Promise<RequestResponse<T>> : Promise<T>;
|
|
||||||
}
|
|
||||||
const request: RequestMethodInUmi = (url: any, options: any) => {
|
|
||||||
const requestMethod = getRequestMethod();
|
|
||||||
return requestMethod(url, options);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { request, useRequest, UseRequestProvider };
|
|
|
@ -1,58 +0,0 @@
|
||||||
// @ts-nocheck
|
|
||||||
import './core/polyfill';
|
|
||||||
|
|
||||||
import { plugin } from './core/plugin';
|
|
||||||
import './core/pluginRegister';
|
|
||||||
import { createHistory } from './core/history';
|
|
||||||
import { ApplyPluginsType } from '/root/ob-repository-synchronize/web/node_modules/umi/node_modules/@umijs/runtime';
|
|
||||||
import { renderClient } from '/root/ob-repository-synchronize/web/node_modules/@umijs/renderer-react/dist/index.js';
|
|
||||||
import { getRoutes } from './core/routes';
|
|
||||||
|
|
||||||
|
|
||||||
import '../global.less';
|
|
||||||
|
|
||||||
const getClientRender = (args: { hot?: boolean; routes?: any[] } = {}) => plugin.applyPlugins({
|
|
||||||
key: 'render',
|
|
||||||
type: ApplyPluginsType.compose,
|
|
||||||
initialValue: () => {
|
|
||||||
const opts = plugin.applyPlugins({
|
|
||||||
key: 'modifyClientRenderOpts',
|
|
||||||
type: ApplyPluginsType.modify,
|
|
||||||
initialValue: {
|
|
||||||
routes: args.routes || getRoutes(),
|
|
||||||
plugin,
|
|
||||||
history: createHistory(args.hot),
|
|
||||||
isServer: process.env.__IS_SERVER,
|
|
||||||
rootElement: 'root',
|
|
||||||
defaultTitle: ``,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return renderClient(opts);
|
|
||||||
},
|
|
||||||
args,
|
|
||||||
});
|
|
||||||
|
|
||||||
const clientRender = getClientRender();
|
|
||||||
export default clientRender();
|
|
||||||
|
|
||||||
|
|
||||||
window.g_umi = {
|
|
||||||
version: '3.5.26',
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// hot module replacement
|
|
||||||
// @ts-ignore
|
|
||||||
if (module.hot) {
|
|
||||||
// @ts-ignore
|
|
||||||
module.hot.accept('./core/routes', () => {
|
|
||||||
const ret = require('./core/routes');
|
|
||||||
if (ret.then) {
|
|
||||||
ret.then(({ getRoutes }) => {
|
|
||||||
getClientRender({ hot: true, routes: getRoutes() })();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
getClientRender({ hot: true, routes: ret.getRoutes() })();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in New Issue