@chlp-tech/rpa-ui 0.0.14 → 0.0.15-beta-1

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.
@@ -27,6 +27,7 @@ interface AccountBlockProps {
27
27
  interface PublishAccountProps {
28
28
  accounts: SocialMediaAccounts;
29
29
  boxWidth?: number | string;
30
+ defaultSelectAccount?: Account;
30
31
  onAccountSelect: (account: Account) => void;
31
32
  onErrorClose?: (account: Account) => void;
32
33
  }
@@ -76,8 +76,9 @@ var PublishAccount = function PublishAccount(_ref2) {
76
76
  var accounts = _ref2.accounts,
77
77
  onAccountSelect = _ref2.onAccountSelect,
78
78
  onErrorClose = _ref2.onErrorClose,
79
- boxWidth = _ref2.boxWidth;
80
- var _useState = useState(null),
79
+ boxWidth = _ref2.boxWidth,
80
+ defaultSelectAccount = _ref2.defaultSelectAccount;
81
+ var _useState = useState(defaultSelectAccount),
81
82
  _useState2 = _slicedToArray(_useState, 2),
82
83
  selectedAccount = _useState2[0],
83
84
  setSelectedAccount = _useState2[1];
@@ -90,13 +91,34 @@ var PublishAccount = function PublishAccount(_ref2) {
90
91
  }
91
92
  return null;
92
93
  };
94
+
95
+ // 判断是否存在
96
+ var isExitInAccounts = function isExitInAccounts(account) {
97
+ if (!account) return false;
98
+ for (var _i2 = 0, _arr2 = ['fb', 'ins', 'tk', 'yt']; _i2 < _arr2.length; _i2++) {
99
+ var platform = _arr2[_i2];
100
+ if (accounts[platform] && accounts[platform].length > 0 && accounts[platform].some(function (item) {
101
+ return item.value === account.value;
102
+ })) {
103
+ return true;
104
+ }
105
+ }
106
+ return false;
107
+ };
93
108
  useEffect(function () {
94
- var firstAccount = getFirstAvailableAccount();
95
- if (firstAccount) {
96
- setSelectedAccount(firstAccount);
97
- onAccountSelect(firstAccount);
109
+ if (defaultSelectAccount) {
110
+ setSelectedAccount(defaultSelectAccount);
111
+ } else {
112
+ if (!selectedAccount && isExitInAccounts(selectedAccount)) {
113
+ return;
114
+ }
115
+ var firstAccount = getFirstAvailableAccount();
116
+ if (firstAccount) {
117
+ setSelectedAccount(firstAccount);
118
+ onAccountSelect(firstAccount);
119
+ }
98
120
  }
99
- }, [accounts]);
121
+ }, [accounts, defaultSelectAccount]);
100
122
  var renderAccounts = function renderAccounts(platform, icon) {
101
123
  var _accounts$platform;
102
124
  if (!accounts[platform] || accounts[platform].length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chlp-tech/rpa-ui",
3
- "version": "0.0.14",
3
+ "version": "0.0.15-beta-1",
4
4
  "description": "rpa-ui",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",