@nocobase/plugin-mobile-client 0.12.0-alpha.2 → 0.12.0-alpha.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/dist/client/index.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
})();
|
|
14
14
|
(function(global2, factory) {
|
|
15
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@nocobase/client"), require("react-router-dom"), require("antd"), require("react-i18next"), require("@ant-design/icons"), require("@formily/react"), require("lodash"), require("@formily/shared"), require("@formily/antd-v5")) : typeof define === "function" && define.amd ? define(["exports", "react", "@nocobase/client", "react-router-dom", "antd", "react-i18next", "@ant-design/icons", "@formily/react", "lodash", "@formily/shared", "@formily/antd-v5"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@nocobase/plugin-mobile-client"] = {}, global2.react, global2["@nocobase/client"], global2["react-router-dom"], global2.antd, global2["react-i18next"], global2["@ant-design/icons"], global2["@formily/react"], global2.lodash, global2["@formily/shared"], global2["@formily/antd-v5"]));
|
|
16
|
-
})(this, function(exports2, React, client, reactRouterDom, antd, reactI18next, icons, react, lodash, shared, antdV5) {
|
|
15
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@nocobase/client"), require("react-router-dom"), require("antd"), require("react-i18next"), require("@ant-design/icons"), require("@formily/react"), require("lodash"), require("ahooks"), require("@formily/shared"), require("@formily/antd-v5")) : typeof define === "function" && define.amd ? define(["exports", "react", "@nocobase/client", "react-router-dom", "antd", "react-i18next", "@ant-design/icons", "@formily/react", "lodash", "ahooks", "@formily/shared", "@formily/antd-v5"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@nocobase/plugin-mobile-client"] = {}, global2.react, global2["@nocobase/client"], global2["react-router-dom"], global2.antd, global2["react-i18next"], global2["@ant-design/icons"], global2["@formily/react"], global2.lodash, global2.ahooks, global2["@formily/shared"], global2["@formily/antd-v5"]));
|
|
16
|
+
})(this, function(exports2, React, client, reactRouterDom, antd, reactI18next, icons, react, lodash, ahooks, shared, antdV5) {
|
|
17
17
|
"use strict";var __defProp = Object.defineProperty;
|
|
18
18
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
19
|
var __publicField = (obj, key, value) => {
|
|
@@ -84,6 +84,14 @@ var __publicField = (obj, key, value) => {
|
|
|
84
84
|
}
|
|
85
85
|
const AppConfiguration = () => {
|
|
86
86
|
const { t: t2 } = useTranslation();
|
|
87
|
+
const location = reactRouterDom.useLocation();
|
|
88
|
+
const targetUrl = React.useMemo(() => {
|
|
89
|
+
let baseUrl = "/mobile";
|
|
90
|
+
if (location.pathname.startsWith("/apps")) {
|
|
91
|
+
baseUrl = location.pathname.split("/").slice(0, 3).join("/");
|
|
92
|
+
}
|
|
93
|
+
return baseUrl;
|
|
94
|
+
}, [location.pathname]);
|
|
87
95
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
88
96
|
antd.Card,
|
|
89
97
|
{
|
|
@@ -93,9 +101,9 @@ var __publicField = (obj, key, value) => {
|
|
|
93
101
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Form, { layout: "vertical", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
94
102
|
antd.Form.Item,
|
|
95
103
|
{
|
|
96
|
-
tooltip: `${t2("The full address is")} ${window.origin}
|
|
104
|
+
tooltip: `${t2("The full address is")} ${window.origin}${targetUrl}`,
|
|
97
105
|
label: t2("Mobile client access address"),
|
|
98
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Input, { value:
|
|
106
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Input, { value: targetUrl, disabled: true })
|
|
99
107
|
}
|
|
100
108
|
) })
|
|
101
109
|
}
|
|
@@ -111,7 +119,18 @@ var __publicField = (obj, key, value) => {
|
|
|
111
119
|
const InterfaceRouter = React.memo(() => {
|
|
112
120
|
const plugin = client.usePlugin(MobileClientPlugin);
|
|
113
121
|
const MobileRouter = plugin.getMobileRouterComponent();
|
|
114
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(InterfaceProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
122
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(InterfaceProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
className: client.css`
|
|
126
|
+
display: flex;
|
|
127
|
+
width: 100%;
|
|
128
|
+
height: 100%;
|
|
129
|
+
position: relative;
|
|
130
|
+
`,
|
|
131
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(MobileRouter, {})
|
|
132
|
+
}
|
|
133
|
+
) });
|
|
115
134
|
});
|
|
116
135
|
InterfaceRouter.displayName = "InterfaceRouter";
|
|
117
136
|
const iOS6 = (props) => {
|
|
@@ -143,6 +162,7 @@ var __publicField = (obj, key, value) => {
|
|
|
143
162
|
display: flex;
|
|
144
163
|
justify-content: center;
|
|
145
164
|
align-items: center;
|
|
165
|
+
margin-top: 50px;
|
|
146
166
|
`
|
|
147
167
|
),
|
|
148
168
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -312,31 +332,6 @@ var __publicField = (obj, key, value) => {
|
|
|
312
332
|
document.addEventListener("touchstart", () => {
|
|
313
333
|
}, true);
|
|
314
334
|
}
|
|
315
|
-
function __read(o, n2) {
|
|
316
|
-
var m2 = typeof Symbol === "function" && o[Symbol.iterator];
|
|
317
|
-
if (!m2)
|
|
318
|
-
return o;
|
|
319
|
-
var i = m2.call(o), r, ar = [], e2;
|
|
320
|
-
try {
|
|
321
|
-
while ((n2 === void 0 || n2-- > 0) && !(r = i.next()).done)
|
|
322
|
-
ar.push(r.value);
|
|
323
|
-
} catch (error) {
|
|
324
|
-
e2 = { error };
|
|
325
|
-
} finally {
|
|
326
|
-
try {
|
|
327
|
-
if (r && !r.done && (m2 = i["return"]))
|
|
328
|
-
m2.call(i);
|
|
329
|
-
} finally {
|
|
330
|
-
if (e2)
|
|
331
|
-
throw e2.error;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return ar;
|
|
335
|
-
}
|
|
336
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
337
|
-
var e2 = new Error(message);
|
|
338
|
-
return e2.name = "SuppressedError", e2.error = error, e2.suppressed = suppressed, e2;
|
|
339
|
-
};
|
|
340
335
|
function attachPropertiesToComponent(component, properties) {
|
|
341
336
|
const ret = component;
|
|
342
337
|
for (const key in properties) {
|
|
@@ -470,14 +465,14 @@ var __publicField = (obj, key, value) => {
|
|
|
470
465
|
var isObject_1 = isObject$3;
|
|
471
466
|
var baseGetTag$2 = _baseGetTag, isObject$2 = isObject_1;
|
|
472
467
|
var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
473
|
-
function isFunction$
|
|
468
|
+
function isFunction$2(value) {
|
|
474
469
|
if (!isObject$2(value)) {
|
|
475
470
|
return false;
|
|
476
471
|
}
|
|
477
472
|
var tag = baseGetTag$2(value);
|
|
478
473
|
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
479
474
|
}
|
|
480
|
-
var isFunction_1 = isFunction$
|
|
475
|
+
var isFunction_1 = isFunction$2;
|
|
481
476
|
var root = _root;
|
|
482
477
|
var coreJsData$1 = root["__core-js_shared__"];
|
|
483
478
|
var _coreJsData = coreJsData$1;
|
|
@@ -506,7 +501,7 @@ var __publicField = (obj, key, value) => {
|
|
|
506
501
|
return "";
|
|
507
502
|
}
|
|
508
503
|
var _toSource = toSource$1;
|
|
509
|
-
var isFunction$
|
|
504
|
+
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource = _toSource;
|
|
510
505
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
511
506
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
512
507
|
var funcProto = Function.prototype, objectProto$5 = Object.prototype;
|
|
@@ -519,7 +514,7 @@ var __publicField = (obj, key, value) => {
|
|
|
519
514
|
if (!isObject$1(value) || isMasked(value)) {
|
|
520
515
|
return false;
|
|
521
516
|
}
|
|
522
|
-
var pattern = isFunction$
|
|
517
|
+
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
523
518
|
return pattern.test(toSource(value));
|
|
524
519
|
}
|
|
525
520
|
var _baseIsNative = baseIsNative$1;
|
|
@@ -675,9 +670,9 @@ var __publicField = (obj, key, value) => {
|
|
|
675
670
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
|
|
676
671
|
}
|
|
677
672
|
var isLength_1 = isLength$2;
|
|
678
|
-
var isFunction
|
|
673
|
+
var isFunction = isFunction_1, isLength$1 = isLength_1;
|
|
679
674
|
function isArrayLike$2(value) {
|
|
680
|
-
return value != null && isLength$1(value.length) && !isFunction
|
|
675
|
+
return value != null && isLength$1(value.length) && !isFunction(value);
|
|
681
676
|
}
|
|
682
677
|
var isArrayLike_1 = isArrayLike$2;
|
|
683
678
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
@@ -877,40 +872,6 @@ var __publicField = (obj, key, value) => {
|
|
|
877
872
|
}
|
|
878
873
|
return ret;
|
|
879
874
|
}
|
|
880
|
-
var isFunction = function(value) {
|
|
881
|
-
return typeof value === "function";
|
|
882
|
-
};
|
|
883
|
-
var isDev = false;
|
|
884
|
-
const isDev$1 = isDev;
|
|
885
|
-
function useMemoizedFn(fn) {
|
|
886
|
-
if (isDev$1) {
|
|
887
|
-
if (!isFunction(fn)) {
|
|
888
|
-
console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof fn));
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
var fnRef = React.useRef(fn);
|
|
892
|
-
fnRef.current = React.useMemo(function() {
|
|
893
|
-
return fn;
|
|
894
|
-
}, [fn]);
|
|
895
|
-
var memoizedFn = React.useRef();
|
|
896
|
-
if (!memoizedFn.current) {
|
|
897
|
-
memoizedFn.current = function() {
|
|
898
|
-
var args = [];
|
|
899
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
900
|
-
args[_i] = arguments[_i];
|
|
901
|
-
}
|
|
902
|
-
return fnRef.current.apply(this, args);
|
|
903
|
-
};
|
|
904
|
-
}
|
|
905
|
-
return memoizedFn.current;
|
|
906
|
-
}
|
|
907
|
-
var useUpdate = function() {
|
|
908
|
-
var _a = __read(React.useState({}), 2), setState = _a[1];
|
|
909
|
-
return React.useCallback(function() {
|
|
910
|
-
return setState({});
|
|
911
|
-
}, []);
|
|
912
|
-
};
|
|
913
|
-
const useUpdate$1 = useUpdate;
|
|
914
875
|
function LeftOutline(props) {
|
|
915
876
|
return /* @__PURE__ */ React__namespace.createElement("svg", Object.assign({
|
|
916
877
|
width: "1em",
|
|
@@ -1021,12 +982,12 @@ var __publicField = (obj, key, value) => {
|
|
|
1021
982
|
defaultValue,
|
|
1022
983
|
onChange
|
|
1023
984
|
} = options;
|
|
1024
|
-
const update = useUpdate
|
|
985
|
+
const update = ahooks.useUpdate();
|
|
1025
986
|
const stateRef = React.useRef(value !== void 0 ? value : defaultValue);
|
|
1026
987
|
if (value !== void 0) {
|
|
1027
988
|
stateRef.current = value;
|
|
1028
989
|
}
|
|
1029
|
-
const setState = useMemoizedFn((v2, forceTrigger = false) => {
|
|
990
|
+
const setState = ahooks.useMemoizedFn((v2, forceTrigger = false) => {
|
|
1030
991
|
const nextValue = typeof v2 === "function" ? v2(stateRef.current) : v2;
|
|
1031
992
|
if (!forceTrigger && nextValue === stateRef.current)
|
|
1032
993
|
return;
|
|
@@ -1382,10 +1343,10 @@ var __publicField = (obj, key, value) => {
|
|
|
1382
1343
|
const { dn } = client.useDesignable();
|
|
1383
1344
|
const fieldSchema = react.useFieldSchema();
|
|
1384
1345
|
const field = react.useField();
|
|
1385
|
-
const onUpdateComponentProps =
|
|
1346
|
+
const onUpdateComponentProps = ahooks.useMemoizedFn(async (data) => {
|
|
1386
1347
|
lodash.set(fieldSchema, "x-component-props", data);
|
|
1387
1348
|
field.componentProps = { ...field.componentProps, ...data };
|
|
1388
|
-
dn.emit("patch", {
|
|
1349
|
+
await dn.emit("patch", {
|
|
1389
1350
|
schema: {
|
|
1390
1351
|
["x-uid"]: fieldSchema["x-uid"],
|
|
1391
1352
|
"x-component-props": fieldSchema["x-component-props"],
|
|
@@ -1397,8 +1358,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1397
1358
|
]
|
|
1398
1359
|
}
|
|
1399
1360
|
});
|
|
1400
|
-
dn.refresh();
|
|
1401
|
-
}
|
|
1361
|
+
await dn.refresh();
|
|
1362
|
+
});
|
|
1402
1363
|
return { onUpdateComponentProps };
|
|
1403
1364
|
};
|
|
1404
1365
|
const menuItemSchema = {
|
|
@@ -1563,12 +1524,12 @@ var __publicField = (obj, key, value) => {
|
|
|
1563
1524
|
const ContainerDesigner = () => {
|
|
1564
1525
|
const { t: t2 } = useTranslation();
|
|
1565
1526
|
const fieldSchema = react.useFieldSchema();
|
|
1527
|
+
const { onUpdateComponentProps } = useSchemaPatch();
|
|
1528
|
+
const field = react.useField();
|
|
1566
1529
|
const { dn } = client.useDesignable();
|
|
1567
|
-
const tabBarSchema = fieldSchema.reduceProperties(
|
|
1568
|
-
(schema, next) => schema || next["x-component"] === "MTabBar" && next
|
|
1569
|
-
);
|
|
1570
1530
|
const navigate = reactRouterDom.useNavigate();
|
|
1571
|
-
const
|
|
1531
|
+
const tabBarSchema = findSchema(fieldSchema, "MTabBar");
|
|
1532
|
+
const tabBarEnabled = tabBarSchema && field.componentProps.tabBarEnabled !== false;
|
|
1572
1533
|
const schemaSettingsProps = {
|
|
1573
1534
|
dn,
|
|
1574
1535
|
field,
|
|
@@ -1594,44 +1555,39 @@ var __publicField = (obj, key, value) => {
|
|
|
1594
1555
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1595
1556
|
client.SchemaSettings.SwitchItem,
|
|
1596
1557
|
{
|
|
1597
|
-
checked:
|
|
1558
|
+
checked: tabBarEnabled,
|
|
1598
1559
|
title: t2("Enable TabBar"),
|
|
1599
1560
|
onChange: async (v2) => {
|
|
1600
|
-
var _a;
|
|
1601
1561
|
if (v2) {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
page: pageSchema.toJSON()
|
|
1562
|
+
if (!tabBarSchema) {
|
|
1563
|
+
const pageSchema = findSchema(fieldSchema, "MPage");
|
|
1564
|
+
await dn.insertBeforeEnd({
|
|
1565
|
+
type: "void",
|
|
1566
|
+
"x-component": "MTabBar",
|
|
1567
|
+
"x-component-props": {},
|
|
1568
|
+
name: "tabBar",
|
|
1569
|
+
properties: {
|
|
1570
|
+
[shared.uid()]: {
|
|
1571
|
+
type: "void",
|
|
1572
|
+
"x-component": "MTabBar.Item",
|
|
1573
|
+
"x-designer": "MTabBar.Item.Designer",
|
|
1574
|
+
"x-component-props": {
|
|
1575
|
+
icon: "HomeOutlined",
|
|
1576
|
+
title: generateNTemplate("Untitled")
|
|
1577
|
+
},
|
|
1578
|
+
properties: {
|
|
1579
|
+
page: pageSchema.toJSON()
|
|
1580
|
+
}
|
|
1622
1581
|
}
|
|
1623
1582
|
}
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
navigate("../");
|
|
1633
|
-
}
|
|
1634
|
-
});
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
await onUpdateComponentProps({
|
|
1587
|
+
tabBarEnabled: v2
|
|
1588
|
+
});
|
|
1589
|
+
if (v2 === false) {
|
|
1590
|
+
navigate("../");
|
|
1635
1591
|
}
|
|
1636
1592
|
}
|
|
1637
1593
|
}
|
|
@@ -1701,6 +1657,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1701
1657
|
const navigate = reactRouterDom.useNavigate();
|
|
1702
1658
|
const params = reactRouterDom.useParams();
|
|
1703
1659
|
const location = reactRouterDom.useLocation();
|
|
1660
|
+
const field = react.useField();
|
|
1661
|
+
const isTabBarEnabled = field.componentProps.tabBarEnabled !== false;
|
|
1704
1662
|
const tabBarSchema = (_a = fieldSchema == null ? void 0 : fieldSchema.properties) == null ? void 0 : _a["tabBar"];
|
|
1705
1663
|
const tabBarCurrentFirstKey = (tabBarSchema == null ? void 0 : tabBarSchema.properties) ? Object.keys(tabBarSchema.properties)[0] : null;
|
|
1706
1664
|
let redirectToUid = null;
|
|
@@ -1733,7 +1691,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1733
1691
|
)
|
|
1734
1692
|
}
|
|
1735
1693
|
),
|
|
1736
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: client.cx("nb-mobile-container-tab-bar", styles.tabBar), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1694
|
+
isTabBarEnabled && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: client.cx("nb-mobile-container-tab-bar", styles.tabBar), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1737
1695
|
client.SchemaComponent,
|
|
1738
1696
|
{
|
|
1739
1697
|
onlyRenderProperties: true,
|
|
@@ -1909,14 +1867,17 @@ var __publicField = (obj, key, value) => {
|
|
|
1909
1867
|
MTabBar.Item = TabBarItem;
|
|
1910
1868
|
MTabBar.displayName = "MTabBar";
|
|
1911
1869
|
const PageDesigner = (props) => {
|
|
1912
|
-
var _a, _b;
|
|
1870
|
+
var _a, _b, _c, _d;
|
|
1913
1871
|
const { showBack } = props;
|
|
1914
1872
|
const { t: t2 } = useTranslation();
|
|
1873
|
+
const field = react.useField();
|
|
1915
1874
|
const fieldSchema = react.useFieldSchema();
|
|
1916
1875
|
const { dn } = client.useDesignable();
|
|
1876
|
+
const { onUpdateComponentProps } = useSchemaPatch();
|
|
1917
1877
|
const headerSchema = (_a = fieldSchema == null ? void 0 : fieldSchema.properties) == null ? void 0 : _a["header"];
|
|
1918
|
-
const
|
|
1919
|
-
const
|
|
1878
|
+
const isHeaderEnabled = !!headerSchema && ((_b = field.componentProps) == null ? void 0 : _b.headerEnabled) !== false;
|
|
1879
|
+
const tabsSchema = (_c = fieldSchema == null ? void 0 : fieldSchema.properties) == null ? void 0 : _c["tabs"];
|
|
1880
|
+
const isTabsEnabled = !!tabsSchema && ((_d = field.componentProps) == null ? void 0 : _d.tabsEnabled) !== false;
|
|
1920
1881
|
const schemaSettingsProps = {
|
|
1921
1882
|
dn,
|
|
1922
1883
|
field,
|
|
@@ -1943,11 +1904,11 @@ var __publicField = (obj, key, value) => {
|
|
|
1943
1904
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1944
1905
|
client.SchemaSettings.SwitchItem,
|
|
1945
1906
|
{
|
|
1946
|
-
checked:
|
|
1907
|
+
checked: isHeaderEnabled,
|
|
1947
1908
|
title: t2("Enable Header"),
|
|
1948
1909
|
onChange: async (v2) => {
|
|
1949
1910
|
var _a2;
|
|
1950
|
-
if (
|
|
1911
|
+
if (!headerSchema) {
|
|
1951
1912
|
await dn.insertAfterBegin({
|
|
1952
1913
|
type: "void",
|
|
1953
1914
|
name: "header",
|
|
@@ -1958,56 +1919,51 @@ var __publicField = (obj, key, value) => {
|
|
|
1958
1919
|
showBack
|
|
1959
1920
|
}
|
|
1960
1921
|
});
|
|
1961
|
-
} else {
|
|
1962
|
-
await dn.remove(headerSchema);
|
|
1963
1922
|
}
|
|
1964
|
-
|
|
1923
|
+
await onUpdateComponentProps({
|
|
1924
|
+
headerEnabled: v2
|
|
1925
|
+
});
|
|
1965
1926
|
}
|
|
1966
1927
|
}
|
|
1967
1928
|
),
|
|
1968
1929
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1969
1930
|
client.SchemaSettings.SwitchItem,
|
|
1970
1931
|
{
|
|
1971
|
-
checked:
|
|
1932
|
+
checked: isTabsEnabled,
|
|
1972
1933
|
title: t2("Enable Tabs"),
|
|
1973
1934
|
onChange: async (v2) => {
|
|
1974
|
-
if (
|
|
1935
|
+
if (!tabsSchema) {
|
|
1975
1936
|
const gridSchema = findGridSchema(fieldSchema);
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1937
|
+
await dn.remove(gridSchema);
|
|
1938
|
+
return dn.insertBeforeEnd({
|
|
1939
|
+
type: "void",
|
|
1940
|
+
name: "tabs",
|
|
1941
|
+
"x-component": "Tabs",
|
|
1942
|
+
"x-component-props": {},
|
|
1943
|
+
"x-initializer": "TabPaneInitializers",
|
|
1944
|
+
"x-initializer-props": {
|
|
1945
|
+
gridInitializer: "MBlockInitializers"
|
|
1946
|
+
},
|
|
1947
|
+
properties: {
|
|
1948
|
+
tab1: {
|
|
1979
1949
|
type: "void",
|
|
1980
|
-
|
|
1981
|
-
"x-component": "Tabs",
|
|
1950
|
+
title: generateNTemplate("Untitled"),
|
|
1951
|
+
"x-component": "Tabs.TabPane",
|
|
1952
|
+
"x-designer": "Tabs.Designer",
|
|
1982
1953
|
"x-component-props": {},
|
|
1983
|
-
"x-initializer": "TabPaneInitializers",
|
|
1984
|
-
"x-initializer-props": {
|
|
1985
|
-
gridInitializer: "MBlockInitializers"
|
|
1986
|
-
},
|
|
1987
1954
|
properties: {
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
"x-component": "Tabs.TabPane",
|
|
1992
|
-
"x-designer": "Tabs.Designer",
|
|
1993
|
-
"x-component-props": {},
|
|
1994
|
-
properties: {
|
|
1995
|
-
grid: {
|
|
1996
|
-
...gridSchema,
|
|
1997
|
-
"x-uid": shared.uid()
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
1955
|
+
grid: {
|
|
1956
|
+
...gridSchema,
|
|
1957
|
+
"x-uid": shared.uid()
|
|
2000
1958
|
}
|
|
2001
1959
|
}
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
} else {
|
|
2006
|
-
const gridSchema = findGridSchema(tabsSchema.properties[Object.keys(tabsSchema.properties)[0]]);
|
|
2007
|
-
if (gridSchema) {
|
|
2008
|
-
return dn.remove(tabsSchema).then(() => dn.insertBeforeEnd(gridSchema, {}));
|
|
2009
|
-
}
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
2010
1963
|
}
|
|
1964
|
+
await onUpdateComponentProps({
|
|
1965
|
+
tabsEnabled: v2
|
|
1966
|
+
});
|
|
2011
1967
|
}
|
|
2012
1968
|
}
|
|
2013
1969
|
)
|
|
@@ -2053,18 +2009,30 @@ var __publicField = (obj, key, value) => {
|
|
|
2053
2009
|
};
|
|
2054
2010
|
});
|
|
2055
2011
|
const InternalPage = (props) => {
|
|
2056
|
-
var _a, _b, _c, _d;
|
|
2012
|
+
var _a, _b, _c, _d, _e;
|
|
2057
2013
|
const { styles } = useStyles();
|
|
2058
2014
|
const Designer2 = client.useDesigner();
|
|
2015
|
+
const field = react.useField();
|
|
2059
2016
|
const fieldSchema = react.useFieldSchema();
|
|
2060
2017
|
const [searchParams, setSearchParams] = reactRouterDom.useSearchParams();
|
|
2061
2018
|
const tabsSchema = (_a = fieldSchema.properties) == null ? void 0 : _a["tabs"];
|
|
2019
|
+
const isHeaderEnabled = field.componentProps.headerEnabled !== false;
|
|
2020
|
+
const isTabsEnabled = field.componentProps.tabsEnabled !== false;
|
|
2021
|
+
let pageSchema = findSchema(fieldSchema, "MPage");
|
|
2022
|
+
if (!isTabsEnabled && !pageSchema && tabsSchema) {
|
|
2023
|
+
const schemaArr = Object.values(tabsSchema.properties || {}).sort((k1, k2) => {
|
|
2024
|
+
return k1["x-index"] - k2["x-index"];
|
|
2025
|
+
});
|
|
2026
|
+
if (schemaArr.length !== 0) {
|
|
2027
|
+
pageSchema = (_b = Object.values(schemaArr[0].properties)) == null ? void 0 : _b[0];
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2062
2030
|
const onlyInPage = fieldSchema.root === fieldSchema.parent;
|
|
2063
2031
|
let hasGlobalActions = false;
|
|
2064
2032
|
if (!tabsSchema && fieldSchema.properties) {
|
|
2065
2033
|
hasGlobalActions = countGridCol(fieldSchema.properties["grid"], 2) === 1;
|
|
2066
|
-
} else if (searchParams.has("tab") && ((
|
|
2067
|
-
hasGlobalActions = countGridCol((
|
|
2034
|
+
} else if (searchParams.has("tab") && ((_c = tabsSchema == null ? void 0 : tabsSchema.properties) == null ? void 0 : _c[searchParams.get("tab")])) {
|
|
2035
|
+
hasGlobalActions = countGridCol((_e = (_d = tabsSchema.properties[searchParams.get("tab")]) == null ? void 0 : _d.properties) == null ? void 0 : _e["grid"], 2) === 1;
|
|
2068
2036
|
} else if (tabsSchema == null ? void 0 : tabsSchema.properties) {
|
|
2069
2037
|
const schema = Object.values(tabsSchema.properties).sort((t1, t2) => t1["x-index"] - t2["x-index"])[0];
|
|
2070
2038
|
if (schema) {
|
|
@@ -2085,22 +2053,19 @@ var __publicField = (obj, key, value) => {
|
|
|
2085
2053
|
);
|
|
2086
2054
|
const GlobalActionProvider = React.useCallback(
|
|
2087
2055
|
(props2) => {
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
) });
|
|
2100
|
-
}
|
|
2101
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props2.children });
|
|
2056
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.TabsContextProvider, { children: hasGlobalActions ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2057
|
+
client.ActionBarProvider,
|
|
2058
|
+
{
|
|
2059
|
+
container: (typeof props2.active !== "undefined" ? props2.active : true) && onlyInPage ? document.getElementById("nb-position-container") : null,
|
|
2060
|
+
forceProps: {
|
|
2061
|
+
layout: "one-column",
|
|
2062
|
+
className: styles.globalActionCSS
|
|
2063
|
+
},
|
|
2064
|
+
children: props2.children
|
|
2065
|
+
}
|
|
2066
|
+
) : props2.children });
|
|
2102
2067
|
},
|
|
2103
|
-
[hasGlobalActions, onlyInPage]
|
|
2068
|
+
[hasGlobalActions, onlyInPage, styles.globalActionCSS]
|
|
2104
2069
|
);
|
|
2105
2070
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(client.SortableItem, { eid: "nb-mobile-scroll-wrapper", className: client.cx("nb-mobile-page", styles.mobilePage), children: [
|
|
2106
2071
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Designer2, { ...fieldSchema == null ? void 0 : fieldSchema["x-designer-props"] }),
|
|
@@ -2112,7 +2077,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2112
2077
|
},
|
|
2113
2078
|
className: client.cx("nb-mobile-page-header", styles.mobilePageHeader),
|
|
2114
2079
|
children: [
|
|
2115
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2080
|
+
isHeaderEnabled && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2116
2081
|
react.RecursionField,
|
|
2117
2082
|
{
|
|
2118
2083
|
schema: fieldSchema,
|
|
@@ -2130,9 +2095,9 @@ var __publicField = (obj, key, value) => {
|
|
|
2130
2095
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2131
2096
|
react.RecursionField,
|
|
2132
2097
|
{
|
|
2133
|
-
schema: fieldSchema,
|
|
2098
|
+
schema: isTabsEnabled ? fieldSchema : pageSchema,
|
|
2134
2099
|
filterProperties: (s) => {
|
|
2135
|
-
return "Tabs" === s["x-component"];
|
|
2100
|
+
return "Tabs" === s["x-component"] || "Grid.Row" === s["x-component"];
|
|
2136
2101
|
}
|
|
2137
2102
|
}
|
|
2138
2103
|
)
|
|
@@ -2323,6 +2288,28 @@ var __publicField = (obj, key, value) => {
|
|
|
2323
2288
|
}
|
|
2324
2289
|
);
|
|
2325
2290
|
};
|
|
2291
|
+
const OpenInNewTab = () => {
|
|
2292
|
+
const location = reactRouterDom.useLocation();
|
|
2293
|
+
const { t: t2 } = useTranslation();
|
|
2294
|
+
const onOpenInNewTab = () => {
|
|
2295
|
+
let baseUrl = window.origin;
|
|
2296
|
+
if (window.location.pathname.startsWith("/apps")) {
|
|
2297
|
+
baseUrl = window.origin + window.location.pathname.split("/").slice(0, 3).join("/");
|
|
2298
|
+
}
|
|
2299
|
+
window.open(`${baseUrl}${location.pathname}${location.search}`);
|
|
2300
|
+
};
|
|
2301
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2302
|
+
"div",
|
|
2303
|
+
{
|
|
2304
|
+
className: client.css`
|
|
2305
|
+
position: absolute;
|
|
2306
|
+
top: -40px;
|
|
2307
|
+
right: 0;
|
|
2308
|
+
`,
|
|
2309
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Button, { type: "dashed", onClick: onOpenInNewTab, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(icons.LinkOutlined, {}), children: t2("Open in new tab") })
|
|
2310
|
+
}
|
|
2311
|
+
);
|
|
2312
|
+
};
|
|
2326
2313
|
const commonCSSVariables = client.css`
|
|
2327
2314
|
--nb-spacing: 14px;
|
|
2328
2315
|
`;
|
|
@@ -2395,15 +2382,17 @@ var __publicField = (obj, key, value) => {
|
|
|
2395
2382
|
return interfaceContext ? React.Fragment : client.AdminProvider;
|
|
2396
2383
|
}, [interfaceContext]);
|
|
2397
2384
|
client.useViewport();
|
|
2398
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.
|
|
2399
|
-
|
|
2400
|
-
{
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2385
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(MobileCore, { children: [
|
|
2386
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(OpenInNewTab, {}),
|
|
2387
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(client.ActionContextProvider, { modalProps, drawerProps, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2388
|
+
"div",
|
|
2389
|
+
{
|
|
2390
|
+
className: client.cx(
|
|
2391
|
+
"nb-mobile-application",
|
|
2392
|
+
commonDesignerCSS,
|
|
2393
|
+
commonCSSVariables,
|
|
2394
|
+
commonCSSOverride,
|
|
2395
|
+
client.css`
|
|
2407
2396
|
display: flex;
|
|
2408
2397
|
flex-direction: column;
|
|
2409
2398
|
width: 100%;
|
|
@@ -2411,13 +2400,14 @@ var __publicField = (obj, key, value) => {
|
|
|
2411
2400
|
position: relative;
|
|
2412
2401
|
overflow: hidden;
|
|
2413
2402
|
`
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2403
|
+
),
|
|
2404
|
+
children: [
|
|
2405
|
+
params.name && !params.name.startsWith("tab_") ? /* @__PURE__ */ jsxRuntimeExports.jsx(reactRouterDom.Outlet, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(client.RemoteSchemaComponent, { uid: mobileSchemaUid, children: props.children }, mobileSchemaUid),
|
|
2406
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "nb-position-container" })
|
|
2407
|
+
]
|
|
2408
|
+
}
|
|
2409
|
+
) })
|
|
2410
|
+
] }) });
|
|
2421
2411
|
};
|
|
2422
2412
|
class MobileClientPlugin extends client.Plugin {
|
|
2423
2413
|
constructor() {
|
package/dist/locale/zh-CN.d.ts
CHANGED
package/dist/locale/zh-CN.js
CHANGED
|
@@ -29,7 +29,8 @@ const locale = {
|
|
|
29
29
|
"Delete settings block": "\u5220\u9664\u8BBE\u7F6E\u533A\u5757",
|
|
30
30
|
"Delete menu block": "\u5220\u9664\u83DC\u5355\u533A\u5757",
|
|
31
31
|
"Mobile client access address": "\u79FB\u52A8\u7AEF\u8BBF\u95EE\u5730\u5740",
|
|
32
|
-
"The full address is": "\u5B8C\u6574\u7684\u5730\u5740\u662F"
|
|
32
|
+
"The full address is": "\u5B8C\u6574\u7684\u5730\u5740\u662F",
|
|
33
|
+
"Open in new tab": "\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00"
|
|
33
34
|
};
|
|
34
35
|
var zh_CN_default = locale;
|
|
35
36
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-mobile-client",
|
|
3
|
-
"version": "0.12.0-alpha.
|
|
3
|
+
"version": "0.12.0-alpha.4",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"displayName": "Mobile-client",
|
|
6
6
|
"displayName.zh-CN": "移动端",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@formily/shared": "2.x",
|
|
14
14
|
"@types/react": "^17.0.0",
|
|
15
15
|
"@types/react-dom": "^17.0.0",
|
|
16
|
+
"ahooks": "^3.7.2",
|
|
16
17
|
"antd": "5.x",
|
|
17
18
|
"antd-mobile": "^5.29.1",
|
|
18
19
|
"antd-style": "^3.3.0",
|
|
@@ -29,5 +30,5 @@
|
|
|
29
30
|
"@nocobase/test": "0.x",
|
|
30
31
|
"@nocobase/utils": "0.x"
|
|
31
32
|
},
|
|
32
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "215dc3b2437c501ca903b56cc378ab5e81c8a11c"
|
|
33
34
|
}
|