@creekjs/umi-plugins 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/creek-layout/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,YAAY,CAAC;8BA8E7C,IAAI;AAAzB,wBAiIE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/creek-layout/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,YAAY,CAAC;8BA8E7C,IAAI;AAAzB,wBA2IE"}
@@ -86,7 +86,8 @@ var getIconsInfoForRoutes = (api) => {
86
86
  var creek_layout_default = (api) => {
87
87
  const TEMPLATE_DIR = (0, import_path.join)(__dirname, "template");
88
88
  const creekWebComponentsPath = (0, import_plugin_utils.winPath)(getPkgPath(api, "@creekjs/web-components"));
89
- const creekIconPath = require.resolve(`${creekWebComponentsPath}/dist/creek-icon`);
89
+ const isMonorepo = (0, import_fs.existsSync)((0, import_path.join)(creekWebComponentsPath, "src"));
90
+ const creekIconPath = isMonorepo ? (0, import_plugin_utils.winPath)((0, import_path.join)(creekWebComponentsPath, "src", "creek-icon")) : require.resolve(`${creekWebComponentsPath}/dist/creek-icon`);
90
91
  api.describe({
91
92
  key: "creekLayout",
92
93
  config: {
@@ -110,15 +111,16 @@ var creek_layout_default = (api) => {
110
111
  });
111
112
  api.modifyConfig((memo) => {
112
113
  const name = require(`${creekWebComponentsPath}/package.json`).name;
113
- memo.alias[name] = creekWebComponentsPath;
114
+ memo.alias[name] = isMonorepo ? (0, import_plugin_utils.winPath)((0, import_path.join)(creekWebComponentsPath, "src")) : creekWebComponentsPath;
114
115
  const routes = memo.routes;
115
116
  const hasNotFoundPage = routes == null ? void 0 : routes.find((item) => [item.name, item.path].includes("404"));
117
+ const notFoundComponentPath = isMonorepo ? (0, import_plugin_utils.winPath)((0, import_path.join)(creekWebComponentsPath, "src", "creek-layout", "Exception", "NotFoundPage.tsx")) : require.resolve(`${creekWebComponentsPath}/dist/creek-layout/Exception/NotFoundPage`);
116
118
  const defaultRoutes = [
117
119
  {
118
120
  name: "404",
119
121
  path: "*",
120
122
  hideInMenu: true,
121
- component: require.resolve(`${creekWebComponentsPath}/dist/creek-layout/Exception/NotFoundPage`)
123
+ component: notFoundComponentPath
122
124
  }
123
125
  ];
124
126
  if (!hasNotFoundPage) {
@@ -132,11 +134,12 @@ var creek_layout_default = (api) => {
132
134
  const hasLocalePlugin = !!api.config.locale;
133
135
  const iconsInfo = getIconsInfoForRoutes(api);
134
136
  const iconFontCNs = Array.isArray((_a = api.userConfig.creekLayout) == null ? void 0 : _a.iconFontCNs) ? (_b = api.userConfig.creekLayout) == null ? void 0 : _b.iconFontCNs : [];
137
+ const importPath = isMonorepo ? (0, import_plugin_utils.winPath)((0, import_path.join)(creekWebComponentsPath, "src")) : creekWebComponentsPath;
135
138
  api.writeTmpFile({
136
139
  path: "Layout.tsx",
137
140
  tplPath: (0, import_path.join)(TEMPLATE_DIR, "/layout.tpl"),
138
141
  context: {
139
- creekWebComponentsPath,
142
+ creekWebComponentsPath: importPath,
140
143
  hasInitialStatePlugin,
141
144
  hasLocalePlugin,
142
145
  access: api.config.access,
@@ -148,7 +151,7 @@ var creek_layout_default = (api) => {
148
151
  path: "types.d.ts",
149
152
  tplPath: (0, import_path.join)(TEMPLATE_DIR, "/type.tpl"),
150
153
  context: {
151
- creekWebComponentsPath,
154
+ creekWebComponentsPath: importPath,
152
155
  hasInitialStatePlugin,
153
156
  access: api.config.access
154
157
  }
@@ -171,7 +174,7 @@ var creek_layout_default = (api) => {
171
174
  path: "runtime.tsx",
172
175
  tplPath: (0, import_path.join)(TEMPLATE_DIR, "/runtime.tpl"),
173
176
  context: {
174
- creekWebComponentsPath,
177
+ creekWebComponentsPath: importPath,
175
178
  hasIconFontCNs: iconFontCNs.length > 0,
176
179
  iconFontCNs: JSON.stringify(iconFontCNs)
177
180
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/creek-layout/index.tsx"],
4
- "sourcesContent": ["import { IApi, IRoute, RUNTIME_TYPE_FILE_NAME } from '@umijs/max';\nimport { lodash, winPath } from '@umijs/max/plugin-utils';\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\n\nimport { withTmpPath } from '../utils';\n\nconst getPkgHasDep = (api: IApi, depList: string[]) => {\n const hasDependency = (pkg: Record<string, any>, dep: string) => pkg.dependencies?.[dep] || pkg.devDependencies?.[dep];\n const { pkg } = api;\n return depList.find((dep) => hasDependency(pkg, dep));\n};\n\nconst getPkgPath = (api: IApi, pkgName: string, depList?: string[]) => {\n const _depList = depList && depList.length ? depList : [pkgName];\n const pkgHasDep = getPkgHasDep(api, _depList);\n\n if (pkgHasDep) {\n const nodeModulesPath = join(api.cwd, 'node_modules', pkgHasDep, 'package.json');\n\n if (existsSync(nodeModulesPath)) {\n return join(api.cwd, 'node_modules', pkgHasDep);\n }\n\n const cwd = process.cwd();\n if (api.cwd !== cwd) {\n const altNodeModulesPath = join(cwd, 'node_modules', pkgHasDep, 'package.json');\n if (existsSync(altNodeModulesPath)) {\n return join(cwd, 'node_modules', pkgHasDep);\n }\n }\n }\n\n // 如果项目中没有去找插件依赖的\n return dirname(require.resolve(`${pkgName}/package.json`));\n};\n\nconst getIconsInfoForRoutes = (api: IApi) => {\n // 获取所有 icons\n const antIconsPath = winPath(getPkgPath(api, '@ant-design/icons'));\n\n const getAllIcons = () => {\n // 读取 index.d.ts\n const iconTypePath = join(antIconsPath, './lib/icons/index.d.ts');\n const iconTypeContent = readFileSync(iconTypePath, 'utf-8');\n\n // 截取 default as ${iconName}, 然后获取 iconName 转换为 map\n return [...iconTypeContent.matchAll(/default as (\\w+)/g)].reduce((memo: Record<string, boolean>, cur) => {\n memo[cur[1]] = true;\n return memo;\n }, {});\n };\n\n const allIcons: Record<string, boolean> = getAllIcons();\n\n const iconsMap = Object.keys(api.appData.routes).reduce<Record<string, boolean>>((memo, id) => {\n const { icon } = api.appData.routes[id];\n if (icon) {\n const upperIcon = lodash.upperFirst(lodash.camelCase(icon));\n // @ts-ignore\n if (allIcons[upperIcon]) {\n memo[upperIcon] = true;\n }\n // @ts-ignore\n if (allIcons[`${upperIcon}Outlined`]) {\n memo[`${upperIcon}Outlined`] = true;\n }\n }\n return memo;\n }, {});\n const icons = Object.keys(iconsMap);\n\n return {\n icons,\n antIconsPath,\n };\n};\n\nexport default (api: IApi) => {\n const TEMPLATE_DIR = join(__dirname, 'template');\n\n const creekWebComponentsPath = winPath(getPkgPath(api, '@creekjs/web-components'));\n const creekIconPath = require.resolve(`${creekWebComponentsPath}/dist/creek-icon`);\n\n api.describe({\n key: 'creekLayout',\n config: {\n schema({ zod }) {\n return zod\n .object({\n title: zod.string(),\n iconFontCNs: zod.string().array(),\n })\n .partial();\n }, \n onChange: api.ConfigChangeType.regenerateTmpFiles,\n },\n enableBy: api.EnableBy.config,\n });\n\n api.modifyAppData((memo) => {\n const version = require(`${creekWebComponentsPath}/package.json`).version;\n memo.pluginLayout = {\n creekWebComponentsPath,\n version,\n };\n return memo;\n });\n\n // 新增404页面\n api.modifyConfig((memo) => {\n const name = require(`${creekWebComponentsPath}/package.json`).name;\n memo.alias[name] = creekWebComponentsPath;\n\n const routes = memo.routes as IRoute[];\n const hasNotFoundPage = routes?.find((item) => [item.name, item.path].includes('404'));\n const defaultRoutes = [\n {\n name: '404',\n path: '*',\n hideInMenu: true,\n component: require.resolve(`${creekWebComponentsPath}/dist/creek-layout/Exception/NotFoundPage`),\n },\n ];\n\n if (!hasNotFoundPage) {\n memo.routes = [...routes, ...defaultRoutes];\n }\n\n return memo;\n });\n\n api.onGenerateFiles(() => {\n const hasInitialStatePlugin = !!api.config.initialState;\n const hasLocalePlugin = !!api.config.locale;\n const iconsInfo = getIconsInfoForRoutes(api);\n\n const iconFontCNs = Array.isArray(api.userConfig.creekLayout?.iconFontCNs) ? api.userConfig.creekLayout?.iconFontCNs : [];\n\n api.writeTmpFile({\n path: 'Layout.tsx',\n tplPath: join(TEMPLATE_DIR, '/layout.tpl'),\n context: {\n creekWebComponentsPath,\n hasInitialStatePlugin,\n hasLocalePlugin,\n access: api.config.access,\n creekLocaleConfig: api.config.creekLocaleConfig ? JSON.stringify(api.config.glocale, null, 2) : 'undefined',\n userConfig: JSON.stringify(api.config.creekLayout, null, 2),\n },\n });\n // 写入类型, RunTimeLayoutConfig 是 app.tsx 中 layout 配置的类型\n api.writeTmpFile({\n path: 'types.d.ts',\n tplPath: join(TEMPLATE_DIR, '/type.tpl'),\n context: {\n creekWebComponentsPath,\n hasInitialStatePlugin,\n access: api.config.access,\n },\n });\n\n api.writeTmpFile({\n path: RUNTIME_TYPE_FILE_NAME,\n tplPath: join(TEMPLATE_DIR, '/runtime-config.type.tpl'),\n context: {},\n });\n\n api.writeTmpFile({\n path: 'icons.tsx',\n tplPath: join(TEMPLATE_DIR, '/icons.tpl'),\n context: {\n icons: iconsInfo.icons,\n antIconsPath: iconsInfo.antIconsPath,\n creekIconPath,\n },\n });\n\n // runtime.tsx\n api.writeTmpFile({\n path: 'runtime.tsx',\n tplPath: join(TEMPLATE_DIR, '/runtime.tpl'),\n context: {\n creekWebComponentsPath,\n hasIconFontCNs: iconFontCNs.length > 0,\n iconFontCNs: JSON.stringify(iconFontCNs),\n },\n });\n });\n\n api.addLayouts(() => {\n return [\n {\n id: 'ant-design-pro-layout',\n file: withTmpPath({ api, path: 'Layout.tsx' }),\n test: (route: any) => {\n return route.layout !== false;\n },\n },\n ];\n });\n\n api.addRuntimePluginKey(() => ['layout']);\n\n api.addRuntimePlugin(() => {\n return [withTmpPath({ api, path: 'runtime.tsx' })];\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAqD;AACrD,0BAAgC;AAChC,gB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,CAAC;AAED,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,0BAA0B;AAAA,MACtD,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,YAAY;AAAA,MACxC,SAAS;AAAA,QACP,OAAO,UAAU;AAAA,QACjB,cAAc,UAAU;AAAA,QACxB;AAAA,MACF;AAAA,IACF,CAAC;AAGD,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,cAAc;AAAA,MAC1C,SAAS;AAAA,QACP;AAAA,QACA,gBAAgB,YAAY,SAAS;AAAA,QACrC,aAAa,KAAK,UAAU,WAAW;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,MAAI,WAAW,MAAM;AACnB,WAAO;AAAA,MACL;AAAA,QACE,IAAI;AAAA,QACJ,UAAM,0BAAY,EAAE,KAAK,MAAM,aAAa,CAAC;AAAA,QAC7C,MAAM,CAAC,UAAe;AACpB,iBAAO,MAAM,WAAW;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,oBAAoB,MAAM,CAAC,QAAQ,CAAC;AAExC,MAAI,iBAAiB,MAAM;AACzB,WAAO,KAAC,0BAAY,EAAE,KAAK,MAAM,cAAc,CAAC,CAAC;AAAA,EACnD,CAAC;AACH;",
4
+ "sourcesContent": ["import { IApi, IRoute, RUNTIME_TYPE_FILE_NAME } from '@umijs/max';\nimport { lodash, winPath } from '@umijs/max/plugin-utils';\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\n\nimport { withTmpPath } from '../utils';\n\nconst getPkgHasDep = (api: IApi, depList: string[]) => {\n const hasDependency = (pkg: Record<string, any>, dep: string) => pkg.dependencies?.[dep] || pkg.devDependencies?.[dep];\n const { pkg } = api;\n return depList.find((dep) => hasDependency(pkg, dep));\n};\n\nconst getPkgPath = (api: IApi, pkgName: string, depList?: string[]) => {\n const _depList = depList && depList.length ? depList : [pkgName];\n const pkgHasDep = getPkgHasDep(api, _depList);\n\n if (pkgHasDep) {\n const nodeModulesPath = join(api.cwd, 'node_modules', pkgHasDep, 'package.json');\n\n if (existsSync(nodeModulesPath)) {\n return join(api.cwd, 'node_modules', pkgHasDep);\n }\n\n const cwd = process.cwd();\n if (api.cwd !== cwd) {\n const altNodeModulesPath = join(cwd, 'node_modules', pkgHasDep, 'package.json');\n if (existsSync(altNodeModulesPath)) {\n return join(cwd, 'node_modules', pkgHasDep);\n }\n }\n }\n\n // 如果项目中没有去找插件依赖的\n return dirname(require.resolve(`${pkgName}/package.json`));\n};\n\nconst getIconsInfoForRoutes = (api: IApi) => {\n // 获取所有 icons\n const antIconsPath = winPath(getPkgPath(api, '@ant-design/icons'));\n\n const getAllIcons = () => {\n // 读取 index.d.ts\n const iconTypePath = join(antIconsPath, './lib/icons/index.d.ts');\n const iconTypeContent = readFileSync(iconTypePath, 'utf-8');\n\n // 截取 default as ${iconName}, 然后获取 iconName 转换为 map\n return [...iconTypeContent.matchAll(/default as (\\w+)/g)].reduce((memo: Record<string, boolean>, cur) => {\n memo[cur[1]] = true;\n return memo;\n }, {});\n };\n\n const allIcons: Record<string, boolean> = getAllIcons();\n\n const iconsMap = Object.keys(api.appData.routes).reduce<Record<string, boolean>>((memo, id) => {\n const { icon } = api.appData.routes[id];\n if (icon) {\n const upperIcon = lodash.upperFirst(lodash.camelCase(icon));\n // @ts-ignore\n if (allIcons[upperIcon]) {\n memo[upperIcon] = true;\n }\n // @ts-ignore\n if (allIcons[`${upperIcon}Outlined`]) {\n memo[`${upperIcon}Outlined`] = true;\n }\n }\n return memo;\n }, {});\n const icons = Object.keys(iconsMap);\n\n return {\n icons,\n antIconsPath,\n };\n};\n\nexport default (api: IApi) => {\n const TEMPLATE_DIR = join(__dirname, 'template');\n\n const creekWebComponentsPath = winPath(getPkgPath(api, '@creekjs/web-components'));\n // Use src path directly when in monorepo, else use dist\n const isMonorepo = existsSync(join(creekWebComponentsPath, 'src'));\n const creekIconPath = isMonorepo \n ? winPath(join(creekWebComponentsPath, 'src', 'creek-icon'))\n : require.resolve(`${creekWebComponentsPath}/dist/creek-icon`);\n\n api.describe({\n key: 'creekLayout',\n config: {\n schema({ zod }) {\n return zod\n .object({\n title: zod.string(),\n iconFontCNs: zod.string().array(),\n })\n .partial();\n }, \n onChange: api.ConfigChangeType.regenerateTmpFiles,\n },\n enableBy: api.EnableBy.config,\n });\n\n api.modifyAppData((memo) => {\n const version = require(`${creekWebComponentsPath}/package.json`).version;\n memo.pluginLayout = {\n creekWebComponentsPath,\n version,\n };\n return memo;\n });\n\n // 新增404页面\n api.modifyConfig((memo) => {\n const name = require(`${creekWebComponentsPath}/package.json`).name;\n memo.alias[name] = isMonorepo ? winPath(join(creekWebComponentsPath, 'src')) : creekWebComponentsPath;\n\n const routes = memo.routes as IRoute[];\n const hasNotFoundPage = routes?.find((item) => [item.name, item.path].includes('404'));\n const notFoundComponentPath = isMonorepo \n ? winPath(join(creekWebComponentsPath, 'src', 'creek-layout', 'Exception', 'NotFoundPage.tsx'))\n : require.resolve(`${creekWebComponentsPath}/dist/creek-layout/Exception/NotFoundPage`);\n \n const defaultRoutes = [\n {\n name: '404',\n path: '*',\n hideInMenu: true,\n component: notFoundComponentPath,\n },\n ];\n\n if (!hasNotFoundPage) {\n memo.routes = [...routes, ...defaultRoutes];\n }\n\n return memo;\n });\n\n api.onGenerateFiles(() => {\n const hasInitialStatePlugin = !!api.config.initialState;\n const hasLocalePlugin = !!api.config.locale;\n const iconsInfo = getIconsInfoForRoutes(api);\n\n const iconFontCNs = Array.isArray(api.userConfig.creekLayout?.iconFontCNs) ? api.userConfig.creekLayout?.iconFontCNs : [];\n\n const importPath = isMonorepo ? winPath(join(creekWebComponentsPath, 'src')) : creekWebComponentsPath;\n\n api.writeTmpFile({\n path: 'Layout.tsx',\n tplPath: join(TEMPLATE_DIR, '/layout.tpl'),\n context: {\n creekWebComponentsPath: importPath,\n hasInitialStatePlugin,\n hasLocalePlugin,\n access: api.config.access,\n creekLocaleConfig: api.config.creekLocaleConfig ? JSON.stringify(api.config.glocale, null, 2) : 'undefined',\n userConfig: JSON.stringify(api.config.creekLayout, null, 2),\n },\n });\n // 写入类型, RunTimeLayoutConfig 是 app.tsx 中 layout 配置的类型\n api.writeTmpFile({\n path: 'types.d.ts',\n tplPath: join(TEMPLATE_DIR, '/type.tpl'),\n context: {\n creekWebComponentsPath: importPath,\n hasInitialStatePlugin,\n access: api.config.access,\n },\n });\n\n api.writeTmpFile({\n path: RUNTIME_TYPE_FILE_NAME,\n tplPath: join(TEMPLATE_DIR, '/runtime-config.type.tpl'),\n context: {},\n });\n\n api.writeTmpFile({\n path: 'icons.tsx',\n tplPath: join(TEMPLATE_DIR, '/icons.tpl'),\n context: {\n icons: iconsInfo.icons,\n antIconsPath: iconsInfo.antIconsPath,\n creekIconPath,\n },\n });\n\n // runtime.tsx\n api.writeTmpFile({\n path: 'runtime.tsx',\n tplPath: join(TEMPLATE_DIR, '/runtime.tpl'),\n context: {\n creekWebComponentsPath: importPath,\n hasIconFontCNs: iconFontCNs.length > 0,\n iconFontCNs: JSON.stringify(iconFontCNs),\n },\n });\n });\n\n api.addLayouts(() => {\n return [\n {\n id: 'ant-design-pro-layout',\n file: withTmpPath({ api, path: 'Layout.tsx' }),\n test: (route: any) => {\n return route.layout !== false;\n },\n },\n ];\n });\n\n api.addRuntimePluginKey(() => ['layout']);\n\n api.addRuntimePlugin(() => {\n return [withTmpPath({ api, path: 'runtime.tsx' })];\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAqD;AACrD,0BAAgC;AAChC,gBAAyC;AACzC,kBAA8B;AAE9B,mBAA4B;AAE5B,IAAM,eAAe,CAAC,KAAW,YAAsB;AACrD,QAAM,gBAAgB,CAACA,MAA0B,QAAa;AARhE;AAQmE,kB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MAAM,CAAC;AAAA,MAC5D;AAAA,IACF,CAAC;AAED,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,WAAW;AAAA,MACvC,SAAS;AAAA,QACP,wBAAwB;AAAA,QACxB;AAAA,QACA,QAAQ,IAAI,OAAO;AAAA,MACrB;AAAA,IACF,CAAC;AAED,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,0BAA0B;AAAA,MACtD,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,YAAY;AAAA,MACxC,SAAS;AAAA,QACP,OAAO,UAAU;AAAA,QACjB,cAAc,UAAU;AAAA,QACxB;AAAA,MACF;AAAA,IACF,CAAC;AAGD,QAAI,aAAa;AAAA,MACf,MAAM;AAAA,MACN,aAAS,kBAAK,cAAc,cAAc;AAAA,MAC1C,SAAS;AAAA,QACP,wBAAwB;AAAA,QACxB,gBAAgB,YAAY,SAAS;AAAA,QACrC,aAAa,KAAK,UAAU,WAAW;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,MAAI,WAAW,MAAM;AACnB,WAAO;AAAA,MACL;AAAA,QACE,IAAI;AAAA,QACJ,UAAM,0BAAY,EAAE,KAAK,MAAM,aAAa,CAAC;AAAA,QAC7C,MAAM,CAAC,UAAe;AACpB,iBAAO,MAAM,WAAW;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,oBAAoB,MAAM,CAAC,QAAQ,CAAC;AAExC,MAAI,iBAAiB,MAAM;AACzB,WAAO,KAAC,0BAAY,EAAE,KAAK,MAAM,cAAc,CAAC,CAAC;AAAA,EACnD,CAAC;AACH;",
6
6
  "names": ["pkg"]
7
7
  }
@@ -19,6 +19,7 @@
19
19
  showDarkButton?: boolean;
20
20
  provider?: React.ReactNode;
21
21
  keepAlive?: boolean | CreekKeepAliveProps;
22
+ showSettingsButton?: boolean;
22
23
  extraActions?: React.ReactNode[];
23
24
  showLocaleButton?: boolean;
24
25
  unAccessible?: JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creekjs/umi-plugins",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "ISC",
@@ -10,14 +10,14 @@
10
10
  "files": [
11
11
  "dist"
12
12
  ],
13
+ "devDependencies": {
14
+ "umi": "^4.6.25",
15
+ "@creekjs/web-components": "^1.0.9",
16
+ "@creekjs/openapi": "^0.0.4",
17
+ "@creekjs/request": "^1.0.3"
18
+ },
13
19
  "scripts": {
14
20
  "father:build": "father build",
15
21
  "father:dev": "father dev --no-clean"
16
- },
17
- "devDependencies": {
18
- "@creekjs/openapi": "workspace:^",
19
- "@creekjs/request": "workspace:^",
20
- "@creekjs/web-components": "workspace:^",
21
- "umi": "^4.6.25"
22
22
  }
23
- }
23
+ }