yootd 0.0.89 → 0.0.90

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.
@@ -14,6 +14,7 @@ export interface TableProps<T = AnyObject> extends Omit<AntTableProps<T>, 'colum
14
14
  headerBgColor?: string;
15
15
  headerTextColor?: string;
16
16
  showSetting?: boolean;
17
+ persistKeys?: string;
17
18
  }
18
19
  export interface ColumnType<T = AnyObject> extends Omit<AntColumnType<T>, 'key'> {
19
20
  key: React.Key;
@@ -1,4 +1,4 @@
1
- var _excluded = ["type", "showSetting", "columns", "components", "headerBgColor", "headerTextColor"];
1
+ var _excluded = ["type", "showSetting", "columns", "components", "persistKeys", "headerBgColor", "headerTextColor"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -29,6 +29,7 @@ var InternalTable = function InternalTable(_ref, ref) {
29
29
  showSetting = _ref.showSetting,
30
30
  columns = _ref.columns,
31
31
  components = _ref.components,
32
+ persistKeys = _ref.persistKeys,
32
33
  headerBgColor = _ref.headerBgColor,
33
34
  headerTextColor = _ref.headerTextColor,
34
35
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -103,6 +104,14 @@ var InternalTable = function InternalTable(_ref, ref) {
103
104
  };
104
105
  var updateKeys = function updateKeys(keys) {
105
106
  setKeys(keys);
107
+ // 检查浏览器是否支持 localStorage
108
+ try {
109
+ if (typeof localStorage !== 'undefined' && persistKeys != null && persistKeys !== '') {
110
+ localStorage.setItem(persistKeys, JSON.stringify(keys));
111
+ }
112
+ } catch (e) {
113
+ console.error(e);
114
+ }
106
115
  };
107
116
  var filterColumns = function filterColumns(columns, keys) {
108
117
  return columns.filter(function (c) {
@@ -119,6 +128,19 @@ var InternalTable = function InternalTable(_ref, ref) {
119
128
  setInnerColumns(_columns);
120
129
  setKeys(_keys);
121
130
  }, [columns]);
131
+ useEffect(function () {
132
+ try {
133
+ if (typeof localStorage !== 'undefined' && persistKeys != null && persistKeys !== '') {
134
+ // 获取当前在代码中的行号
135
+ var _keys2 = localStorage.getItem(persistKeys);
136
+ if (_keys2) {
137
+ setKeys(JSON.parse(_keys2));
138
+ }
139
+ }
140
+ } catch (error) {
141
+ console.error(error);
142
+ }
143
+ }, [persistKeys]);
122
144
  return /*#__PURE__*/React.createElement(TableRowContext.Provider, {
123
145
  value: {
124
146
  columns: innerColumns,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yootd",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",