@abtnode/ux 1.8.65-beta-bfcc12ce → 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 +12 -16
- package/package.json +7 -7
package/lib/blocklet/storage.js
CHANGED
|
@@ -29,7 +29,7 @@ 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 _localStorage$getItem, _blocklet$environment;
|
|
32
|
+
var _localStorage$getItem, _blocklet$environment, _blocklet$environment2, _blocklet$environment3;
|
|
33
33
|
const options = [
|
|
34
34
|
// TODO: 测试用,上线后才需删除
|
|
35
35
|
{
|
|
@@ -42,7 +42,6 @@ function Storage() {
|
|
|
42
42
|
value: 'https://service.didspaces.com/app',
|
|
43
43
|
label: 'prod spaces'
|
|
44
44
|
}];
|
|
45
|
-
const [didSpacesUrl, setDidSpacesUrl] = (0, _react.useState)(options[0].value);
|
|
46
45
|
|
|
47
46
|
/** @type {{ api: import('@abtnode/client').ABTNodeClient }} */
|
|
48
47
|
const {
|
|
@@ -58,6 +57,7 @@ function Storage() {
|
|
|
58
57
|
blocklet
|
|
59
58
|
} = (0, _blocklet.useBlockletContext)();
|
|
60
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) || '');
|
|
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);
|
|
61
61
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
62
62
|
const {
|
|
63
63
|
appDid
|
|
@@ -91,6 +91,15 @@ function Storage() {
|
|
|
91
91
|
_toast.default.error(error.message);
|
|
92
92
|
});
|
|
93
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
|
+
};
|
|
94
103
|
const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
|
|
95
104
|
open: false,
|
|
96
105
|
action: 'one-click-authorization',
|
|
@@ -98,19 +107,6 @@ function Storage() {
|
|
|
98
107
|
checkFn: _axios.default.create({
|
|
99
108
|
baseURL: (0, _urlJoin.default)(didSpacesUrl, 'space')
|
|
100
109
|
}).get,
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @param {{endpoint: string}} response
|
|
104
|
-
*/
|
|
105
|
-
onSuccess: async (response, decrypt) => {
|
|
106
|
-
setEndpoint(decrypt(response.endpoint));
|
|
107
|
-
await saveStorageEndpoint(blocklet.meta.did, decrypt(response.endpoint));
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
110
|
-
open: false
|
|
111
|
-
}));
|
|
112
|
-
}, 3000);
|
|
113
|
-
},
|
|
114
110
|
onClose: () => {
|
|
115
111
|
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
116
112
|
open: false
|
|
@@ -259,7 +255,7 @@ function Storage() {
|
|
|
259
255
|
action: authorizeConnect.action,
|
|
260
256
|
baseUrl: authorizeConnect.baseUrl,
|
|
261
257
|
checkFn: authorizeConnect.checkFn,
|
|
262
|
-
onSuccess:
|
|
258
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
263
259
|
onClose: authorizeConnect.onClose,
|
|
264
260
|
checkTimeout: authorizeConnect.checkTimeout,
|
|
265
261
|
extraParams: authorizeConnect.extraParams,
|
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,18 +21,18 @@
|
|
|
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-
|
|
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
27
|
"@arcblock/did-connect": "^2.4.71",
|
|
28
28
|
"@arcblock/did-motif": "^1.1.10",
|
|
29
29
|
"@arcblock/icons": "^2.4.71",
|
|
30
30
|
"@arcblock/terminal": "^2.4.71",
|
|
31
31
|
"@arcblock/ux": "^2.4.71",
|
|
32
|
-
"@blocklet/constant": "1.8.65-beta-
|
|
32
|
+
"@blocklet/constant": "1.8.65-beta-db7f2529",
|
|
33
33
|
"@blocklet/launcher-layout": "^1.9.58",
|
|
34
34
|
"@blocklet/list": "^0.10.50",
|
|
35
|
-
"@blocklet/meta": "1.8.65-beta-
|
|
35
|
+
"@blocklet/meta": "1.8.65-beta-db7f2529",
|
|
36
36
|
"@blocklet/ui-react": "^2.4.71",
|
|
37
37
|
"@emotion/react": "^11.10.4",
|
|
38
38
|
"@emotion/styled": "^11.10.4",
|
|
@@ -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
|
}
|