@pisell/materials 1.0.601 → 1.0.602
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +58 -25
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.js +9 -9
- package/es/components/dataSourceComponents/fields/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +51 -20
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.js +16 -11
- package/lib/components/dataSourceComponents/fields/index.d.ts +2 -2
- package/package.json +3 -3
|
@@ -51,6 +51,7 @@ import useEngineContext from "../../../../hooks/useEngineContext";
|
|
|
51
51
|
* />
|
|
52
52
|
*/
|
|
53
53
|
var Subdomain = function Subdomain(props) {
|
|
54
|
+
var _coreData$tenant;
|
|
54
55
|
var propsOnBlur = props.onBlur,
|
|
55
56
|
propsOnChange = props.onChange,
|
|
56
57
|
_props$rootDomain = props.rootDomain,
|
|
@@ -79,30 +80,53 @@ var Subdomain = function Subdomain(props) {
|
|
|
79
80
|
var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4, _context$appHelper$ut5, _context$appHelper$ut6, _context$appHelper$ut7, _context$appHelper$ut8;
|
|
80
81
|
return (_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 ? void 0 : (_context$appHelper$ut2 = _context$appHelper$ut.getApp) === null || _context$appHelper$ut2 === void 0 ? void 0 : (_context$appHelper$ut3 = _context$appHelper$ut2.call(_context$appHelper$ut)) === null || _context$appHelper$ut3 === void 0 ? void 0 : (_context$appHelper$ut4 = _context$appHelper$ut3.data) === null || _context$appHelper$ut4 === void 0 ? void 0 : (_context$appHelper$ut5 = _context$appHelper$ut4.store) === null || _context$appHelper$ut5 === void 0 ? void 0 : (_context$appHelper$ut6 = _context$appHelper$ut5.getStore) === null || _context$appHelper$ut6 === void 0 ? void 0 : (_context$appHelper$ut7 = _context$appHelper$ut6.call(_context$appHelper$ut5)) === null || _context$appHelper$ut7 === void 0 ? void 0 : (_context$appHelper$ut8 = _context$appHelper$ut7.getDataByModel) === null || _context$appHelper$ut8 === void 0 ? void 0 : _context$appHelper$ut8.call(_context$appHelper$ut7, 'core', 'core');
|
|
81
82
|
}, [context]);
|
|
82
|
-
|
|
83
|
+
console.log('%c [ coreData ]-79', 'font-size:13px; background:#7b0629; color:#bf4a6d;', coreData);
|
|
83
84
|
// 3. 获取 tenantData
|
|
84
|
-
var tenantData =
|
|
85
|
-
var _coreData$tenant;
|
|
86
|
-
if (rootDomain === 'saas' && coreData !== null && coreData !== void 0 && (_coreData$tenant = coreData.tenant) !== null && _coreData$tenant !== void 0 && _coreData$tenant.id) {
|
|
87
|
-
return useTenantData(coreData.tenant.id);
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
}, [rootDomain, coreData]);
|
|
85
|
+
var tenantData = useTenantData(rootDomain, coreData === null || coreData === void 0 ? void 0 : (_coreData$tenant = coreData.tenant) === null || _coreData$tenant === void 0 ? void 0 : _coreData$tenant.id);
|
|
91
86
|
|
|
92
87
|
// 4. parseExternalValue 函数
|
|
93
|
-
var parseExternalValue =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
var parseExternalValue = function parseExternalValue(val) {
|
|
89
|
+
// 如果值为空或只有空格或只有点号,返回默认值
|
|
90
|
+
if (!val || !val.trim() || val.trim() === '.') {
|
|
91
|
+
return {
|
|
92
|
+
subdomain: '',
|
|
93
|
+
suffix: suffixEmpty()
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
// 将连续的点替换为单个点
|
|
98
|
+
var normalizedVal = val.replace(/\.+/g, '.');
|
|
99
|
+
var parts = normalizedVal.split('.');
|
|
100
|
+
|
|
101
|
+
// 如果第一部分为空(以点号开头),且有后续部分
|
|
102
|
+
if (parts[0] === '' && parts.length > 1) {
|
|
103
|
+
return {
|
|
104
|
+
subdomain: '',
|
|
105
|
+
suffix: ".".concat(parts.slice(1).join('.'))
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 如果只有一个部分,作为子域名
|
|
110
|
+
if (parts.length === 1) {
|
|
111
|
+
return {
|
|
112
|
+
subdomain: parts[0].trim(),
|
|
113
|
+
suffix: suffixEmpty()
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 有多个部分,第一个作为子域名,其余作为后缀
|
|
118
|
+
return {
|
|
119
|
+
subdomain: parts[0].trim(),
|
|
120
|
+
suffix: ".".concat(parts.slice(1).join('.'))
|
|
121
|
+
};
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error('Error parsing value:', error);
|
|
124
|
+
return {
|
|
125
|
+
subdomain: '',
|
|
126
|
+
suffix: suffixEmpty()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
106
130
|
|
|
107
131
|
// 5. 处理 value 和 domain 变化
|
|
108
132
|
useEffect(function () {
|
|
@@ -117,20 +141,29 @@ var Subdomain = function Subdomain(props) {
|
|
|
117
141
|
var _newSuffix = '';
|
|
118
142
|
switch (rootDomain) {
|
|
119
143
|
case 'xzero':
|
|
120
|
-
_newSuffix = coreData ? ".".concat(coreData.tenant_domain) : suffixEmpty();
|
|
144
|
+
_newSuffix = coreData !== null && coreData !== void 0 && coreData.tenant_domain ? ".".concat(coreData.tenant_domain) : suffixEmpty();
|
|
121
145
|
break;
|
|
122
146
|
case 'saas':
|
|
123
|
-
_newSuffix = tenantData ? ".".concat(tenantData['saas.domain']) : suffixEmpty();
|
|
147
|
+
_newSuffix = tenantData !== null && tenantData !== void 0 && tenantData['saas.domain'] ? ".".concat(tenantData['saas.domain']) : suffixEmpty();
|
|
148
|
+
break;
|
|
149
|
+
case 'custom':
|
|
150
|
+
if (customDomain) {
|
|
151
|
+
var normalizedDomain = customDomain.replace(/\.+/g, '.');
|
|
152
|
+
_newSuffix = normalizedDomain.startsWith('.') ? normalizedDomain : ".".concat(normalizedDomain);
|
|
153
|
+
} else {
|
|
154
|
+
_newSuffix = suffixEmpty();
|
|
155
|
+
}
|
|
124
156
|
break;
|
|
125
157
|
default:
|
|
126
|
-
_newSuffix =
|
|
158
|
+
_newSuffix = suffixEmpty();
|
|
127
159
|
}
|
|
128
160
|
setSuffix(_newSuffix);
|
|
129
161
|
}
|
|
130
162
|
} catch (error) {
|
|
131
163
|
console.error('Error updating domain:', error);
|
|
164
|
+
setSuffix(suffixEmpty());
|
|
132
165
|
}
|
|
133
|
-
}, [value, rootDomain, customDomain, tenantData, coreData
|
|
166
|
+
}, [value, rootDomain, customDomain, tenantData, coreData]);
|
|
134
167
|
|
|
135
168
|
// 6. 处理输入变化
|
|
136
169
|
var handleChange = useCallback(function (e) {
|
|
@@ -45,19 +45,19 @@ export var getTenantData = /*#__PURE__*/function () {
|
|
|
45
45
|
/**
|
|
46
46
|
* 自定义 Hook,用于获取租户数据
|
|
47
47
|
*/
|
|
48
|
-
export var useTenantData = function useTenantData(
|
|
48
|
+
export var useTenantData = function useTenantData(rootDomain, tenantId) {
|
|
49
49
|
var _useRequest = useRequest(function () {
|
|
50
|
-
|
|
50
|
+
// 只有在 saas 模式且有 tenantId 时才发起请求
|
|
51
|
+
if (rootDomain === 'saas' && tenantId) {
|
|
52
|
+
return getTenantData(tenantId);
|
|
53
|
+
}
|
|
54
|
+
return Promise.resolve(undefined);
|
|
51
55
|
}, {
|
|
52
|
-
cacheKey:
|
|
56
|
+
cacheKey: "tenant-data-".concat(tenantId),
|
|
53
57
|
staleTime: 1000 * 60 * 5,
|
|
54
58
|
// 5分钟后数据过期
|
|
55
59
|
cacheTime: 1000 * 60 * 60 // 1小时后清除缓存
|
|
56
60
|
}),
|
|
57
|
-
data = _useRequest.data
|
|
58
|
-
|
|
59
|
-
if (error) {
|
|
60
|
-
console.error("Error fetching tenant data:", error);
|
|
61
|
-
}
|
|
62
|
-
return data; // 返回租户数据
|
|
61
|
+
data = _useRequest.data;
|
|
62
|
+
return data;
|
|
63
63
|
};
|
|
@@ -20,7 +20,7 @@ declare const formFieldMap: {
|
|
|
20
20
|
Subdomain: import("react").FC<import("antd").InputProps & {
|
|
21
21
|
onChange: (value: string) => void;
|
|
22
22
|
onBlur?: ((e: import("react").FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
23
|
-
rootDomain: "custom" | "
|
|
23
|
+
rootDomain: "custom" | "saas" | "xzero";
|
|
24
24
|
customDomain?: string | undefined;
|
|
25
25
|
value?: string | undefined;
|
|
26
26
|
tenantId: string;
|
|
@@ -78,7 +78,7 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
|
|
|
78
78
|
Subdomain: import("react").FC<import("antd").InputProps & {
|
|
79
79
|
onChange: (value: string) => void;
|
|
80
80
|
onBlur?: ((e: import("react").FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
81
|
-
rootDomain: "custom" | "
|
|
81
|
+
rootDomain: "custom" | "saas" | "xzero";
|
|
82
82
|
customDomain?: string | undefined;
|
|
83
83
|
value?: string | undefined;
|
|
84
84
|
tenantId: string;
|
|
@@ -40,6 +40,7 @@ var import_utils = require("../../dataSourceForm/utils");
|
|
|
40
40
|
var import_useDataSource = __toESM(require("../../hooks/useDataSource"));
|
|
41
41
|
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
42
42
|
var Subdomain = (props) => {
|
|
43
|
+
var _a;
|
|
43
44
|
const {
|
|
44
45
|
onBlur: propsOnBlur,
|
|
45
46
|
onChange: propsOnChange,
|
|
@@ -55,24 +56,45 @@ var Subdomain = (props) => {
|
|
|
55
56
|
const [subdomain, setSubdomain] = (0, import_react.useState)("");
|
|
56
57
|
const [suffix, setSuffix] = (0, import_react.useState)("");
|
|
57
58
|
const coreData = (0, import_react.useMemo)(() => {
|
|
58
|
-
var
|
|
59
|
-
return (_h = (_g = (_f = (_e = (_d = (_c = (_b = (
|
|
59
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
60
|
+
return (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a2 = context.appHelper.utils) == null ? void 0 : _a2.getApp) == null ? void 0 : _b.call(_a2)) == null ? void 0 : _c.data) == null ? void 0 : _d.store) == null ? void 0 : _e.getStore) == null ? void 0 : _f.call(_e)) == null ? void 0 : _g.getDataByModel) == null ? void 0 : _h.call(_g, "core", "core");
|
|
60
61
|
}, [context]);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
console.log("%c [ coreData ]-79", "font-size:13px; background:#7b0629; color:#bf4a6d;", coreData);
|
|
63
|
+
const tenantData = (0, import_serve.useTenantData)(rootDomain, (_a = coreData == null ? void 0 : coreData.tenant) == null ? void 0 : _a.id);
|
|
64
|
+
const parseExternalValue = (val) => {
|
|
65
|
+
if (!val || !val.trim() || val.trim() === ".") {
|
|
66
|
+
return {
|
|
67
|
+
subdomain: "",
|
|
68
|
+
suffix: suffixEmpty()
|
|
69
|
+
};
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
try {
|
|
72
|
+
const normalizedVal = val.replace(/\.+/g, ".");
|
|
73
|
+
const parts = normalizedVal.split(".");
|
|
74
|
+
if (parts[0] === "" && parts.length > 1) {
|
|
75
|
+
return {
|
|
76
|
+
subdomain: "",
|
|
77
|
+
suffix: `.${parts.slice(1).join(".")}`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (parts.length === 1) {
|
|
81
|
+
return {
|
|
82
|
+
subdomain: parts[0].trim(),
|
|
83
|
+
suffix: suffixEmpty()
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
subdomain: parts[0].trim(),
|
|
88
|
+
suffix: `.${parts.slice(1).join(".")}`
|
|
89
|
+
};
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error("Error parsing value:", error);
|
|
92
|
+
return {
|
|
93
|
+
subdomain: "",
|
|
94
|
+
suffix: suffixEmpty()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
76
98
|
(0, import_react.useEffect)(() => {
|
|
77
99
|
try {
|
|
78
100
|
if (value) {
|
|
@@ -83,20 +105,29 @@ var Subdomain = (props) => {
|
|
|
83
105
|
let newSuffix = "";
|
|
84
106
|
switch (rootDomain) {
|
|
85
107
|
case "xzero":
|
|
86
|
-
newSuffix = coreData ? `.${coreData.tenant_domain}` : suffixEmpty();
|
|
108
|
+
newSuffix = (coreData == null ? void 0 : coreData.tenant_domain) ? `.${coreData.tenant_domain}` : suffixEmpty();
|
|
87
109
|
break;
|
|
88
110
|
case "saas":
|
|
89
|
-
newSuffix = tenantData ? `.${tenantData["saas.domain"]}` : suffixEmpty();
|
|
111
|
+
newSuffix = (tenantData == null ? void 0 : tenantData["saas.domain"]) ? `.${tenantData["saas.domain"]}` : suffixEmpty();
|
|
112
|
+
break;
|
|
113
|
+
case "custom":
|
|
114
|
+
if (customDomain) {
|
|
115
|
+
const normalizedDomain = customDomain.replace(/\.+/g, ".");
|
|
116
|
+
newSuffix = normalizedDomain.startsWith(".") ? normalizedDomain : `.${normalizedDomain}`;
|
|
117
|
+
} else {
|
|
118
|
+
newSuffix = suffixEmpty();
|
|
119
|
+
}
|
|
90
120
|
break;
|
|
91
121
|
default:
|
|
92
|
-
newSuffix =
|
|
122
|
+
newSuffix = suffixEmpty();
|
|
93
123
|
}
|
|
94
124
|
setSuffix(newSuffix);
|
|
95
125
|
}
|
|
96
126
|
} catch (error) {
|
|
97
127
|
console.error("Error updating domain:", error);
|
|
128
|
+
setSuffix(suffixEmpty());
|
|
98
129
|
}
|
|
99
|
-
}, [value, rootDomain, customDomain, tenantData, coreData
|
|
130
|
+
}, [value, rootDomain, customDomain, tenantData, coreData]);
|
|
100
131
|
const handleChange = (0, import_react.useCallback)((e) => {
|
|
101
132
|
try {
|
|
102
133
|
const inputValue = e.target.value.toLowerCase();
|
|
@@ -40,17 +40,22 @@ var getTenantData = async (id) => {
|
|
|
40
40
|
throw error;
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
var useTenantData = (
|
|
44
|
-
const { data
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
var useTenantData = (rootDomain, tenantId) => {
|
|
44
|
+
const { data } = (0, import_ahooks.useRequest)(
|
|
45
|
+
() => {
|
|
46
|
+
if (rootDomain === "saas" && tenantId) {
|
|
47
|
+
return getTenantData(tenantId);
|
|
48
|
+
}
|
|
49
|
+
return Promise.resolve(void 0);
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
cacheKey: `tenant-data-${tenantId}`,
|
|
53
|
+
staleTime: 1e3 * 60 * 5,
|
|
54
|
+
// 5分钟后数据过期
|
|
55
|
+
cacheTime: 1e3 * 60 * 60
|
|
56
|
+
// 1小时后清除缓存
|
|
57
|
+
}
|
|
58
|
+
);
|
|
54
59
|
return data;
|
|
55
60
|
};
|
|
56
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -20,7 +20,7 @@ declare const formFieldMap: {
|
|
|
20
20
|
Subdomain: import("react").FC<import("antd").InputProps & {
|
|
21
21
|
onChange: (value: string) => void;
|
|
22
22
|
onBlur?: ((e: import("react").FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
23
|
-
rootDomain: "custom" | "
|
|
23
|
+
rootDomain: "custom" | "saas" | "xzero";
|
|
24
24
|
customDomain?: string | undefined;
|
|
25
25
|
value?: string | undefined;
|
|
26
26
|
tenantId: string;
|
|
@@ -78,7 +78,7 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
|
|
|
78
78
|
Subdomain: import("react").FC<import("antd").InputProps & {
|
|
79
79
|
onChange: (value: string) => void;
|
|
80
80
|
onBlur?: ((e: import("react").FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
81
|
-
rootDomain: "custom" | "
|
|
81
|
+
rootDomain: "custom" | "saas" | "xzero";
|
|
82
82
|
customDomain?: string | undefined;
|
|
83
83
|
value?: string | undefined;
|
|
84
84
|
tenantId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/materials",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.602",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"swiper": "^8.4.7",
|
|
71
71
|
"react-barcode": "^1.5.3",
|
|
72
72
|
"@pisell/icon": "0.0.10",
|
|
73
|
-
"@pisell/
|
|
74
|
-
"@pisell/
|
|
73
|
+
"@pisell/utils": "1.0.43",
|
|
74
|
+
"@pisell/date-picker": "1.0.115"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"react": "^18.0.0",
|