@nocobase/plugin-theme-editor 0.11.1-alpha.3 → 0.11.1-alpha.5
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.
|
@@ -51,7 +51,6 @@ const useThemeSettings = () => {
|
|
|
51
51
|
};
|
|
52
52
|
exports.useThemeSettings = useThemeSettings;
|
|
53
53
|
function Label() {
|
|
54
|
-
var _currentUser$data, _currentUser$data$dat, _systemSettings$data, _systemSettings$data$;
|
|
55
54
|
const _useTranslation = (0, _locale.useTranslation)(),
|
|
56
55
|
t = _useTranslation.t;
|
|
57
56
|
const currentUser = (0, _client().useCurrentUserContext)();
|
|
@@ -105,11 +104,7 @@ function Label() {
|
|
|
105
104
|
(0, _client2().error)(err);
|
|
106
105
|
return null;
|
|
107
106
|
}
|
|
108
|
-
if (!
|
|
109
|
-
(0, _client2().error)('Please check if provide `CurrentUserProvider` in your app.');
|
|
110
|
-
throw new Error('Please check if provide `CurrentUserProvider` in your app.');
|
|
111
|
-
}
|
|
112
|
-
if (!(systemSettings !== null && systemSettings !== void 0 && (_systemSettings$data = systemSettings.data) !== null && _systemSettings$data !== void 0 && (_systemSettings$data$ = _systemSettings$data.data) !== null && _systemSettings$data$ !== void 0 && _systemSettings$data$.options)) {
|
|
107
|
+
if (!systemSettings) {
|
|
113
108
|
(0, _client2().error)('Please check if provide `SystemSettingsProvider` in your app.');
|
|
114
109
|
throw new Error('Please check if provide `SystemSettingsProvider` in your app.');
|
|
115
110
|
}
|
|
@@ -38,20 +38,21 @@ function useUpdateThemeSettings() {
|
|
|
38
38
|
const systemSettings = (0, _client().useSystemSettings)();
|
|
39
39
|
const updateUserThemeSettings = (0, _react().useCallback)( /*#__PURE__*/function () {
|
|
40
40
|
var _ref = _asyncToGenerator(function* (themeId) {
|
|
41
|
-
|
|
41
|
+
var _currentUser$data$dat;
|
|
42
|
+
if (themeId === ((_currentUser$data$dat = currentUser.data.data.systemSettings) === null || _currentUser$data$dat === void 0 ? void 0 : _currentUser$data$dat.themeId)) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
try {
|
|
45
46
|
yield api.resource('users').updateProfile({
|
|
46
47
|
values: {
|
|
47
|
-
systemSettings: _objectSpread(_objectSpread({}, currentUser.data.data.systemSettings), {}, {
|
|
48
|
+
systemSettings: _objectSpread(_objectSpread({}, currentUser.data.data.systemSettings || {}), {}, {
|
|
48
49
|
themeId
|
|
49
50
|
})
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
53
|
currentUser.mutate({
|
|
53
54
|
data: _objectSpread(_objectSpread({}, currentUser.data.data), {}, {
|
|
54
|
-
systemSettings: _objectSpread(_objectSpread({}, currentUser.data.data.systemSettings), {}, {
|
|
55
|
+
systemSettings: _objectSpread(_objectSpread({}, currentUser.data.data.systemSettings || {}), {}, {
|
|
55
56
|
themeId
|
|
56
57
|
})
|
|
57
58
|
})
|
|
@@ -66,21 +67,22 @@ function useUpdateThemeSettings() {
|
|
|
66
67
|
}(), [api, currentUser]);
|
|
67
68
|
const updateSystemThemeSettings = (0, _react().useCallback)( /*#__PURE__*/function () {
|
|
68
69
|
var _ref2 = _asyncToGenerator(function* (themeId) {
|
|
69
|
-
|
|
70
|
+
var _systemSettings$data$;
|
|
71
|
+
if (themeId === ((_systemSettings$data$ = systemSettings.data.data.options) === null || _systemSettings$data$ === void 0 ? void 0 : _systemSettings$data$.themeId)) {
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
74
|
yield api.request({
|
|
73
75
|
url: 'systemSettings:update/1',
|
|
74
76
|
method: 'post',
|
|
75
77
|
data: {
|
|
76
|
-
options: _objectSpread(_objectSpread({}, systemSettings.data.data.options), {}, {
|
|
78
|
+
options: _objectSpread(_objectSpread({}, systemSettings.data.data.options || {}), {}, {
|
|
77
79
|
themeId
|
|
78
80
|
})
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
systemSettings.mutate({
|
|
82
84
|
data: _objectSpread(_objectSpread({}, systemSettings.data.data), {}, {
|
|
83
|
-
options: _objectSpread(_objectSpread({}, systemSettings.data.data.options), {}, {
|
|
85
|
+
options: _objectSpread(_objectSpread({}, systemSettings.data.data.options || {}), {}, {
|
|
84
86
|
themeId
|
|
85
87
|
})
|
|
86
88
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-theme-editor",
|
|
3
|
-
"version": "0.11.1-alpha.
|
|
3
|
+
"version": "0.11.1-alpha.5",
|
|
4
4
|
"main": "lib/server/index.js",
|
|
5
5
|
"displayName": "Theme editor",
|
|
6
6
|
"displayName.zh-CN": "主题编辑器",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"@ant-design/cssinjs": "^1.11.1",
|
|
22
22
|
"@ant-design/icons": "^5.1.4",
|
|
23
23
|
"@emotion/css": "^11.11.2",
|
|
24
|
-
"@nocobase/client": "0.11.1-alpha.
|
|
25
|
-
"@nocobase/database": "0.11.1-alpha.
|
|
26
|
-
"@nocobase/server": "0.11.1-alpha.
|
|
27
|
-
"@nocobase/test": "0.11.1-alpha.
|
|
28
|
-
"@nocobase/utils": "0.11.1-alpha.
|
|
24
|
+
"@nocobase/client": "0.11.1-alpha.5",
|
|
25
|
+
"@nocobase/database": "0.11.1-alpha.5",
|
|
26
|
+
"@nocobase/server": "0.11.1-alpha.5",
|
|
27
|
+
"@nocobase/test": "0.11.1-alpha.5",
|
|
28
|
+
"@nocobase/utils": "0.11.1-alpha.5",
|
|
29
29
|
"antd": "^5.6.4",
|
|
30
30
|
"lodash": "4.17.21",
|
|
31
31
|
"react": "^18.2.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "1dcfd15a7d95a40b0a2f60e1de19ec574066fb20"
|
|
34
34
|
}
|
|
@@ -68,12 +68,7 @@ function Label() {
|
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
if (!
|
|
72
|
-
error('Please check if provide `CurrentUserProvider` in your app.');
|
|
73
|
-
throw new Error('Please check if provide `CurrentUserProvider` in your app.');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!systemSettings?.data?.data?.options) {
|
|
71
|
+
if (!systemSettings) {
|
|
77
72
|
error('Please check if provide `SystemSettingsProvider` in your app.');
|
|
78
73
|
throw new Error('Please check if provide `SystemSettingsProvider` in your app.');
|
|
79
74
|
}
|
|
@@ -9,14 +9,14 @@ export function useUpdateThemeSettings() {
|
|
|
9
9
|
|
|
10
10
|
const updateUserThemeSettings = useCallback(
|
|
11
11
|
async (themeId: number | null) => {
|
|
12
|
-
if (themeId === currentUser.data.data.systemSettings
|
|
12
|
+
if (themeId === currentUser.data.data.systemSettings?.themeId) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
16
|
await api.resource('users').updateProfile({
|
|
17
17
|
values: {
|
|
18
18
|
systemSettings: {
|
|
19
|
-
...currentUser.data.data.systemSettings,
|
|
19
|
+
...(currentUser.data.data.systemSettings || {}),
|
|
20
20
|
themeId,
|
|
21
21
|
},
|
|
22
22
|
},
|
|
@@ -25,7 +25,7 @@ export function useUpdateThemeSettings() {
|
|
|
25
25
|
data: {
|
|
26
26
|
...currentUser.data.data,
|
|
27
27
|
systemSettings: {
|
|
28
|
-
...currentUser.data.data.systemSettings,
|
|
28
|
+
...(currentUser.data.data.systemSettings || {}),
|
|
29
29
|
themeId,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
@@ -39,7 +39,7 @@ export function useUpdateThemeSettings() {
|
|
|
39
39
|
|
|
40
40
|
const updateSystemThemeSettings = useCallback(
|
|
41
41
|
async (themeId: number | null) => {
|
|
42
|
-
if (themeId === systemSettings.data.data.options
|
|
42
|
+
if (themeId === systemSettings.data.data.options?.themeId) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
await api.request({
|
|
@@ -47,7 +47,7 @@ export function useUpdateThemeSettings() {
|
|
|
47
47
|
method: 'post',
|
|
48
48
|
data: {
|
|
49
49
|
options: {
|
|
50
|
-
...systemSettings.data.data.options,
|
|
50
|
+
...(systemSettings.data.data.options || {}),
|
|
51
51
|
themeId,
|
|
52
52
|
},
|
|
53
53
|
},
|
|
@@ -56,7 +56,7 @@ export function useUpdateThemeSettings() {
|
|
|
56
56
|
data: {
|
|
57
57
|
...systemSettings.data.data,
|
|
58
58
|
options: {
|
|
59
|
-
...systemSettings.data.data.options,
|
|
59
|
+
...(systemSettings.data.data.options || {}),
|
|
60
60
|
themeId,
|
|
61
61
|
},
|
|
62
62
|
},
|