@abtnode/ux 1.8.65-beta-f7af64a4 → 1.8.65-beta-db7f2529
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/lib/blocklet/storage.js +33 -19
- package/lib/locales/en.js +0 -7
- package/lib/locales/zh.js +0 -7
- package/lib/util/mode.js +11 -0
- package/package.json +14 -14
package/lib/blocklet/storage.js
CHANGED
|
@@ -29,7 +29,20 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
29
29
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
30
30
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
31
31
|
function Storage() {
|
|
32
|
-
var _blocklet$environment;
|
|
32
|
+
var _localStorage$getItem, _blocklet$environment, _blocklet$environment2, _blocklet$environment3;
|
|
33
|
+
const options = [
|
|
34
|
+
// TODO: 测试用,上线后才需删除
|
|
35
|
+
{
|
|
36
|
+
value: (_localStorage$getItem = localStorage.getItem('test-spaces')) !== null && _localStorage$getItem !== void 0 && _localStorage$getItem.startsWith('http') ? localStorage.getItem('test-spaces') : 'https://bbqazi2fhuczchrlggs4njj2bucbvnwjjm2xlq6yk6i.did.abtnet.io',
|
|
37
|
+
label: 'test spaces'
|
|
38
|
+
}, {
|
|
39
|
+
value: 'https://storage.staging.abtnet.io/app',
|
|
40
|
+
label: 'staging spaces'
|
|
41
|
+
}, {
|
|
42
|
+
value: 'https://service.didspaces.com/app',
|
|
43
|
+
label: 'prod spaces'
|
|
44
|
+
}];
|
|
45
|
+
|
|
33
46
|
/** @type {{ api: import('@abtnode/client').ABTNodeClient }} */
|
|
34
47
|
const {
|
|
35
48
|
api
|
|
@@ -44,7 +57,7 @@ function Storage() {
|
|
|
44
57
|
blocklet
|
|
45
58
|
} = (0, _blocklet.useBlockletContext)();
|
|
46
59
|
const [endpoint, setEndpoint] = (0, _react.useState)(((_blocklet$environment = blocklet.environments.find(e => e.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)) === null || _blocklet$environment === void 0 ? void 0 : _blocklet$environment.value) || '');
|
|
47
|
-
const [didSpacesUrl, setDidSpacesUrl] = (0, _react.useState)(
|
|
60
|
+
const [didSpacesUrl, setDidSpacesUrl] = (0, _react.useState)((_blocklet$environment2 = (_blocklet$environment3 = blocklet.environments.find(e => e.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACES_URL)) === null || _blocklet$environment3 === void 0 ? void 0 : _blocklet$environment3.value) !== null && _blocklet$environment2 !== void 0 ? _blocklet$environment2 : options[0].value);
|
|
48
61
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
49
62
|
const {
|
|
50
63
|
appDid
|
|
@@ -78,6 +91,15 @@ function Storage() {
|
|
|
78
91
|
_toast.default.error(error.message);
|
|
79
92
|
});
|
|
80
93
|
}
|
|
94
|
+
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
95
|
+
setEndpoint(decrypt(response.endpoint));
|
|
96
|
+
await saveStorageEndpoint(blocklet.meta.did, decrypt(response.endpoint));
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
99
|
+
open: false
|
|
100
|
+
}));
|
|
101
|
+
}, 3000);
|
|
102
|
+
};
|
|
81
103
|
const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
|
|
82
104
|
open: false,
|
|
83
105
|
action: 'one-click-authorization',
|
|
@@ -85,19 +107,6 @@ function Storage() {
|
|
|
85
107
|
checkFn: _axios.default.create({
|
|
86
108
|
baseURL: (0, _urlJoin.default)(didSpacesUrl, 'space')
|
|
87
109
|
}).get,
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {{endpoint: string}} response
|
|
91
|
-
*/
|
|
92
|
-
onSuccess: async (response, decrypt) => {
|
|
93
|
-
setEndpoint(decrypt(response.endpoint));
|
|
94
|
-
await saveStorageEndpoint(blocklet.meta.did, decrypt(response.endpoint));
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
97
|
-
open: false
|
|
98
|
-
}));
|
|
99
|
-
}, 3000);
|
|
100
|
-
},
|
|
101
110
|
onClose: () => {
|
|
102
111
|
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
103
112
|
open: false
|
|
@@ -130,9 +139,9 @@ function Storage() {
|
|
|
130
139
|
} = event.target;
|
|
131
140
|
if ((0, _lodash.isEmpty)(value)) {
|
|
132
141
|
setErrorMessage(t('storage.didSpaces.addressCannotEmpty', locale));
|
|
133
|
-
|
|
134
|
-
setErrorMessage(null);
|
|
142
|
+
return;
|
|
135
143
|
}
|
|
144
|
+
setErrorMessage(null);
|
|
136
145
|
setDidSpacesUrl(value);
|
|
137
146
|
};
|
|
138
147
|
const onBackup = async () => {
|
|
@@ -173,6 +182,7 @@ function Storage() {
|
|
|
173
182
|
}, [appName, locale, t]);
|
|
174
183
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
|
|
175
184
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StorageUrlTextField, {
|
|
185
|
+
select: true,
|
|
176
186
|
sx: {
|
|
177
187
|
marginTop: '20px'
|
|
178
188
|
},
|
|
@@ -199,7 +209,11 @@ function Storage() {
|
|
|
199
209
|
},
|
|
200
210
|
children: endpoint ? t('storage.didSpaces.reAuthorization') : t('storage.didSpaces.goToAuthorization')
|
|
201
211
|
})
|
|
202
|
-
}
|
|
212
|
+
},
|
|
213
|
+
children: options.map(option => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
214
|
+
value: option.value,
|
|
215
|
+
children: option.label
|
|
216
|
+
}, option.value))
|
|
203
217
|
}), endpoint && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
204
218
|
color: "text.secondary",
|
|
205
219
|
sx: {
|
|
@@ -241,7 +255,7 @@ function Storage() {
|
|
|
241
255
|
action: authorizeConnect.action,
|
|
242
256
|
baseUrl: authorizeConnect.baseUrl,
|
|
243
257
|
checkFn: authorizeConnect.checkFn,
|
|
244
|
-
onSuccess:
|
|
258
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
245
259
|
onClose: authorizeConnect.onClose,
|
|
246
260
|
checkTimeout: authorizeConnect.checkTimeout,
|
|
247
261
|
extraParams: authorizeConnect.extraParams,
|
package/lib/locales/en.js
CHANGED
|
@@ -280,13 +280,6 @@ module.exports = {
|
|
|
280
280
|
installFromMarket: 'Install New Blocklets',
|
|
281
281
|
installFromUrl: 'Install From Url',
|
|
282
282
|
installFromCreate: 'Create Blocklet',
|
|
283
|
-
restoreFromSpaces: 'Restore from Spaces',
|
|
284
|
-
restoreFromSpacesForm: {
|
|
285
|
-
endpoint: 'Spaces endpoint',
|
|
286
|
-
blockletSecretKey: "blocklet's secret key",
|
|
287
|
-
restore: 'Restore',
|
|
288
|
-
successfully: 'Restored successfully'
|
|
289
|
-
},
|
|
290
283
|
installedAt: 'Installed At',
|
|
291
284
|
internal: 'Internal',
|
|
292
285
|
startedAt: 'Started At',
|
package/lib/locales/zh.js
CHANGED
|
@@ -286,13 +286,6 @@ module.exports = {
|
|
|
286
286
|
installFromMarket: '从应用商店安装',
|
|
287
287
|
installFromUrl: '通过 URL 安装',
|
|
288
288
|
installFromCreate: '创建基石程序',
|
|
289
|
-
restoreFromSpaces: '从 Spaces 还原',
|
|
290
|
-
restoreFromSpacesForm: {
|
|
291
|
-
endpoint: 'Spaces 端点',
|
|
292
|
-
blockletSecretKey: 'blocklet 的私钥',
|
|
293
|
-
restore: '还原',
|
|
294
|
-
successfully: '还原成功'
|
|
295
|
-
},
|
|
296
289
|
installedAt: '安装时间',
|
|
297
290
|
internal: '内部',
|
|
298
291
|
startedAt: '启动时间',
|
package/lib/util/mode.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isAlphaMode = void 0;
|
|
7
|
+
/* eslint-disable import/prefer-default-export */
|
|
8
|
+
|
|
9
|
+
// 当前模式是 内测模式 吗? @see: https://developer.aliyun.com/article/572525
|
|
10
|
+
const isAlphaMode = localStorage.getItem('enableAlphaMode') === 'true';
|
|
11
|
+
exports.isAlphaMode = isAlphaMode;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.65-beta-
|
|
6
|
+
"version": "1.8.65-beta-db7f2529",
|
|
7
7
|
"description": "UX components shared across abtnode packages",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@abtnode/auth": "1.8.65-beta-
|
|
25
|
-
"@abtnode/constant": "1.8.65-beta-
|
|
26
|
-
"@abtnode/util": "1.8.65-beta-
|
|
27
|
-
"@arcblock/did-connect": "^2.4.
|
|
24
|
+
"@abtnode/auth": "1.8.65-beta-db7f2529",
|
|
25
|
+
"@abtnode/constant": "1.8.65-beta-db7f2529",
|
|
26
|
+
"@abtnode/util": "1.8.65-beta-db7f2529",
|
|
27
|
+
"@arcblock/did-connect": "^2.4.71",
|
|
28
28
|
"@arcblock/did-motif": "^1.1.10",
|
|
29
|
-
"@arcblock/icons": "^2.4.
|
|
30
|
-
"@arcblock/terminal": "^2.4.
|
|
31
|
-
"@arcblock/ux": "^2.4.
|
|
32
|
-
"@blocklet/constant": "1.8.65-beta-
|
|
33
|
-
"@blocklet/launcher-layout": "^1.9.
|
|
34
|
-
"@blocklet/list": "^0.10.
|
|
35
|
-
"@blocklet/meta": "1.8.65-beta-
|
|
36
|
-
"@blocklet/ui-react": "^2.4.
|
|
29
|
+
"@arcblock/icons": "^2.4.71",
|
|
30
|
+
"@arcblock/terminal": "^2.4.71",
|
|
31
|
+
"@arcblock/ux": "^2.4.71",
|
|
32
|
+
"@blocklet/constant": "1.8.65-beta-db7f2529",
|
|
33
|
+
"@blocklet/launcher-layout": "^1.9.58",
|
|
34
|
+
"@blocklet/list": "^0.10.50",
|
|
35
|
+
"@blocklet/meta": "1.8.65-beta-db7f2529",
|
|
36
|
+
"@blocklet/ui-react": "^2.4.71",
|
|
37
37
|
"@emotion/react": "^11.10.4",
|
|
38
38
|
"@emotion/styled": "^11.10.4",
|
|
39
39
|
"@iconify/react": "^4.0.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"@babel/preset-react": "^7.18.6",
|
|
87
87
|
"babel-plugin-inline-react-svg": "^1.1.2"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "b9cd53d1db3535a691aebed2ff6f9053376d46dc"
|
|
90
90
|
}
|