Compare commits

1 Commits

Author SHA1 Message Date
eric
7dfc26e8c1 feat: 新增页面 2022-12-15 14:58:35 +08:00
48 changed files with 18249 additions and 0 deletions

View File

@@ -48,6 +48,12 @@ export default [
icon: 'table',
path: '/list',
component: './TableList',
},
{
name: 'list.table-list',
icon: 'table',
path: '/cityNew',
component: './cityNew',
},
{
path: '/',

View File

@@ -0,0 +1,9 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import { Outlet, useOutletContext } from 'umi';
export default function EmptyRoute() {
const context = useOutletContext();
return <Outlet context={context} />;
}

View File

@@ -0,0 +1,19 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import type { IRuntimeConfig as Plugin0 } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-initialState/runtimeConfig.d'
import type { IRuntimeConfig as Plugin1 } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-layout/runtimeConfig.d'
import type { IRuntimeConfig as Plugin2 } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-request/runtimeConfig.d'
interface IDefaultRuntimeConfig {
onRouteChange?: (props: { routes: any, clientRoutes: any, location: any, action:any }) => void;
patchRoutes?: (props: { routes: any }) => void;
patchClientRoutes?: (props: { routes: any }) => void;
render?: (oldRender: () => void) => void;
rootContainer?: (lastRootContainer: JSX.Element, args?: any) => void;
[key: string]: any;
}
export type RuntimeConfig = IDefaultRuntimeConfig & Plugin0 & Plugin1 & Plugin2
export function defineApp(config: RuntimeConfig): RuntimeConfig {
return config;
}

61
src/.umi/core/history.ts Normal file
View File

@@ -0,0 +1,61 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import { createHashHistory, createMemoryHistory, createBrowserHistory, History } from '/Users/eric/Desktop/city-admin/node_modules/@umijs/preset-umi/node_modules/@umijs/renderer-react';
let history: History;
let basename: string = '/';
export function createHistory(opts: any) {
let h;
if (opts.type === 'hash') {
h = createHashHistory();
} else if (opts.type === 'memory') {
h = createMemoryHistory(opts);
} else {
h = createBrowserHistory();
}
if (opts.basename) {
basename = opts.basename;
}
history = {
...h,
push(to, state) {
h.push(patchTo(to), state);
},
replace(to, state) {
h.replace(patchTo(to), state);
},
get location() {
return h.location;
},
get action() {
return h.action;
}
}
return h;
}
// Patch `to` to support basename
// Refs:
// https://github.com/remix-run/history/blob/3e9dab4/packages/history/index.ts#L484
// https://github.com/remix-run/history/blob/dev/docs/api-reference.md#to
function patchTo(to: any) {
if (typeof to === 'string') {
return `${stripLastSlash(basename)}${to}`;
} else if (typeof to === 'object' && to.pathname) {
return {
...to,
pathname: `${stripLastSlash(basename)}${to.pathname}`,
};
} else {
throw new Error(`Unexpected to: ${to}`);
}
}
function stripLastSlash(path) {
return path.slice(-1) === '/' ? path.slice(0, -1) : path;
}
export { history };

62
src/.umi/core/plugin.ts Normal file
View File

@@ -0,0 +1,62 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import * as Plugin_0 from '/Users/eric/Desktop/city-admin/src/app.tsx';
import * as Plugin_1 from '/Users/eric/Desktop/city-admin/src/.umi/plugin-access/runtime.tsx';
import * as Plugin_2 from '/Users/eric/Desktop/city-admin/src/.umi/plugin-initialState/runtime.tsx';
import * as Plugin_3 from '/Users/eric/Desktop/city-admin/src/.umi/plugin-layout/runtime.tsx';
import * as Plugin_4 from '/Users/eric/Desktop/city-admin/src/.umi/plugin-locale/runtime.tsx';
import * as Plugin_5 from '/Users/eric/Desktop/city-admin/src/.umi/plugin-model/runtime.tsx';
import { PluginManager } from 'umi';
function __defaultExport (obj) {
if (obj.default) {
return typeof obj.default === 'function' ? obj.default() : obj.default
}
return obj;
}
export function getPlugins() {
return [
{
apply: __defaultExport(Plugin_0),
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/eric/Desktop/city-admin/src/app.tsx',
},
{
apply: Plugin_1,
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/eric/Desktop/city-admin/src/.umi/plugin-access/runtime.tsx',
},
{
apply: Plugin_2,
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/eric/Desktop/city-admin/src/.umi/plugin-initialState/runtime.tsx',
},
{
apply: Plugin_3,
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/eric/Desktop/city-admin/src/.umi/plugin-layout/runtime.tsx',
},
{
apply: Plugin_4,
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/eric/Desktop/city-admin/src/.umi/plugin-locale/runtime.tsx',
},
{
apply: Plugin_5,
path: process.env.NODE_ENV === 'production' ? void 0 : '/Users/eric/Desktop/city-admin/src/.umi/plugin-model/runtime.tsx',
},
];
}
export function getValidKeys() {
return ['patchRoutes','patchClientRoutes','modifyContextOpts','rootContainer','innerProvider','i18nProvider','accessProvider','dataflowProvider','outerProvider','render','onRouteChange','getInitialState','layout','locale','qiankun','request',];
}
let pluginManager = null;
export function createPluginManager() {
pluginManager = PluginManager.create({
plugins: getPlugins(),
validKeys: getValidKeys(),
});
return pluginManager;
}
export function getPluginManager() {
return pluginManager;
}

347
src/.umi/core/pluginConfig.d.ts vendored Normal file
View File

@@ -0,0 +1,347 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
// Created by Umi Plugin
export interface IConfigFromPlugins {
clientLoader?: {
}
codeSplitting?: {
jsStrategy?: ("bigVendors" | "depPerChunk" | "granularChunks")
jsStrategyOptions?: {
}
cssStrategy?: "mergeAll"
cssStrategyOptions?: {
}
}
title?: string
styles?: any[]
scripts?: any[]
routes?: {
}[]
reactRouter5Compat?: {
}
presets?: string[]
plugins?: string[]
npmClient?: ("pnpm" | "tnpm" | "cnpm" | "yarn" | "npm")
mountElementId?: string
metas?: any[]
links?: any[]
historyWithQuery?: {
}
history?: {
type?: ("browser" | "hash" | "memory")
}
headScripts?: any[]
conventionRoutes?: {
base?: string
exclude?: any[]
}
base?: string
writeToDisk?: boolean
theme?: {
}
targets?: {
}
svgr?: {
}
svgo?: ({
} | boolean)
styleLoader?: {
}
srcTranspiler?: ("babel" | "esbuild" | "swc" | "none")
sassLoader?: {
}
runtimePublicPath?: {
}
purgeCSS?: {
}
publicPath?: string
proxy?: ({
} | any[])
postcssLoader?: {
}
outputPath?: string
mfsu?: ({
cacheDirectory?: string
chainWebpack?: (() => any)
esbuild?: boolean
exclude?: any[]
include?: string[]
mfName?: string
remoteAliases?: string[]
remoteName?: string
runtimePublicPath?: boolean
shared?: {
}
strategy?: ("eager" | "normal")
} | boolean)
mdx?: {
loader?: string
loaderOptions?: {
}
}
manifest?: {
}
lessLoader?: {
}
jsMinifierOptions?: {
}
jsMinifier?: ("esbuild" | "swc" | "terser" | "uglifyJs" | "none")
inlineLimit?: number
ignoreMomentLocale?: boolean
https?: {
}
hash?: boolean
forkTSChecker?: {
}
fastRefresh?: boolean
extraPostCSSPlugins?: any[]
extraBabelPresets?: any[]
extraBabelPlugins?: any[]
extraBabelIncludes?: any[]
externals?: ({
} | string | (() => any))
esm?: {
}
devtool?: (string | boolean)
depTranspiler?: ("babel" | "esbuild" | "swc" | "none")
define?: {
}
deadCode?: {
}
cssMinifierOptions?: {
}
cssMinifier?: ("cssnano" | "esbuild" | "parcelCSS" | "none")
cssLoaderModules?: {
}
cssLoader?: {
}
copy?: any[]
cacheDirectoryPath?: string
babelLoaderCustomize?: string
autoprefixer?: {
}
autoCSSModules?: boolean
alias?: {
}
crossorigin?: (boolean | {
includes?: {
}[]
})
esmi?: {
cdnOrigin?: string
shimUrl?: string
}
exportStatic?: {
extraRoutePaths?: ((() => any) | string[])
}
favicons?: string[]
mock?: {
exclude?: string[]
include?: string[]
}
mpa?: {
template?: string
layout?: string
getConfigFromEntryFile?: boolean
entry?: {
}
}
polyfill?: {
imports?: string[]
}
routePrefetch?: {
}
ssr?: {
serverBuildPath?: string
platform?: string
builder?: ("esbuild" | "webpack")
}
terminal?: {
}
tmpFiles?: boolean
lowImport?: {
libs?: any[]
css?: string
}
vite?: {
}
apiRoute?: {
platform?: string
}
monorepoRedirect?: (boolean | {
srcDir?: string[]
exclude?: {
}[]
})
test?: {
}
clickToComponent?: {
editor?: string
}
legacy?: {
buildOnly?: boolean
nodeModulesTransform?: boolean
}
classPropertiesLoose?: {
}
verifyCommit?: {
scope?: string[]
allowEmoji?: boolean
}
run?: {
globals?: string[]
}
access?: ({
} | boolean)
analytics?: ({
baidu?: string
ga?: string
ga_v2?: string
} | boolean)
antd?: ({
configProvider?: {
}
dark?: boolean
compact?: boolean
import?: boolean
style?: ("less" | "css")
theme?: {
}
} | boolean)
dva?: ({
extraModels?: string[]
immer?: {
}
skipModelValidate?: boolean
} | boolean)
initialState?: ({
loading?: string
} | boolean)
layout?: ({
} | boolean)
locale?: ({
default?: string
useLocalStorage?: boolean
baseNavigator?: boolean
title?: boolean
antd?: boolean
baseSeparator?: string
} | boolean)
mf?: {
name?: string
remotes?: {
aliasName?: string
name?: string
entry?: string
entries?: {
}
keyResolver?: string
}[]
shared?: {
}
library?: {
}
}
model?: ({
extraModels?: string[]
} | boolean)
moment2dayjs?: ({
preset?: string
plugins?: any[]
} | boolean)
qiankun?: ({
slave?: {
}
master?: {
}
externalQiankun?: boolean
} | boolean)
request?: ({
dataField?: ""
} | boolean)
tailwindcss?: ({
} | boolean)
valtio?: {
}
openAPI?: ({
requestLibPath?: string
schemaPath?: string
mock?: boolean
projectName?: string
apiPrefix?: (string | (() => any))
namespace?: string
hook?: {
customFunctionName?: (() => any)
customClassName?: (() => any)
}
}[] | {
requestLibPath?: string
schemaPath?: string
mock?: boolean
projectName?: string
apiPrefix?: (string | (() => any))
namespace?: string
hook?: {
customFunctionName?: (() => any)
customClassName?: (() => any)
}
})
keepalive?: any[]
tabsLayout?: (boolean | {
hasCustomTabs?: boolean
hasDropdown?: boolean
})
}

169
src/.umi/core/polyfill.ts Normal file
View File

@@ -0,0 +1,169 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.error.cause.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.aggregate-error.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.aggregate-error.cause.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.array.at.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.array.reduce.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.array.reduce-right.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.object.has-own.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.promise.any.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.reflect.to-string-tag.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.regexp.flags.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.string.at-alternative.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.string.replace-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.typed-array.at.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/es.typed-array.set.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.from-async.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.filter-out.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.filter-reject.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.find-last.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.find-last-index.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.group-by.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.group-by-to-map.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.is-template-object.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.last-index.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.last-item.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.to-reversed.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.to-sorted.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.to-spliced.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.unique-by.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.array.with.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.constructor.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.as-indexed-pairs.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.drop.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.every.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.filter.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.find.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.flat-map.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.for-each.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.map.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.reduce.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.some.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.take.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.async-iterator.to-array.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.bigint.range.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.composite-key.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.composite-symbol.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.function.is-callable.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.function.is-constructor.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.function.un-this.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.constructor.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.as-indexed-pairs.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.drop.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.every.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.filter.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.find.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.flat-map.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.for-each.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.map.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.reduce.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.some.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.take.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.to-array.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.iterator.to-async.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.delete-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.emplace.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.every.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.filter.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.find.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.find-key.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.group-by.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.includes.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.key-by.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.key-of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.map-keys.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.map-values.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.merge.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.reduce.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.some.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.update.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.update-or-insert.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.map.upsert.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.clamp.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.deg-per-rad.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.degrees.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.fscale.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.iaddh.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.imulh.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.isubh.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.rad-per-deg.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.radians.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.scale.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.seeded-prng.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.signbit.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.math.umulh.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.number.from-string.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.number.range.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.object.iterate-entries.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.object.iterate-keys.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.object.iterate-values.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.observable.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.promise.try.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.define-metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.delete-metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.get-metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.get-metadata-keys.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.get-own-metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.get-own-metadata-keys.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.has-metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.has-own-metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.reflect.metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.add-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.delete-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.difference.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.every.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.filter.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.find.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.intersection.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.is-disjoint-from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.is-subset-of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.is-superset-of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.join.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.map.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.reduce.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.some.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.symmetric-difference.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.set.union.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.string.at.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.string.cooked.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.string.code-points.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.async-dispose.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.dispose.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.matcher.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.metadata.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.observable.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.pattern-match.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.symbol.replace-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.from-async.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.filter-out.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.filter-reject.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.find-last.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.find-last-index.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.group-by.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.to-reversed.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.to-sorted.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.to-spliced.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.unique-by.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.typed-array.with.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-map.delete-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-map.from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-map.of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-map.emplace.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-map.upsert.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-set.add-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-set.delete-all.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-set.from.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/esnext.weak-set.of.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/web.dom-exception.stack.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/web.immediate.js";
import "/Users/eric/Desktop/city-admin/node_modules/core-js/modules/web.structured-clone.js";
import '/Users/eric/Desktop/city-admin/node_modules/@umijs/preset-umi/node_modules/regenerator-runtime/runtime.js';
export {};

24
src/.umi/core/route.tsx Normal file
View File

@@ -0,0 +1,24 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
export async function getRoutes() {
return {
routes: {"1":{"path":"/user","layout":false,"id":"1"},"2":{"name":"login","path":"/user/login","file":"@/pages/User/Login/index.tsx","parentId":"1","id":"2"},"3":{"path":"/welcome","name":"welcome","icon":"smile","file":"@/pages/Welcome.tsx","parentId":"ant-design-pro-layout","id":"3"},"4":{"path":"/admin","name":"admin","icon":"crown","access":"canAdmin","parentId":"ant-design-pro-layout","id":"4"},"5":{"path":"/admin","redirect":"/admin/sub-page","parentId":"4","id":"5"},"6":{"path":"/admin/sub-page","name":"sub-page","file":"@/pages/Admin.tsx","parentId":"4","id":"6"},"7":{"name":"list.table-list","icon":"table","path":"/list","file":"@/pages/TableList/index.tsx","parentId":"ant-design-pro-layout","id":"7"},"8":{"name":"list.table-list","icon":"table","path":"/cityNew","file":"@/pages/cityNew/index.tsx","parentId":"ant-design-pro-layout","id":"8"},"9":{"path":"/","redirect":"/welcome","parentId":"ant-design-pro-layout","id":"9"},"10":{"path":"*","layout":false,"file":"@/pages/404.tsx","id":"10"},"ant-design-pro-layout":{"id":"ant-design-pro-layout","path":"/","file":"@/.umi/plugin-layout/Layout.tsx","isLayout":true},"umi/plugin/openapi":{"path":"/umi/plugin/openapi","id":"umi/plugin/openapi","file":"/Users/eric/Desktop/city-admin/src/.umi/plugin-openapi/openapi.tsx"}},
routeComponents: {
'1': React.lazy(() => import( './EmptyRoute')),
'2': React.lazy(() => import(/* webpackChunkName: "p__User__Login__index" */'@/pages/User/Login/index.tsx')),
'3': React.lazy(() => import(/* webpackChunkName: "p__Welcome" */'@/pages/Welcome.tsx')),
'4': React.lazy(() => import( './EmptyRoute')),
'5': React.lazy(() => import( './EmptyRoute')),
'6': React.lazy(() => import(/* webpackChunkName: "p__Admin" */'@/pages/Admin.tsx')),
'7': React.lazy(() => import(/* webpackChunkName: "p__TableList__index" */'@/pages/TableList/index.tsx')),
'8': React.lazy(() => import(/* webpackChunkName: "p__cityNew__index" */'@/pages/cityNew/index.tsx')),
'9': React.lazy(() => import( './EmptyRoute')),
'10': React.lazy(() => import(/* webpackChunkName: "p__404" */'@/pages/404.tsx')),
'ant-design-pro-layout': React.lazy(() => import(/* webpackChunkName: "umi__plugin-layout__Layout" */'@/.umi/plugin-layout/Layout.tsx')),
'umi/plugin/openapi': React.lazy(() => import(/* webpackChunkName: "umi__plugin-openapi__openapi" */'/Users/eric/Desktop/city-admin/src/.umi/plugin-openapi/openapi.tsx')),
},
};
}

38
src/.umi/core/terminal.ts Normal file
View File

@@ -0,0 +1,38 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
const console = globalThis.console;
let count = 0;
let groupLevel = 0;
function send(type: string, message?: string) {
if(process.env.NODE_ENV==='production'){
return;
}else{
const encodedMessage = message ? `&m=${encodeURI(message)}` : '';
fetch(`/__umi/api/terminal?type=${type}&t=${Date.now()}&c=${count++}&g=${groupLevel}${encodedMessage}`, { mode: 'no-cors' })
}
}
function prettyPrint(obj: any) {
return JSON.stringify(obj, null, 2);
}
function stringifyObjs(objs: any[]) {
const obj = objs.length > 1 ? objs.map(stringify).join(' ') : objs[0];
return typeof obj === 'object' ? `${prettyPrint(obj)}` : obj.toString();
}
function stringify(obj: any) {
return typeof obj === 'object' ? `${JSON.stringify(obj)}` : obj.toString();
}
const terminal = {
log(...objs: any[]) { send('log', stringifyObjs(objs)) },
info(...objs: any[]) { send('info', stringifyObjs(objs)) },
warn(...objs: any[]) { send('warn', stringifyObjs(objs)) },
error(...objs: any[]) { send('error', stringifyObjs(objs)) },
group() { groupLevel++ },
groupCollapsed() { groupLevel++ },
groupEnd() { groupLevel && --groupLevel },
clear() { send('clear') },
trace(...args: any[]) { console.trace(...args) },
profile(...args: any[]) { console.profile(...args) },
profileEnd(...args: any[]) { console.profileEnd(...args) },
};
export { terminal };

22
src/.umi/exports.ts Normal file
View File

@@ -0,0 +1,22 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
// @umijs/renderer-*
export { createBrowserHistory, createHashHistory, createMemoryHistory, createSearchParams, generatePath, matchPath, matchRoutes, Navigate, NavLink, Outlet, resolvePath, useLocation, useMatch, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams, Helmet, useAppData, useClientLoaderData, useServerLoaderData, renderClient, __getRoot, Link, useRouteData, __useFetcher, withRouter } from '/Users/eric/Desktop/city-admin/node_modules/@umijs/preset-umi/node_modules/@umijs/renderer-react';
export type { History } from '/Users/eric/Desktop/city-admin/node_modules/@umijs/preset-umi/node_modules/@umijs/renderer-react'
// umi/client/client/plugin
export { ApplyPluginsType, PluginManager } from '/Users/eric/Desktop/city-admin/node_modules/umi/client/client/plugin.js';
export { history, createHistory } from './core/history';
export { terminal } from './core/terminal';
export { TestBrowser } from './testBrowser';
// plugins
export { Access, useAccess, useAccessMarkedRoutes } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-access';
export { addLocale, setLocale, getLocale, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage, getAllLocales, FormattedDate, FormattedDateParts, FormattedDisplayName, FormattedHTMLMessage, FormattedList, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts, IntlProvider, RawIntlProvider, SelectLang } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-locale';
export { Provider, useModel } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-model';
export { useRequest, UseRequestProvider, request, getRequestInstance } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-request';
export { proxy, useSnapshot, snapshot, subscribe, proxyWithComputed, proxyWithHistory, proxyWithDevtools, proxyMap, proxySet } from '/Users/eric/Desktop/city-admin/src/.umi/plugin-valtio';
// plugins types.d.ts
export * from '/Users/eric/Desktop/city-admin/src/.umi/plugin-layout/types.d';
export * from '/Users/eric/Desktop/city-admin/src/.umi/plugin-request/types.d';
export { defineApp } from './core/defineApp'
export type { RuntimeConfig } from './core/defineApp'

View File

@@ -0,0 +1,5 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
export const AccessContext = React.createContext<any>(null);

View File

@@ -0,0 +1,87 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React, { PropsWithChildren } from 'react';
import { AccessContext } from './context';
import type { IRoute } from 'umi';
export const useAccess = () => {
return React.useContext(AccessContext);
};
export interface AccessProps {
accessible: boolean;
fallback?: React.ReactNode;
}
export const Access: React.FC<PropsWithChildren<AccessProps>> = (props) => {
if (process.env.NODE_ENV === 'development' && typeof props.accessible !== 'boolean') {
throw new Error('[access] the `accessible` property on <Access /> should be a boolean');
}
return <>{ props.accessible ? props.children : props.fallback }</>;
};
export const useAccessMarkedRoutes = (routes: IRoute[]) => {
const access = useAccess();
const markdedRoutes: IRoute[] = React.useMemo(() => {
const process = (route, parentAccessCode, parentRoute) => {
let accessCode = route.access;
// 用父级的路由检测父级的 accessCode
let detectorRoute = route;
if (!accessCode && parentAccessCode) {
accessCode = parentAccessCode;
detectorRoute = parentRoute;
}
// set default status
route.unaccessible = false;
// check access code
if (typeof accessCode === 'string') {
const detector = access[accessCode];
if (typeof detector === 'function') {
route.unaccessible = !detector(detectorRoute);
} else if (typeof detector === 'boolean') {
route.unaccessible = !detector;
} else if (typeof detector === 'undefined') {
route.unaccessible = true;
}
}
// check children access code
if (route.children?.length) {
const isNoAccessibleChild = !route.children.reduce((hasAccessibleChild, child) => {
process(child, accessCode, route);
return hasAccessibleChild || !child.unaccessible;
}, false);
// make sure parent route is unaccessible if all children are unaccessible
if (isNoAccessibleChild) {
route.unaccessible = true;
}
}
// check children access code
if (route.routes?.length) {
const isNoAccessibleChild = !route.routes.reduce((hasAccessibleChild, child) => {
process(child, accessCode, route);
return hasAccessibleChild || !child.unaccessible;
}, false);
// make sure parent route is unaccessible if all children are unaccessible
if (isNoAccessibleChild) {
route.unaccessible = true;
}
}
return route;
}
return routes.map(route => process(route));
}, [routes.length, access]);
return markdedRoutes;
}

View File

@@ -0,0 +1,23 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import accessFactory from '@/access'
import { useModel } from '@@/plugin-model';
import { AccessContext } from './context';
function Provider(props) {
const { initialState } = useModel('@@initialState');
const access = React.useMemo(() => accessFactory(initialState), [initialState]);
return (
<AccessContext.Provider value={access}>
{ props.children }
</AccessContext.Provider>
);
}
export function accessProvider(container) {
return <Provider>{ container }</Provider>;
}

View File

@@ -0,0 +1,50 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import { useState, useEffect, useCallback } from 'react';
import { getInitialState } from '@/app';
export type InitialStateType = Awaited<ReturnType<typeof getInitialState>> | undefined;
const initState = {
initialState: undefined as InitialStateType,
loading: true,
error: undefined,
};
export default () => {
const [state, setState] = useState(initState);
const refresh = useCallback(async () => {
setState((s) => ({ ...s, loading: true, error: undefined }));
try {
const ret = await getInitialState();
setState((s) => ({ ...s, initialState: ret, loading: false }));
} catch (e) {
setState((s) => ({ ...s, error: e, loading: false }));
}
}, []);
const setInitialState = useCallback(
async (
initialState: InitialStateType | ((initialState: InitialStateType) => InitialStateType),
) => {
setState((s) => {
if (typeof initialState === 'function') {
return { ...s, initialState: initialState(s.initialState), loading: false };
}
return { ...s, initialState, loading: false };
});
},
[],
);
useEffect(() => {
refresh();
}, []);
return {
...state,
refresh,
setInitialState,
};
}

View File

@@ -0,0 +1,19 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import { useModel } from '@@/plugin-model';
function Loading() { return <div />; }
export default function InitialStateProvider(props: any) {
const appLoaded = React.useRef(false);
const { loading = false } = useModel("@@initialState") || {};
React.useEffect(() => {
if (!loading) {
appLoaded.current = true;
}
}, [loading]);
if (loading && !appLoaded.current) {
return <Loading />;
}
return props.children;
}

View File

@@ -0,0 +1,8 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import Provider from './Provider';
export function dataflowProvider(container) {
return <Provider>{ container }</Provider>;
}

View File

@@ -0,0 +1,5 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
export interface IRuntimeConfig {
getInitialState?: () => Promise<Record<string, any>>
}

View File

@@ -0,0 +1,37 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import { history, type IRoute } from 'umi';
import { Result, Button } from 'antd';
const Exception: React.FC<{
children: React.ReactNode;
route?: IRoute;
notFound?: React.ReactNode;
noAccessible?: React.ReactNode;
unAccessible?: React.ReactNode;
noFound?: React.ReactNode;
}> = (props) => (
// render custom 404
(!props.route && (props.noFound || props.notFound)) ||
// render custom 403
(props.route?.unaccessible && (props.unAccessible || props.noAccessible)) ||
// render default exception
((!props.route || props.route?.unaccessible) && (
<Result
status={props.route ? '403' : '404'}
title={props.route ? '403' : '404'}
subTitle={props.route ? '抱歉,你无权访问该页面' : '抱歉,你访问的页面不存在'}
extra={
<Button type="primary" onClick={() => history.push('/')}>
</Button>
}
/>
)) ||
// normal render
props.children
);
export default Exception;

View File

@@ -0,0 +1,52 @@
@import '~antd/es/style/themes/default.less';
@media screen and (max-width: 480px) {
// 在小屏幕的时候可以有更好的体验
.umi-plugin-layout-container {
width: 100% !important;
}
.umi-plugin-layout-container > * {
border-radius: 0 !important;
}
}
.umi-plugin-layout-menu {
.anticon {
margin-right: 8px;
}
.ant-dropdown-menu-item {
min-width: 160px;
}
}
.umi-plugin-layout-right {
display: flex !important;
float: right;
height: 100%;
margin-left: auto;
overflow: hidden;
.umi-plugin-layout-action {
display: flex;
align-items: center;
height: 100%;
padding: 0 12px;
cursor: pointer;
transition: all 0.3s;
> i {
color: rgba(255, 255, 255, 0.85);
vertical-align: middle;
}
&:hover {
background: rgba(0, 0, 0, 0.025);
}
&:global(.opened) {
background: rgba(0, 0, 0, 0.025);
}
}
.umi-plugin-layout-search {
padding: 0 12px;
&:hover {
background: transparent;
}
}
}
.umi-plugin-layout-name {
margin-left: 8px;
}

View File

@@ -0,0 +1,178 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import { Link, useLocation, useNavigate, Outlet, useAppData, useRouteData, matchRoutes } from 'umi';
import type { IRoute } from 'umi';
import React, { useMemo } from 'react';
import {
ProLayout,
} from "/Users/eric/Desktop/city-admin/node_modules/@ant-design/pro-components";
import './Layout.less';
import Logo from './Logo';
import Exception from './Exception';
import { getRightRenderContent } from './rightRender';
import { useModel } from '@@/plugin-model';
import { useAccessMarkedRoutes } from '@@/plugin-access';
import { useIntl } from '@@/plugin-locale';
// 过滤出需要显示的路由, 这里的filterFn 指 不希望显示的层级
const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) => {
if (routes.length === 0) {
return []
}
let newRoutes = []
for (const route of routes) {
const newRoute = {...route };
if (filterFn(route)) {
if (Array.isArray(newRoute.routes)) {
newRoutes.push(...filterRoutes(newRoute.routes, filterFn))
}
} else {
if (Array.isArray(newRoute.children)) {
newRoute.children = filterRoutes(newRoute.children, filterFn);
newRoute.routes = newRoute.children;
}
newRoutes.push(newRoute);
}
}
return newRoutes;
}
// 格式化路由 处理因 wrapper 导致的 菜单 path 不一致
const mapRoutes = (routes: IRoute[]) => {
if (routes.length === 0) {
return []
}
return routes.map(route => {
// 需要 copy 一份, 否则会污染原始数据
const newRoute = {...route}
if (route.originPath) {
newRoute.path = route.originPath
}
if (Array.isArray(route.routes)) {
newRoute.routes = mapRoutes(route.routes);
}
if (Array.isArray(route.children)) {
newRoute.children = mapRoutes(route.children);
}
return newRoute
})
}
export default (props: any) => {
const location = useLocation();
const navigate = useNavigate();
const { clientRoutes, pluginManager } = useAppData();
const initialInfo = (useModel && useModel('@@initialState')) || {
initialState: undefined,
loading: false,
setInitialState: null,
};
const { initialState, loading, setInitialState } = initialInfo;
const userConfig = {
"locale": true,
"navTheme": "light",
"colorPrimary": "#1890ff",
"layout": "mix",
"contentWidth": "Fluid",
"fixedHeader": false,
"fixSiderbar": true,
"colorWeak": false,
"title": "Ant Design Pro",
"pwa": false,
"logo": "https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg",
"iconfontUrl": ""
};
const { formatMessage } = useIntl();
const runtimeConfig = pluginManager.applyPlugins({
key: 'layout',
type: 'modify',
initialValue: {
...initialInfo
},
});
// 现在的 layout 及 wrapper 实现是通过父路由的形式实现的, 会导致路由数据多了冗余层级, proLayout 消费时, 无法正确展示菜单, 这里对冗余数据进行过滤操作
const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper;
})
const [route] = useAccessMarkedRoutes(mapRoutes(newRoutes));
const matchedRoute = useMemo(() => matchRoutes(route.children, location.pathname)?.pop?.()?.route, [location.pathname]);
return (
<ProLayout
route={route}
location={location}
title={userConfig.title || 'plugin-layout'}
navTheme="dark"
siderWidth={256}
onMenuHeaderClick={(e) => {
e.stopPropagation();
e.preventDefault();
navigate('/');
}}
formatMessage={userConfig.formatMessage || formatMessage}
menu={{ locale: userConfig.locale }}
logo={Logo}
menuItemRender={(menuItemProps, defaultDom) => {
if (menuItemProps.isUrl || menuItemProps.children) {
return defaultDom;
}
if (menuItemProps.path && location.pathname !== menuItemProps.path) {
return (
// handle wildcard route path, for example /slave/* from qiankun
<Link to={menuItemProps.path.replace('/*', '')} target={menuItemProps.target}>
{defaultDom}
</Link>
);
}
return defaultDom;
}}
itemRender={(route) => <Link to={route.path}>{route.breadcrumbName}</Link>}
disableContentMargin
fixSiderbar
fixedHeader
{...runtimeConfig}
rightContentRender={
runtimeConfig.rightContentRender !== false &&
((layoutProps) => {
const dom = getRightRenderContent({
runtimeConfig,
loading,
initialState,
setInitialState,
});
if (runtimeConfig.rightContentRender) {
return runtimeConfig.rightContentRender(layoutProps, dom, {
// BREAK CHANGE userConfig > runtimeConfig
userConfig,
runtimeConfig,
loading,
initialState,
setInitialState,
});
}
return dom;
})
}
>
<Exception
route={matchedRoute}
notFound={runtimeConfig?.notFound}
noAccessible={runtimeConfig?.noAccessible}
>
{runtimeConfig.childrenRender
? runtimeConfig.childrenRender(<Outlet />, props)
: <Outlet />
}
</Exception>
</ProLayout>
);
}

View File

@@ -0,0 +1,94 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
const LogoIcon: React.FC = () => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 200 200"
>
<defs>
<linearGradient
id="linearGradient-1"
x1="62.102%"
x2="108.197%"
y1="0%"
y2="37.864%"
>
<stop offset="0%" stopColor="#4285EB"></stop>
<stop offset="100%" stopColor="#2EC7FF"></stop>
</linearGradient>
<linearGradient
id="linearGradient-2"
x1="69.644%"
x2="54.043%"
y1="0%"
y2="108.457%"
>
<stop offset="0%" stopColor="#29CDFF"></stop>
<stop offset="37.86%" stopColor="#148EFF"></stop>
<stop offset="100%" stopColor="#0A60FF"></stop>
</linearGradient>
<linearGradient
id="linearGradient-3"
x1="69.691%"
x2="16.723%"
y1="-12.974%"
y2="117.391%"
>
<stop offset="0%" stopColor="#FA816E"></stop>
<stop offset="41.473%" stopColor="#F74A5C"></stop>
<stop offset="100%" stopColor="#F51D2C"></stop>
</linearGradient>
<linearGradient
id="linearGradient-4"
x1="68.128%"
x2="30.44%"
y1="-35.691%"
y2="114.943%"
>
<stop offset="0%" stopColor="#FA8E7D"></stop>
<stop offset="51.264%" stopColor="#F74A5C"></stop>
<stop offset="100%" stopColor="#F51D2C"></stop>
</linearGradient>
</defs>
<g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
<g transform="translate(-20 -20)">
<g transform="translate(20 20)">
<g>
<g fillRule="nonzero">
<g>
<path
fill="url(#linearGradient-1)"
d="M91.588 4.177L4.18 91.513a11.981 11.981 0 000 16.974l87.408 87.336a12.005 12.005 0 0016.989 0l36.648-36.618c4.209-4.205 4.209-11.023 0-15.228-4.208-4.205-11.031-4.205-15.24 0l-27.783 27.76c-1.17 1.169-2.945 1.169-4.114 0l-69.802-69.744c-1.17-1.169-1.17-2.942 0-4.11l69.802-69.745c1.17-1.169 2.944-1.169 4.114 0l27.783 27.76c4.209 4.205 11.032 4.205 15.24 0 4.209-4.205 4.209-11.022 0-15.227L108.581 4.056c-4.719-4.594-12.312-4.557-16.993.12z"
></path>
<path
fill="url(#linearGradient-2)"
d="M91.588 4.177L4.18 91.513a11.981 11.981 0 000 16.974l87.408 87.336a12.005 12.005 0 0016.989 0l36.648-36.618c4.209-4.205 4.209-11.023 0-15.228-4.208-4.205-11.031-4.205-15.24 0l-27.783 27.76c-1.17 1.169-2.945 1.169-4.114 0l-69.802-69.744c-1.17-1.169-1.17-2.942 0-4.11l69.802-69.745c2.912-2.51 7.664-7.596 14.642-8.786 5.186-.883 10.855 1.062 17.009 5.837L108.58 4.056c-4.719-4.594-12.312-4.557-16.993.12z"
></path>
</g>
<path
fill="url(#linearGradient-3)"
d="M153.686 135.855c4.208 4.205 11.031 4.205 15.24 0l27.034-27.012c4.7-4.696 4.7-12.28 0-16.974l-27.27-27.15c-4.218-4.2-11.043-4.195-15.254.013-4.209 4.205-4.209 11.022 0 15.227l18.418 18.403c1.17 1.169 1.17 2.943 0 4.111l-18.168 18.154c-4.209 4.205-4.209 11.023 0 15.228z"
></path>
</g>
<ellipse
cx="100.519"
cy="100.437"
fill="url(#linearGradient-4)"
rx="23.6"
ry="23.581"
></ellipse>
</g>
</g>
</g>
</g>
</svg>
);
};
export default LogoIcon;

View File

@@ -0,0 +1,7 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import SmileOutlined from '/Users/eric/Desktop/city-admin/node_modules/@ant-design/icons/es/icons/SmileOutlined';
import CrownOutlined from '/Users/eric/Desktop/city-admin/node_modules/@ant-design/icons/es/icons/CrownOutlined';
import TableOutlined from '/Users/eric/Desktop/city-admin/node_modules/@ant-design/icons/es/icons/TableOutlined';
export default { SmileOutlined, CrownOutlined, TableOutlined };

View File

@@ -0,0 +1,4 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
export type TempType = string

View File

@@ -0,0 +1,72 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import { Avatar, Dropdown, Menu, Spin } from 'antd';
import { LogoutOutlined } from '@ant-design/icons';
import { SelectLang } from '@@/plugin-locale';
export function getRightRenderContent (opts: {
runtimeConfig: any,
loading: boolean,
initialState: any,
setInitialState: any,
}) {
if (opts.runtimeConfig.rightRender) {
return opts.runtimeConfig.rightRender(
opts.initialState,
opts.setInitialState,
opts.runtimeConfig,
);
}
const menu = (
<Menu className="umi-plugin-layout-menu">
<Menu.Item
key="logout"
onClick={() =>
opts.runtimeConfig.logout && opts.runtimeConfig?.logout(opts.initialState)
}
>
<LogoutOutlined />
退
</Menu.Item>
</Menu>
);
const avatar = (
<span className="umi-plugin-layout-action">
<Avatar
size="small"
className="umi-plugin-layout-avatar"
src={
opts.initialState?.avatar ||
'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
}
alt="avatar"
/>
<span className="umi-plugin-layout-name">{opts.initialState?.name}</span>
</span>
);
if (opts.loading) {
return (
<div className="umi-plugin-layout-right">
<Spin size="small" style={ { marginLeft: 8, marginRight: 8 } } />
</div>
);
}
return (
<div className="umi-plugin-layout-right anticon">
{opts.runtimeConfig.logout ? (
<Dropdown overlay={menu} overlayClassName="umi-plugin-layout-container">
{avatar}
</Dropdown>
) : (
avatar
)}
<SelectLang />
</div>
);
}

View File

@@ -0,0 +1,25 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import icons from './icons';
function formatIcon(name: string) {
return name
.replace(name[0], name[0].toUpperCase())
.replace(/-(w)/g, function(all, letter) {
return letter.toUpperCase();
});
}
export function patchRoutes({ routes }) {
Object.keys(routes).forEach(key => {
const { icon } = routes[key];
if (icon && typeof icon === 'string') {
const upperIcon = formatIcon(icon);
if (icons[upperIcon] || icons[upperIcon + 'Outlined']) {
routes[key].icon = React.createElement(icons[upperIcon] || icons[upperIcon + 'Outlined']);
}
}
});
}

View File

@@ -0,0 +1,6 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import type { RunTimeLayoutConfig } from './types.d';
export interface IRuntimeConfig {
layout?: RunTimeLayoutConfig
}

34
src/.umi/plugin-layout/types.d.ts vendored Normal file
View File

@@ -0,0 +1,34 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import type { ProLayoutProps, HeaderProps } from "/Users/eric/Desktop/city-admin/node_modules/@ant-design/pro-components";
import type InitialStateType from '@@/plugin-initialState/@@initialState';
type InitDataType = ReturnType<typeof InitialStateType>;
import type { IConfigFromPlugins } from '@@/core/pluginConfig';
export type RunTimeLayoutConfig = (initData: InitDataType) => Omit<
ProLayoutProps,
'rightContentRender'
> & {
childrenRender?: (dom: JSX.Element, props: ProLayoutProps) => React.ReactNode;
unAccessible?: JSX.Element;
noFound?: JSX.Element;
logout?: (initialState: InitDataType['initialState']) => Promise<void> | void;
rightContentRender?: (
headerProps: HeaderProps,
dom: JSX.Element,
props: {
userConfig: IConfigFromPlugins['layout'];
runtimeConfig: RunTimeLayoutConfig;
loading: InitDataType['loading'];
initialState: InitDataType['initialState'];
setInitialState: InitDataType['setInitialState'];
},
) => JSX.Element;
rightRender?: (
initialState: InitDataType['initialState'],
setInitialState: InitDataType['setInitialState'],
runtimeConfig: RunTimeLayoutConfig,
) => JSX.Element;
};

View File

@@ -0,0 +1,475 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React,{ useState } from 'react';
import { Menu, Dropdown } from 'antd';
import { ClickParam } from 'antd/es/menu';
import { DropDownProps } from 'antd/es/dropdown';
import { getLocale, getAllLocales, setLocale } from './localeExports';
export interface HeaderDropdownProps extends DropDownProps {
overlayClassName?: string;
placement?:
| 'bottomLeft'
| 'bottomRight'
| 'topLeft'
| 'topCenter'
| 'topRight'
| 'bottomCenter';
}
const HeaderDropdown: React.FC<HeaderDropdownProps> = ({
overlayClassName: cls,
...restProps
}) => (
<Dropdown
overlayClassName={cls}
{...restProps}
/>
);
interface LocalData {
lang: string,
label?: string,
icon?: string,
title?: string,
}
interface SelectLangProps {
globalIconClassName?: string;
postLocalesData?: (locales: LocalData[]) => LocalData[];
onItemClick?: (params: ClickParam) => void;
className?: string;
reload?: boolean;
icon?: React.ReactNode;
}
const transformArrayToObject = (allLangUIConfig:LocalData[])=>{
return allLangUIConfig.reduce((obj, item) => {
if(!item.lang){
return obj;
}
return {
...obj,
[item.lang]: item,
};
}, {});
}
const defaultLangUConfigMap = {
'ar-EG': {
lang: 'ar-EG',
label: 'العربية',
icon: '🇪🇬',
title: 'لغة'
},
'az-AZ': {
lang: 'az-AZ',
label: 'Azərbaycan dili',
icon: '🇦🇿',
title: 'Dil'
},
'bg-BG': {
lang: 'bg-BG',
label: 'Български език',
icon: '🇧🇬',
title: 'език'
},
'bn-BD': {
lang: 'bn-BD',
label: 'বাংলা',
icon: '🇧🇩',
title: 'ভাষা'
},
'ca-ES': {
lang: 'ca-ES',
label: 'Catalá',
icon: '🇨🇦',
title: 'llengua'
},
'cs-CZ': {
lang: 'cs-CZ',
label: 'Čeština',
icon: '🇨🇿',
title: 'Jazyk'
},
'da-DK': {
lang: 'da-DK',
label: 'Dansk',
icon: '🇩🇰',
title: 'Sprog'
},
'de-DE': {
lang: 'de-DE',
label: 'Deutsch',
icon: '🇩🇪',
title: 'Sprache'
},
'el-GR': {
lang: 'el-GR',
label: 'Ελληνικά',
icon: '🇬🇷',
title: 'Γλώσσα'
},
'en-GB': {
lang: 'en-GB',
label: 'English',
icon: '🇬🇧',
title: 'Language'
},
'en-US': {
lang: 'en-US',
label: 'English',
icon: '🇺🇸',
title: 'Language'
},
'es-ES': {
lang: 'es-ES',
label: 'Español',
icon: '🇪🇸',
title: 'Idioma'
},
'et-EE': {
lang: 'et-EE',
label: 'Eesti',
icon: '🇪🇪',
title: 'Keel'
},
'fa-IR': {
lang: 'fa-IR',
label: 'فارسی',
icon: '🇮🇷',
title: 'زبان'
},
'fi-FI': {
lang: 'fi-FI',
label: 'Suomi',
icon: '🇫🇮',
title: 'Kieli'
},
'fr-BE': {
lang: 'fr-BE',
label: 'Français',
icon: '🇧🇪',
title: 'Langue'
},
'fr-FR': {
lang: 'fr-FR',
label: 'Français',
icon: '🇫🇷',
title: 'Langue'
},
'ga-IE': {
lang: 'ga-IE',
label: 'Gaeilge',
icon: '🇮🇪',
title: 'Teanga'
},
'he-IL': {
lang: 'he-IL',
label: 'עברית',
icon: '🇮🇱',
title: 'שפה'
},
'hi-IN': {
lang: 'hi-IN',
label: 'हिन्दी, हिंदी',
icon: '🇮🇳',
title: 'भाषा: हिन्दी'
},
'hr-HR': {
lang: 'hr-HR',
label: 'Hrvatski jezik',
icon: '🇭🇷',
title: 'Jezik'
},
'hu-HU': {
lang: 'hu-HU',
label: 'Magyar',
icon: '🇭🇺',
title: 'Nyelv'
},
'hy-AM': {
lang: 'hu-HU',
label: 'Հայերեն',
icon: '🇦🇲',
title: 'Լեզու'
},
'id-ID': {
lang: 'id-ID',
label: 'Bahasa Indonesia',
icon: '🇮🇩',
title: 'Bahasa'
},
'it-IT': {
lang: 'it-IT',
label: 'Italiano',
icon: '🇮🇹',
title: 'Linguaggio'
},
'is-IS': {
lang: 'is-IS',
label: 'Íslenska',
icon: '🇮🇸',
title: 'Tungumál'
},
'ja-JP': {
lang: 'ja-JP',
label: '日本語',
icon: '🇯🇵',
title: '言語'
},
'ku-IQ': {
lang: 'ku-IQ',
label: 'کوردی',
icon: '🇮🇶',
title: 'Ziman'
},
'kn-IN': {
lang: 'kn-IN',
label: 'ಕನ್ನಡ',
icon: '🇮🇳',
title: 'ಭಾಷೆ'
},
'ko-KR': {
lang: 'ko-KR',
label: '한국어',
icon: '🇰🇷',
title: '언어'
},
'lv-LV': {
lang: 'lv-LV',
label: 'Latviešu valoda',
icon: '🇱🇮',
title: 'Kalba'
},
'mk-MK': {
lang: 'mk-MK',
label: 'македонски јазик',
icon: '🇲🇰',
title: 'Јазик'
},
'mn-MN': {
lang: 'mn-MN',
label: 'Монгол хэл',
icon: '🇲🇳',
title: 'Хэл'
},
'ms-MY': {
lang: 'ms-MY',
label: 'بهاس ملايو‎',
icon: '🇲🇾',
title: 'Bahasa'
},
'nb-NO': {
lang: 'nb-NO',
label: 'Norsk',
icon: '🇳🇴',
title: 'Språk'
},
'ne-NP': {
lang: 'ne-NP',
label: 'नेपाली',
icon: '🇳🇵',
title: 'भाषा'
},
'nl-BE': {
lang: 'nl-BE',
label: 'Vlaams',
icon: '🇧🇪',
title: 'Taal'
},
'nl-NL': {
lang: 'nl-NL',
label: 'Vlaams',
icon: '🇳🇱',
title: 'Taal'
},
'pl-PL': {
lang: 'pl-PL',
label: 'Polski',
icon: '🇵🇱',
title: 'Język'
},
'pt-BR': {
lang: 'pt-BR',
label: 'Português',
icon: '🇧🇷',
title: 'Idiomas'
},
'pt-PT': {
lang: 'pt-PT',
label: 'Português',
icon: '🇵🇹',
title: 'Idiomas'
},
'ro-RO': {
lang: 'ro-RO',
label: 'Română',
icon: '🇷🇴',
title: 'Limba'
},
'ru-RU': {
lang: 'ru-RU',
label: 'Русский',
icon: '🇷🇺',
title: 'язык'
},
'sk-SK': {
lang: 'sk-SK',
label: 'Slovenčina',
icon: '🇸🇰',
title: 'Jazyk'
},
'sr-RS': {
lang: 'sr-RS',
label: 'српски језик',
icon: '🇸🇷',
title: 'Језик'
},
'sl-SI': {
lang: 'sl-SI',
label: 'Slovenščina',
icon: '🇸🇱',
title: 'Jezik'
},
'sv-SE': {
lang: 'sv-SE',
label: 'Svenska',
icon: '🇸🇪',
title: 'Språk'
},
'ta-IN': {
lang: 'ta-IN',
label: 'தமிழ்',
icon: '🇮🇳',
title: 'மொழி'
},
'th-TH': {
lang: 'th-TH',
label: 'ไทย',
icon: '🇹🇭',
title: 'ภาษา'
},
'tr-TR': {
lang: 'tr-TR',
label: 'Türkçe',
icon: '🇹🇷',
title: 'Dil'
},
'uk-UA': {
lang: 'uk-UA',
label: 'Українська',
icon: '🇺🇰',
title: 'Мова'
},
'vi-VN': {
lang: 'vi-VN',
label: 'Tiếng Việt',
icon: '🇻🇳',
title: 'Ngôn ngữ'
},
'zh-CN': {
lang: 'zh-CN',
label: '简体中文',
icon: '🇨🇳',
title: '语言'
},
'zh-TW': {
lang: 'zh-TW',
label: '繁體中文',
icon: '🇭🇰',
title: '語言'
}
};
export const SelectLang: React.FC<SelectLangProps> = (props) => {
const {
globalIconClassName,
postLocalesData,
onItemClick,
icon,
style,
reload,
...restProps
} = props;
const [selectedLang, setSelectedLang] = useState(() => getLocale());
const changeLang = ({ key }: ClickParam): void => {
setLocale(key, reload);
setSelectedLang(getLocale())
};
const defaultLangUConfig = getAllLocales().map(
(key) =>
defaultLangUConfigMap[key] || {
lang: key,
label: key,
icon: "🌐",
title: key,
}
);
const allLangUIConfig =
postLocalesData?.(defaultLangUConfig) || defaultLangUConfig;
const handleClick = onItemClick
? (params: ClickParam) => onItemClick(params)
: changeLang;
const menuItemStyle = { minWidth: "160px" };
const menuItemIconStyle = { marginRight: "8px" };
const langMenu = (
<Menu selectedKeys={[selectedLang]} onClick={handleClick}>
{allLangUIConfig.map((localeObj) => {
return (
<Menu.Item key={localeObj.lang || localeObj.key} style={menuItemStyle}>
<span role="img" aria-label={localeObj?.label || "en-US"} style={menuItemIconStyle}>
{localeObj?.icon || "🌐"}
</span>
{localeObj?.label || "en-US"}
</Menu.Item>
);
})}
</Menu>
);
const inlineStyle = {
cursor: "pointer",
padding: "12px",
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
fontSize: 18,
verticalAlign: "middle",
...style,
};
return (
<HeaderDropdown overlay={langMenu} placement="bottomRight" {...restProps}>
<span className={globalIconClassName} style={inlineStyle}>
<i className="anticon" title={allLangUIConfig[selectedLang]?.title}>
{ icon ?
icon : (
<svg
viewBox="0 0 24 24"
focusable="false"
width="1em"
height="1em"
fill="currentColor"
aria-hidden="true"
>
<path d="M0 0h24v24H0z" fill="none" />
<path
d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z "
className="css-c4d79v"
/>
</svg>
)}
</i>
</span>
</HeaderDropdown>
);
return <></>
};

View File

@@ -0,0 +1,5 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
export { addLocale, setLocale, getLocale, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage, getAllLocales, FormattedDate, FormattedDateParts, FormattedDisplayName, FormattedHTMLMessage, FormattedList, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts, IntlProvider, RawIntlProvider } from './localeExports';
export { SelectLang } from './SelectLang';

View File

@@ -0,0 +1,64 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import { ConfigProvider } from 'antd';
import moment from '/Users/eric/Desktop/city-admin/node_modules/moment';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/bn-bd';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/fa';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/id';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/ja';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/pt-br';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/zh-cn';
import '/Users/eric/Desktop/city-admin/node_modules/moment/locale/zh-tw';
import { RawIntlProvider, getLocale, getDirection , setIntl, getIntl, localeInfo, event, LANG_CHANGE_EVENT } from './localeExports';
export function _onCreate() {
const locale = getLocale();
if (moment?.locale) {
moment.locale(localeInfo[locale]?.momentLocale || '');
}
setIntl(locale);
}
const useIsomorphicLayoutEffect =
typeof window !== 'undefined' &&
typeof window.document !== 'undefined' &&
typeof window.document.createElement !== 'undefined'
? React.useLayoutEffect
: React.useEffect
export const _LocaleContainer = (props:any) => {
const initLocale = getLocale();
const [locale, setLocale] = React.useState(initLocale);
const [intl, setContainerIntl] = React.useState(() => getIntl(locale, true));
const handleLangChange = (locale:string) => {
if (moment?.locale) {
moment.locale(localeInfo[locale]?.momentLocale || 'en');
}
setLocale(locale);
setContainerIntl(getIntl(locale));
};
useIsomorphicLayoutEffect(() => {
event.on(LANG_CHANGE_EVENT, handleLangChange);
return () => {
event.off(LANG_CHANGE_EVENT, handleLangChange);
};
}, []);
const defaultAntdLocale = {
}
const direction = getDirection();
return (
<ConfigProvider direction={direction} locale={localeInfo[locale]?.antd || defaultAntdLocale}>
<RawIntlProvider value={intl}>{props.children}</RawIntlProvider>
</ConfigProvider>
)
};

View File

@@ -0,0 +1,350 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import {
createIntl,
IntlShape,
MessageDescriptor,
} from '/Users/eric/Desktop/city-admin/node_modules/react-intl';
import { getPluginManager } from '../core/plugin';
import EventEmitter from '/Users/eric/Desktop/city-admin/node_modules/event-emitter';
// @ts-ignore
import warning from '/Users/eric/Desktop/city-admin/node_modules/@umijs/plugins/node_modules/warning';
export {
createIntl,
};
export {
FormattedDate,
FormattedDateParts,
FormattedDisplayName,
FormattedHTMLMessage,
FormattedList,
FormattedMessage,
FormattedNumber,
FormattedNumberParts,
FormattedPlural,
FormattedRelativeTime,
FormattedTime,
FormattedTimeParts,
IntlContext,
IntlProvider,
RawIntlProvider,
createIntlCache,
defineMessages,
injectIntl,
useIntl,
} from '/Users/eric/Desktop/city-admin/node_modules/react-intl';
let g_intl: IntlShape;
const useLocalStorage = true;
// @ts-ignore
export const event = new EventEmitter();
export const LANG_CHANGE_EVENT = Symbol('LANG_CHANGE');
import bnBD0 from 'antd/es/locale/bn_BD';
import lang_bnBD0 from "/Users/eric/Desktop/city-admin/src/locales/bn-BD.ts";
import enUS0 from 'antd/es/locale/en_US';
import lang_enUS0 from "/Users/eric/Desktop/city-admin/src/locales/en-US.ts";
import faIR0 from 'antd/es/locale/fa_IR';
import lang_faIR0 from "/Users/eric/Desktop/city-admin/src/locales/fa-IR.ts";
import idID0 from 'antd/es/locale/id_ID';
import lang_idID0 from "/Users/eric/Desktop/city-admin/src/locales/id-ID.ts";
import jaJP0 from 'antd/es/locale/ja_JP';
import lang_jaJP0 from "/Users/eric/Desktop/city-admin/src/locales/ja-JP.ts";
import ptBR0 from 'antd/es/locale/pt_BR';
import lang_ptBR0 from "/Users/eric/Desktop/city-admin/src/locales/pt-BR.ts";
import zhCN0 from 'antd/es/locale/zh_CN';
import lang_zhCN0 from "/Users/eric/Desktop/city-admin/src/locales/zh-CN.ts";
import zhTW0 from 'antd/es/locale/zh_TW';
import lang_zhTW0 from "/Users/eric/Desktop/city-admin/src/locales/zh-TW.ts";
export const localeInfo: {[key: string]: any} = {
'bn-BD': {
messages: {
...lang_bnBD0,
},
locale: 'bn-BD',
antd: {
...bnBD0,
},
momentLocale: 'bn-bd',
},
'en-US': {
messages: {
...lang_enUS0,
},
locale: 'en-US',
antd: {
...enUS0,
},
momentLocale: '',
},
'fa-IR': {
messages: {
...lang_faIR0,
},
locale: 'fa-IR',
antd: {
...faIR0,
},
momentLocale: 'fa',
},
'id-ID': {
messages: {
...lang_idID0,
},
locale: 'id-ID',
antd: {
...idID0,
},
momentLocale: 'id',
},
'ja-JP': {
messages: {
...lang_jaJP0,
},
locale: 'ja-JP',
antd: {
...jaJP0,
},
momentLocale: 'ja',
},
'pt-BR': {
messages: {
...lang_ptBR0,
},
locale: 'pt-BR',
antd: {
...ptBR0,
},
momentLocale: 'pt-br',
},
'zh-CN': {
messages: {
...lang_zhCN0,
},
locale: 'zh-CN',
antd: {
...zhCN0,
},
momentLocale: 'zh-cn',
},
'zh-TW': {
messages: {
...lang_zhTW0,
},
locale: 'zh-TW',
antd: {
...zhTW0,
},
momentLocale: 'zh-tw',
},
};
/**
* 增加一个新的国际化语言
* @param name 语言的 key
* @param messages 对应的枚举对象
* @param extraLocales momentLocale, antd 国际化
*/
export const addLocale = (
name: string,
messages: Object,
extraLocales: {
momentLocale:string;
antd:string
},
) => {
if (!name) {
return;
}
// 可以合并
const mergeMessages = localeInfo[name]?.messages
? Object.assign({}, localeInfo[name].messages, messages)
: messages;
const { momentLocale, antd } = extraLocales || {};
const locale = name.split('-')?.join('-')
localeInfo[name] = {
messages: mergeMessages,
locale,
momentLocale: momentLocale,
antd,
};
// 如果这是的 name 和当前的locale 相同需要重新设置一下,不然更新不了
if (locale === getLocale()) {
event.emit(LANG_CHANGE_EVENT, locale);
}
};
/**
* 获取当前的 intl 对象,可以在 node 中使用
* @param locale 需要切换的语言类型
* @param changeIntl 是否不使用 g_intl
* @returns IntlShape
*/
export const getIntl = (locale?: string, changeIntl?: boolean) => {
// 如果全局的 g_intl 存在,且不是 setIntl 调用
if (g_intl && !changeIntl && !locale) {
return g_intl;
}
// 获取当前 locale
if (!locale) locale = getLocale();
// 如果存在于 localeInfo 中
if (locale&&localeInfo[locale]) {
return createIntl(localeInfo[locale]);
}
// 不存在需要一个报错提醒
warning(
!locale||!!localeInfo[locale],
`The current popular language does not exist, please check the locales folder!`,
);
// 使用 zh-CN
if (localeInfo["zh-CN"]) return createIntl(localeInfo["zh-CN"]);
// 如果还没有,返回一个空的
return createIntl({
locale: "zh-CN",
messages: {},
});
};
/**
* 切换全局的 intl 的设置
* @param locale 语言的key
*/
export const setIntl = (locale: string) => {
g_intl = getIntl(locale, true);
};
/**
* 获取当前选择的语言
* @returns string
*/
export const getLocale = () => {
const runtimeLocale = getPluginManager().applyPlugins({
key: 'locale',
// workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
type: 'modify',
initialValue: {},
});
// runtime getLocale for user define
if (typeof runtimeLocale?.getLocale === 'function') {
return runtimeLocale.getLocale();
}
// please clear localStorage if you change the baseSeparator config
// because changing will break the app
const lang =
navigator.cookieEnabled && typeof localStorage !== 'undefined' && useLocalStorage
? window.localStorage.getItem('umi_locale')
: '';
// support baseNavigator, default true
let browserLang;
const isNavigatorLanguageValid =
typeof navigator !== 'undefined' && typeof navigator.language === 'string';
browserLang = isNavigatorLanguageValid
? navigator.language.split('-').join('-')
: '';
return lang || browserLang || "zh-CN";
};
/**
* 获取当前选择的方向
* @returns string
*/
export const getDirection = () => {
const lang = getLocale();
// array with all prefixs for rtl langueges ex: ar-EG , he-IL
const rtlLangs = ['he', 'ar', 'fa', 'ku']
const direction = rtlLangs.filter(lng => lang.startsWith(lng)).length ? 'rtl' : 'ltr';
return direction;
};
/**
* 切换语言
* @param lang 语言的 key
* @param realReload 是否刷新页面,默认刷新
* @returns string
*/
export const setLocale = (lang: string, realReload: boolean = true) => {
//const { pluginManager } = useAppContext();
//const runtimeLocale = pluginManagerapplyPlugins({
// key: 'locale',
// workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
// type: 'modify',
// initialValue: {},
//});
const updater = () => {
if (getLocale() !== lang) {
if (navigator.cookieEnabled && typeof window.localStorage !== 'undefined' && useLocalStorage) {
window.localStorage.setItem('umi_locale', lang || '');
}
setIntl(lang);
if (realReload) {
window.location.reload();
} else {
event.emit(LANG_CHANGE_EVENT, lang);
// chrome 不支持这个事件。所以人肉触发一下
if (window.dispatchEvent) {
const event = new Event('languagechange');
window.dispatchEvent(event);
}
}
}
}
//if (typeof runtimeLocale?.setLocale === 'function') {
// runtimeLocale.setLocale({
// lang,
// realReload,
// updater: updater,
// });
// return;
//}
updater();
};
let firstWaring = true;
/**
* intl.formatMessage 的语法糖
* @deprecated 使用此 api 会造成切换语言的时候无法自动刷新,请使用 useIntl 或 injectIntl
* @param descriptor { id : string, defaultMessage : string }
* @param values { [key:string] : string }
* @returns string
*/
export const formatMessage: IntlShape['formatMessage'] = (
descriptor: MessageDescriptor,
values: any,
) => {
if (firstWaring) {
warning(
false,
`Using this API will cause automatic refresh when switching languages, please use useIntl or injectIntl.
使用此 api 会造成切换语言的时候无法自动刷新,请使用 useIntl 或 injectIntl。
http://j.mp/37Fkd5Q
`,
);
firstWaring = false;
}
if (!g_intl) {
setIntl(getLocale());
}
return g_intl.formatMessage(descriptor, values);
};
/**
* 获取语言列表
* @returns string[]
*/
export const getAllLocales = () => Object.keys(localeInfo);

View File

@@ -0,0 +1,9 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
// @ts-ignore
import { _LocaleContainer } from './locale';
export function i18nProvider(container: Element) {
return React.createElement(_LocaleContainer, null, container);
}

View File

@@ -0,0 +1,181 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
// @ts-ignore
import type { models as rawModels } from '@@/plugin-model/model';
import isEqual from '/Users/eric/Desktop/city-admin/node_modules/fast-deep-equal/index.js';
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
type Models = typeof rawModels;
type GetNamespaces<M> = {
[K in keyof M]: M[K] extends { namespace: string }
? M[K]['namespace']
: never;
}[keyof M];
type Namespaces = GetNamespaces<Models>;
// @ts-ignore
const Context = React.createContext<{ dispatcher: Dispatcher }>(null);
class Dispatcher {
callbacks: Record<Namespaces, Set<Function>> = {};
data: Record<Namespaces, unknown> = {};
update = (namespace: Namespaces) => {
if (this.callbacks[namespace]) {
this.callbacks[namespace].forEach((cb) => {
try {
const data = this.data[namespace];
cb(data);
} catch (e) {
cb(undefined);
}
});
}
};
}
interface ExecutorProps {
hook: () => any;
onUpdate: (val: any) => void;
namespace: string;
}
function Executor(props: ExecutorProps) {
const { hook, onUpdate, namespace } = props;
const updateRef = useRef(onUpdate);
const initialLoad = useRef(false);
let data: any;
try {
data = hook();
} catch (e) {
console.error(
`plugin-model: Invoking '${namespace || 'unknown'}' model failed:`,
e,
);
}
// 首次执行时立刻返回初始值
useMemo(() => {
updateRef.current(data);
}, []);
// React 16.13 后 update 函数用 useEffect 包裹
useEffect(() => {
if (initialLoad.current) {
updateRef.current(data);
} else {
initialLoad.current = true;
}
});
return null;
}
const dispatcher = new Dispatcher();
export function Provider(props: {
models: Record<string, any>;
children: React.ReactNode;
}) {
return (
<Context.Provider value={{ dispatcher }}>
{Object.keys(props.models).map((namespace) => {
return (
<Executor
key={namespace}
hook={props.models[namespace]}
namespace={namespace}
onUpdate={(val) => {
dispatcher.data[namespace] = val;
dispatcher.update(namespace);
}}
/>
);
})}
{props.children}
</Context.Provider>
);
}
type GetModelByNamespace<M, N> = {
[K in keyof M]: M[K] extends { namespace: string; model: unknown }
? M[K]['namespace'] extends N
? M[K]['model'] extends (...args: any) => any
? ReturnType<M[K]['model']>
: never
: never
: never;
}[keyof M];
type Model<N> = GetModelByNamespace<Models, N>;
type Selector<N, S> = (model: Model<N>) => S;
type SelectedModel<N, T> = T extends (...args: any) => any
? ReturnType<NonNullable<T>>
: Model<N>;
export function useModel<N extends Namespaces>(namespace: N): Model<N>;
export function useModel<N extends Namespaces, S>(
namespace: N,
selector: Selector<N, S>,
): SelectedModel<N, typeof selector>;
export function useModel<N extends Namespaces, S>(
namespace: N,
selector?: Selector<N, S>,
): SelectedModel<N, typeof selector> {
const { dispatcher } = useContext<{ dispatcher: Dispatcher }>(Context);
const selectorRef = useRef(selector);
selectorRef.current = selector;
const [state, setState] = useState(() =>
selectorRef.current
? selectorRef.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 = (data: any) => {
if (!isMount.current) {
// 如果 handler 执行过程中,组件被卸载了,则强制更新全局 data
// TODO: 需要加个 example 测试
setTimeout(() => {
dispatcher.data[namespace] = data;
dispatcher.update(namespace);
});
} else {
const currentState = selectorRef.current
? selectorRef.current(data)
: data;
const previousState = stateRef.current;
if (!isEqual(currentState, previousState)) {
setState(currentState);
}
}
};
dispatcher.callbacks[namespace] ||= new Set() as any; // rawModels 是 umi 动态生成的文件,导致前面 callback[namespace] 的类型无法推导出来,所以用 as any 来忽略掉
dispatcher.callbacks[namespace].add(handler);
dispatcher.update(namespace);
return () => {
dispatcher.callbacks[namespace].delete(handler);
};
}, [namespace]);
return state;
}

View File

@@ -0,0 +1,8 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import model_1 from '/Users/eric/Desktop/city-admin/src/.umi/plugin-initialState/@@initialState';
export const models = {
model_1: { namespace: '@@initialState', model: model_1 },
} as const

View File

@@ -0,0 +1,20 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React from 'react';
import { Provider } from './';
import { models as rawModels } from './model';
function ProviderWrapper(props: any) {
const models = React.useMemo(() => {
return Object.keys(rawModels).reduce((memo, key) => {
memo[rawModels[key].namespace] = rawModels[key].model;
return memo;
}, {});
}, []);
return <Provider models={models} {...props}>{ props.children }</Provider>
}
export function dataflowProvider(container, opts) {
return <ProviderWrapper {...opts}>{ container }</ProviderWrapper>;
}

View File

@@ -0,0 +1,39 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import { useEffect, useState } from 'react';
import { SwaggerUIBundle } from 'swagger-ui-dist';
import 'swagger-ui-dist/swagger-ui.css';
const App = () => {
const [value, setValue] = useState("openapi" );
useEffect(() => {
SwaggerUIBundle({
url: `/umi-plugins_${value}.json`,
dom_id: '#swagger-ui',
});
}, [value]);
return (
<div
style={{
padding: 24,
}}
>
<select
style={{
position: "fixed",
right: "16px",
top: "8px",
}}
onChange={(e) => setValue(e.target.value)}
>
<option value="openapi">openapi</option>
<option value="swagger">swagger</option>
</select>
<div id="swagger-ui" />
</div>
);
};
export default App;

View File

@@ -0,0 +1,9 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
export {
useRequest,
UseRequestProvider,
request,
getRequestInstance,
} from './request';

View File

@@ -0,0 +1,265 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import axios, {
type AxiosInstance,
type AxiosRequestConfig,
type AxiosResponse,
type AxiosError,
} from '/Users/eric/Desktop/city-admin/node_modules/axios';
import useUmiRequest, { UseRequestProvider } from '/Users/eric/Desktop/city-admin/node_modules/@ahooksjs/use-request';
import { ApplyPluginsType } from 'umi';
import { getPluginManager } from '../core/plugin';
import {
BaseOptions,
BasePaginatedOptions,
BaseResult,
CombineService,
LoadMoreFormatReturn,
LoadMoreOptions,
LoadMoreOptionsWithFormat,
LoadMoreParams,
LoadMoreResult,
OptionsWithFormat,
PaginatedFormatReturn,
PaginatedOptionsWithFormat,
PaginatedParams,
PaginatedResult,
} from '/Users/eric/Desktop/city-admin/node_modules/@ahooksjs/use-request/es/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,
});
}
// request 方法 opts 参数的接口
interface IRequestOptions extends AxiosRequestConfig {
skipErrorHandler?: boolean;
requestInterceptors?: IRequestInterceptorTuple[];
responseInterceptors?: IResponseInterceptorTuple[];
[key: string]: any;
}
interface IRequestOptionsWithResponse extends IRequestOptions {
getResponse: true;
}
interface IRequestOptionsWithoutResponse extends IRequestOptions{
getResponse: false;
}
interface IRequest{
<T = any>(url: string, opts: IRequestOptionsWithResponse): Promise<AxiosResponse<T>>;
<T = any>(url: string, opts: IRequestOptionsWithoutResponse): Promise<T>;
<T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse 默认是 false 因此不提供该参数时,只返回 data
<T = any>(url: string): Promise<T>; // 不提供 opts 时,默认使用 'GET' method并且默认返回 data
}
type RequestError = AxiosError | Error
interface IErrorHandler {
(error: RequestError, opts: IRequestOptions): void;
}
type IRequestInterceptorAxios = (config: RequestOptions) => RequestOptions;
type IRequestInterceptorUmiRequest = (url: string, config : RequestOptions) => { url: string, options: RequestOptions };
type IRequestInterceptor = IRequestInterceptorAxios | IRequestInterceptorUmiRequest;
type IErrorInterceptor = (error: Error) => Promise<Error>;
type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosResponse<T> ;
type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
type IResponseInterceptorTuple = [IResponseInterceptor, IErrorInterceptor] | [IResponseInterceptor] | IResponseInterceptor
export interface RequestConfig<T = any> extends AxiosRequestConfig {
errorConfig?: {
errorHandler?: IErrorHandler;
errorThrower?: ( res: T ) => void
};
requestInterceptors?: IRequestInterceptorTuple[];
responseInterceptors?: IResponseInterceptorTuple[];
}
let requestInstance: AxiosInstance;
let config: RequestConfig;
const getConfig = (): RequestConfig => {
if (config) return config;
config = getPluginManager().applyPlugins({
key: 'request',
type: ApplyPluginsType.modify,
initialValue: {},
});
return config;
};
const getRequestInstance = (): AxiosInstance => {
if (requestInstance) return requestInstance;
const config = getConfig();
requestInstance = axios.create(config);
config?.requestInterceptors?.forEach((interceptor) => {
if(interceptor instanceof Array){
requestInstance.interceptors.request.use((config) => {
const { url } = config;
if(interceptor[0].length === 2){
const { url: newUrl, options } = interceptor[0](url, config);
return { ...options, url: newUrl };
}
return interceptor[0](config);
}, interceptor[1]);
} else {
requestInstance.interceptors.request.use((config) => {
const { url } = config;
if(interceptor.length === 2){
const { url: newUrl, options } = interceptor(url, config);
return { ...options, url: newUrl };
}
return interceptor(config);
})
}
});
config?.responseInterceptors?.forEach((interceptor) => {
interceptor instanceof Array ?
requestInstance.interceptors.response.use(interceptor[0], interceptor[1]):
requestInstance.interceptors.response.use(interceptor);
});
// 当响应的数据 success 是 false 的时候,抛出 error 以供 errorHandler 处理。
requestInstance.interceptors.response.use((response) => {
const { data } = response;
if(data?.success === false && config?.errorConfig?.errorThrower){
config.errorConfig.errorThrower(data);
}
return response;
})
return requestInstance;
};
const request: IRequest = (url: string, opts: any = { method: 'GET' }) => {
const requestInstance = getRequestInstance();
const config = getConfig();
const { getResponse = false, requestInterceptors, responseInterceptors } = opts;
const requestInterceptorsToEject = requestInterceptors?.map((interceptor) => {
if(interceptor instanceof Array){
return requestInstance.interceptors.request.use((config) => {
const { url } = config;
if(interceptor[0].length === 2){
const { url: newUrl, options } = interceptor[0](url, config);
return { ...options, url: newUrl };
}
return interceptor[0](config);
}, interceptor[1]);
} else {
return requestInstance.interceptors.request.use((config) => {
const { url } = config;
if(interceptor.length === 2){
const { url: newUrl, options } = interceptor(url, config);
return { ...options, url: newUrl };
}
return interceptor(config);
})
}
});
const responseInterceptorsToEject = responseInterceptors?.map((interceptor) => {
return interceptor instanceof Array ?
requestInstance.interceptors.response.use(interceptor[0], interceptor[1]):
requestInstance.interceptors.response.use(interceptor);
});
return new Promise((resolve, reject)=>{
requestInstance
.request({...opts, url})
.then((res)=>{
requestInterceptorsToEject?.forEach((interceptor) => {
requestInstance.interceptors.request.eject(interceptor);
});
responseInterceptorsToEject?.forEach((interceptor) => {
requestInstance.interceptors.response.eject(interceptor);
});
resolve(getResponse ? res : res.data);
})
.catch((error)=>{
requestInterceptorsToEject?.forEach((interceptor) => {
requestInstance.interceptors.request.eject(interceptor);
});
responseInterceptorsToEject?.forEach((interceptor) => {
requestInstance.interceptors.response.eject(interceptor);
});
try {
const handler =
config?.errorConfig?.errorHandler;
if(handler)
handler(error, opts, config);
} catch (e) {
reject(e);
}
reject(error);
})
})
}
export {
useRequest,
UseRequestProvider,
request,
getRequestInstance,
};
export type {
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
AxiosError,
RequestError,
IResponseInterceptor as ResponseInterceptor,
IRequestOptions as RequestOptions,
IRequest as Request,
};

View File

@@ -0,0 +1,6 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import type { RequestConfig } from './types.d'
export type IRuntimeConfig = {
request?: RequestConfig
};

10
src/.umi/plugin-request/types.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
export type {
RequestConfig,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
AxiosError,
RequestError,
ResponseInterceptor } from './request';

View File

@@ -0,0 +1,11 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
export {
proxy, useSnapshot, snapshot, subscribe,
proxyWithComputed,
proxyWithHistory,
proxyWithDevtools,
proxyMap,
proxySet,
} from '/Users/eric/Desktop/city-admin/node_modules/@umijs/valtio';

84
src/.umi/testBrowser.tsx Normal file
View File

@@ -0,0 +1,84 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import React, { useEffect, useState } from 'react';
import { ApplyPluginsType } from 'umi';
import { renderClient, RenderClientOpts } from '/Users/eric/Desktop/city-admin/node_modules/@umijs/preset-umi/node_modules/@umijs/renderer-react';
import { createHistory } from './core/history';
import { createPluginManager } from './core/plugin';
import { getRoutes } from './core/route';
import type { Location } from 'history';
import './core/polyfill';
import '/Users/eric/Desktop/city-admin/src/global.less';
import '/Users/eric/Desktop/city-admin/src/global.tsx';
import 'antd/dist/antd.less';
const publicPath = '/';
const runtimePublicPath = false;
type TestBrowserProps = {
location?: Partial<Location>;
historyRef?: React.MutableRefObject<Location>;
};
export function TestBrowser(props: TestBrowserProps) {
const pluginManager = createPluginManager();
const [context, setContext] = useState<RenderClientOpts | undefined>(
undefined
);
useEffect(() => {
const genContext = async () => {
const { routes, routeComponents } = await getRoutes(pluginManager);
// allow user to extend routes
await pluginManager.applyPlugins({
key: 'patchRoutes',
type: ApplyPluginsType.event,
args: {
routes,
routeComponents,
},
});
const contextOpts = pluginManager.applyPlugins({
key: 'modifyContextOpts',
type: ApplyPluginsType.modify,
initialValue: {},
});
const basename = contextOpts.basename || '/';
const history = createHistory({
type: 'memory',
basename,
});
return {
routes,
routeComponents,
pluginManager,
rootElement: contextOpts.rootElement || document.getElementById('root'),
publicPath,
runtimePublicPath,
history,
basename,
components: true,
};
};
genContext().then((context) => {
setContext(context);
if (props.location) {
context?.history?.push(props.location);
}
if (props.historyRef) {
props.historyRef.current = context?.history;
}
});
}, []);
if (context === undefined) {
return <div id="loading" />;
}
const Children = renderClient(context);
return (
<React.Fragment>
<Children />
</React.Fragment>
);
}

35
src/.umi/tsconfig.json Normal file
View File

@@ -0,0 +1,35 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"jsx": "react-jsx",
"esModuleInterop": true,
"sourceMap": true,
"baseUrl": "../../",
"strict": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"paths": {
"@/*": [
"src/*"
],
"@@/*": [
"src/.umi/*"
],
"@umijs/max": [
"/Users/eric/Desktop/city-admin/node_modules/umi"
],
"@umijs/max/typings": [
"src/.umi/typings"
]
}
},
"include": [
"../../.umirc.ts",
"../../**/*.d.ts",
"../../**/*.ts",
"../../**/*.tsx"
]
}

136
src/.umi/typings.d.ts vendored Normal file
View File

@@ -0,0 +1,136 @@
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
type CSSModuleClasses = { readonly [key: string]: string }
declare module '*.css' {
const classes: CSSModuleClasses
export default classes
}
declare module '*.scss' {
const classes: CSSModuleClasses
export default classes
}
declare module '*.sass' {
const classes: CSSModuleClasses
export default classes
}
declare module '*.less' {
const classes: CSSModuleClasses
export default classes
}
declare module '*.styl' {
const classes: CSSModuleClasses
export default classes
}
declare module '*.stylus' {
const classes: CSSModuleClasses
export default classes
}
// images
declare module '*.jpg' {
const src: string
export default src
}
declare module '*.jpeg' {
const src: string
export default src
}
declare module '*.png' {
const src: string
export default src
}
declare module '*.gif' {
const src: string
export default src
}
declare module '*.svg' {
import * as React from 'react';
export const ReactComponent: React.FunctionComponent<React.SVGProps<
SVGSVGElement
> & { title?: string }>;
const src: string
export default src
}
declare module '*.ico' {
const src: string
export default src
}
declare module '*.webp' {
const src: string
export default src
}
declare module '*.avif' {
const src: string
export default src
}
// media
declare module '*.mp4' {
const src: string
export default src
}
declare module '*.webm' {
const src: string
export default src
}
declare module '*.ogg' {
const src: string
export default src
}
declare module '*.mp3' {
const src: string
export default src
}
declare module '*.wav' {
const src: string
export default src
}
declare module '*.flac' {
const src: string
export default src
}
declare module '*.aac' {
const src: string
export default src
}
// fonts
declare module '*.woff' {
const src: string
export default src
}
declare module '*.woff2' {
const src: string
export default src
}
declare module '*.eot' {
const src: string
export default src
}
declare module '*.ttf' {
const src: string
export default src
}
declare module '*.otf' {
const src: string
export default src
}
// other
declare module '*.wasm' {
const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>
export default initWasm
}
declare module '*.webmanifest' {
const src: string
export default src
}
declare module '*.pdf' {
const src: string
export default src
}
declare module '*.txt' {
const src: string
export default src
}

62
src/.umi/umi.ts Normal file
View File

@@ -0,0 +1,62 @@
// @ts-nocheck
// This file is generated by Umi automatically
// DO NOT CHANGE IT MANUALLY!
import './core/polyfill';
import '/Users/eric/Desktop/city-admin/src/global.less';
import '/Users/eric/Desktop/city-admin/src/global.tsx';
import 'antd/dist/antd.less';
import { renderClient } from '/Users/eric/Desktop/city-admin/node_modules/@umijs/preset-umi/node_modules/@umijs/renderer-react';
import { getRoutes } from './core/route';
import { createPluginManager } from './core/plugin';
import { createHistory } from './core/history';
import { ApplyPluginsType } from 'umi';
const publicPath = "/";
const runtimePublicPath = false;
async function render() {
const pluginManager = createPluginManager();
const { routes, routeComponents } = await getRoutes(pluginManager);
// allow user to extend routes
await pluginManager.applyPlugins({
key: 'patchRoutes',
type: ApplyPluginsType.event,
args: {
routes,
routeComponents,
},
});
return (pluginManager.applyPlugins({
key: 'render',
type: ApplyPluginsType.compose,
initialValue() {
const contextOpts = pluginManager.applyPlugins({
key: 'modifyContextOpts',
type: ApplyPluginsType.modify,
initialValue: {},
});
const basename = contextOpts.basename || '/';
const context = {
routes,
routeComponents,
pluginManager,
rootElement: contextOpts.rootElement || document.getElementById('root'),
publicPath,
runtimePublicPath,
history: createHistory({
type: contextOpts.historyType || 'browser',
basename,
...contextOpts.historyOpts,
}),
basename,
};
return renderClient(context);
},
}))();
}
render();

View File

220
src/pages/cityNew/index.tsx Normal file
View File

@@ -0,0 +1,220 @@
import { EllipsisOutlined, PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable, TableDropdown } from '@ant-design/pro-components';
import { Button, Dropdown, Space, Tag } from 'antd';
import { useRef } from 'react';
import request from 'umi-request';
type GithubIssueItem = {
url: string;
id: number;
number: number;
title: string;
labels: {
name: string;
color: string;
}[];
state: string;
comments: number;
created_at: string;
updated_at: string;
closed_at?: string;
};
const columns: ProColumns<GithubIssueItem>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '标题',
dataIndex: 'title',
copyable: true,
ellipsis: true,
tip: '标题过长会自动收缩',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
disable: true,
title: '状态',
dataIndex: 'state',
filters: true,
onFilter: true,
ellipsis: true,
valueType: 'select',
valueEnum: {
all: { text: '超长'.repeat(50) },
open: {
text: '未解决',
status: 'Error',
},
closed: {
text: '已解决',
status: 'Success',
disabled: true,
},
processing: {
text: '解决中',
status: 'Processing',
},
},
},
{
disable: true,
title: '标签',
dataIndex: 'labels',
search: false,
renderFormItem: (_, { defaultRender }) => {
return defaultRender(_);
},
render: (_, record) => (
<Space>
{record.labels.map(({ name, color }) => (
<Tag color={color} key={name}>
{name}
</Tag>
))}
</Space>
),
},
{
title: '创建时间',
key: 'showTime',
dataIndex: 'created_at',
valueType: 'date',
sorter: true,
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'created_at',
valueType: 'dateRange',
hideInTable: true,
search: {
transform: (value) => {
return {
startTime: value[0],
endTime: value[1],
};
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
render: (text, record, _, action) => [
<a
key="editable"
onClick={() => {
action?.startEditable?.(record.id);
}}
>
</a>,
<a href={record.url} target="_blank" rel="noopener noreferrer" key="view">
</a>,
<TableDropdown
key="actionGroup"
onSelect={() => action?.reload()}
menus={[
{ key: 'copy', name: '复制' },
{ key: 'delete', name: '删除' },
]}
/>,
],
},
];
export default () => {
const actionRef = useRef<ActionType>();
return (
<ProTable<GithubIssueItem>
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params = {}, sort, filter) => {
console.log(sort, filter);
return request<{
data: GithubIssueItem[];
}>('https://proapi.azurewebsites.net/github/issues', {
params,
});
}}
editable={{
type: 'multiple',
}}
columnsState={{
persistenceKey: 'pro-table-singe-demos',
persistenceType: 'localStorage',
onChange(value) {
console.log('value: ', value);
},
}}
rowKey="id"
search={{
labelWidth: 'auto',
}}
options={{
setting: {
listsHeight: 400,
},
}}
form={{
// 由于配置了 transform提交的参与与定义的不同这里需要转化一下
syncToUrl: (values, type) => {
if (type === 'get') {
return {
...values,
created_at: [values.startTime, values.endTime],
};
}
return values;
},
}}
pagination={{
pageSize: 5,
onChange: (page) => console.log(page),
}}
dateFormatter="string"
headerTitle="高级表格"
toolBarRender={() => [
<Button key="button" icon={<PlusOutlined />} type="primary">
</Button>,
<Dropdown
key="menu"
menu={{
items: [
{
label: '1st item',
key: '1',
},
{
label: '2nd item',
key: '1',
},
{
label: '3rd item',
key: '1',
},
],
}}
>
<Button>
<EllipsisOutlined />
</Button>
</Dropdown>,
]}
/>
);
};

14797
yarn.lock Normal file

File diff suppressed because it is too large Load Diff