create-antd-skin 1.2.3 → 1.2.4

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.
package/bin/layout.js CHANGED
@@ -115,11 +115,6 @@ async function patchLayoutFile(filePath) {
115
115
  await fs_extra_1.default.writeFile(filePath, output.code);
116
116
  console.log(chalk_1.default.greenBright("✓") + " Updated:", path_1.default.relative(process.cwd(), filePath));
117
117
  }
118
- function hasThemeSkinsProp(node) {
119
- return node.attributes.some(attr => t.isJSXAttribute(attr) &&
120
- t.isJSXIdentifier(attr.name) &&
121
- attr.name.name === "themeSkins");
122
- }
123
118
  async function getLayoutFiles(dir) {
124
119
  const result = [];
125
120
  const items = await fs_extra_1.default.readdir(dir);
package/bin/skin.js CHANGED
@@ -9,22 +9,31 @@ const path_1 = __importDefault(require("path"));
9
9
  const inquirer_1 = __importDefault(require("inquirer"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const ora_1 = __importDefault(require("ora"));
12
- async function findSkinEntry(skinDir) {
13
- const tsFile = path_1.default.join(skinDir, "index.ts");
14
- const tsxFile = path_1.default.join(skinDir, "index.tsx");
15
- if (await fs_extra_1.default.pathExists(tsxFile)) {
16
- return {
17
- source: tsxFile,
18
- ext: "tsx",
19
- };
12
+ /** 按 tsx > ts 优先级返回目录中已存在的入口文件;都不存在返回 null */
13
+ async function findExistingEntry(dir) {
14
+ const candidates = ["tsx", "ts"];
15
+ for (const ext of candidates) {
16
+ const file = path_1.default.join(dir, `index.${ext}`);
17
+ if (await fs_extra_1.default.pathExists(file)) {
18
+ return { source: file, ext };
19
+ }
20
20
  }
21
- if (await fs_extra_1.default.pathExists(tsFile)) {
22
- return {
23
- source: tsFile,
24
- ext: "ts",
25
- };
21
+ return null;
22
+ }
23
+ /** 源皮肤目录必须有入口,缺失时抛错 */
24
+ async function findSkinEntry(skinDir) {
25
+ const entry = await findExistingEntry(skinDir);
26
+ if (!entry) {
27
+ throw new Error(`No skin entry found in ${skinDir}. Expected index.ts or index.tsx`);
26
28
  }
27
- throw new Error(`No skin entry found in ${skinDir}. Expected index.ts or index.tsx`);
29
+ return entry;
30
+ }
31
+ /** 目标项目入口:已有则沿用,没有则默认 index.ts */
32
+ async function resolveTargetIndexFile(skinRoot) {
33
+ const existing = await findExistingEntry(skinRoot);
34
+ return existing
35
+ ? existing.source
36
+ : path_1.default.join(skinRoot, "index.ts");
28
37
  }
29
38
  async function getSkinList() {
30
39
  const skinsDir = path_1.default.join(__dirname, "../skins");
@@ -54,10 +63,10 @@ async function copySkinFiles(skinName, skinDir, projectRoot) {
54
63
  }
55
64
  async function updateSkinIndex(skinName, projectRoot) {
56
65
  const skinRoot = path_1.default.join(projectRoot, "src/components/warden-skins");
57
- const indexFile = path_1.default.join(skinRoot, "index.ts");
58
66
  await fs_extra_1.default.ensureDir(skinRoot);
67
+ const indexFile = await resolveTargetIndexFile(skinRoot);
59
68
  const dirs = (await fs_extra_1.default.readdir(skinRoot))
60
- .filter(item => item !== "index.ts")
69
+ .filter(item => item !== "index.ts" && item !== "index.tsx")
61
70
  .filter(item => fs_extra_1.default.statSync(path_1.default.join(skinRoot, item)).isDirectory());
62
71
  const skinNames = Array.from(new Set([...dirs, skinName]));
63
72
  const imports = skinNames
@@ -109,7 +118,7 @@ async function installSkin(skinName) {
109
118
  }
110
119
  const skin = skins.find(item => item.name === selectedSkin);
111
120
  if (!skin) {
112
- console.error(chalk_1.default.red(`× Skin "${selectedSkin}" not found.`));
121
+ console.error(chalk_1.default.red(`× Skin "${selectedSkin}" not found. can only be [${skins.join(",")}]`));
113
122
  process.exit(1);
114
123
  }
115
124
  const spinner = (0, ora_1.default)(`Installing skin "${selectedSkin}"...`).start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-antd-skin",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "this is skin-cli for @adminui-dev/antd-layout",
5
5
  "main": "index.js",
6
6
  "author": "zhouwenqi",
@@ -0,0 +1,50 @@
1
+ import { LazyImage } from "@adminui-dev/antd-layout"
2
+ import type {ThemeSkin} from "@adminui-dev/antd-layout"
3
+ import { Grid } from "antd"
4
+
5
+ const { useBreakpoint } = Grid
6
+
7
+ const skinBgStyles:React.CSSProperties = {
8
+ position:"absolute",
9
+ inset:"0",
10
+ backgroundColor:"#090a0b",
11
+ }
12
+ const imgStyles:React.CSSProperties = {
13
+ position:"absolute",
14
+ transition:"width 0.3s, height 0.3s, opaticy 0.3s"
15
+ }
16
+ const ImageBackground=()=>{
17
+ const { xs } = useBreakpoint()
18
+ const leftStyle = xs ? {"height":"100%"} : {"width:":"260px"}
19
+ return (
20
+ <div style={skinBgStyles}>
21
+ <LazyImage style={{...leftStyle,...imgStyles,top:"0px"}} src="/images/skins/blue-sky/bg-top-left-dark.webp" alt="bg-top-left.webp" />
22
+ <LazyImage style={{...imgStyles,top:"0px",right:"0px"}} src="/images/skins/blue-sky/bg-top-right-dark.webp" alt="bg-bottom-right.webp" />
23
+ <LazyImage style={{...imgStyles,bottom:"0px",left:"0px"}} src="/images/skins/blue-sky/bg-bottom-left.webp" alt="bg-bottom-left.webp" />
24
+ </div>
25
+ )
26
+ }
27
+ const skin:ThemeSkin = {
28
+ "name":"blueSkyDark",
29
+ "skinType":"system",
30
+ "backgroundColor":"#090a0b",
31
+ "layoutConfig":{
32
+ "theme":"dark",
33
+ "primaryColor":"#32a7da",
34
+ "noneHeader":false,
35
+ "hideBorder":false,
36
+ "asideBlur":true,
37
+ "headerBlur":true,
38
+ "largeBrand":true,
39
+ "containerBlur":true,
40
+ "menuItemSelectColor":"primary",
41
+ },
42
+ "antdToken":{
43
+ "colorBgBase": "#0b0c0c",
44
+ "colorTextBase": "#f4fafd"
45
+ },
46
+ "logo":"/images/skins/blue-sky/app-logo-dark.webp",
47
+ "icon":"/images/skins/blue-sky/skin-icon-dark.webp",
48
+ "backgroundContent":<ImageBackground />
49
+ }
50
+ export default skin
@@ -0,0 +1,50 @@
1
+ import { LazyImage } from "@adminui-dev/antd-layout"
2
+ import type {ThemeSkin} from "@adminui-dev/antd-layout"
3
+ import { Grid } from "antd"
4
+
5
+ const { useBreakpoint } = Grid
6
+
7
+ const skinBgStyles:React.CSSProperties = {
8
+ position:"absolute",
9
+ inset:"0",
10
+ backgroundColor:"#fbfbfb",
11
+ }
12
+ const imgStyles:React.CSSProperties = {
13
+ position:"absolute",
14
+ transition:"width 0.3s, height 0.3s, opaticy 0.3s"
15
+ }
16
+ const ImageBackground=()=>{
17
+ const { xs } = useBreakpoint()
18
+ const leftStyle = xs ? {"height":"100%"} : {"width:":"260px"}
19
+ return (
20
+ <div style={skinBgStyles}>
21
+ <LazyImage style={{...leftStyle,...imgStyles,top:"0px"}} src="/images/skins/blue-sky/bg-top-left.webp" alt="bg-top-left.webp" />
22
+ <LazyImage style={{...imgStyles,top:"0px",right:"0px"}} src="/images/skins/blue-sky/bg-top-right.webp" alt="bg-bottom-right.webp" />
23
+ <LazyImage style={{...imgStyles,bottom:"0px",left:"0px"}} src="/images/skins/blue-sky/bg-bottom-left.webp" alt="bg-bottom-left.webp" />
24
+ </div>
25
+ )
26
+ }
27
+ const skin:ThemeSkin = {
28
+ "name":"blueSkyLight",
29
+ "skinType":"system",
30
+ "backgroundColor":"#fbfbfb",
31
+ "layoutConfig":{
32
+ "theme":"light",
33
+ "primaryColor":"#4dbae9",
34
+ "noneHeader":false,
35
+ "hideBorder":false,
36
+ "asideBlur":true,
37
+ "headerBlur":true,
38
+ "largeBrand":true,
39
+ "containerBlur":true,
40
+ "menuItemSelectColor":"primary",
41
+ },
42
+ "antdToken":{
43
+ "colorBgBase": "#f4fafd",
44
+ "colorTextBase": "#010d13"
45
+ },
46
+ "logo":"/images/skins/blue-sky/app-logo-light.webp",
47
+ "icon":"/images/skins/blue-sky/skin-icon-light.webp",
48
+ "backgroundContent":<ImageBackground />
49
+ }
50
+ export default skin