gyyg-components 0.1.15 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gyyg-components",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -98,12 +98,12 @@
98
98
  </div>
99
99
  </template>
100
100
  <script>
101
- import deepCopy from './methods'
101
+ import { deepCopy } from "@/utils/common.js";
102
102
  import styleText from './styleText.vue'
103
103
  import btnClick from './btnClick.vue'
104
104
  import iconButton from './iconButton.vue';
105
105
  export default {
106
- name: 'emc-table',
106
+ name: 'EmcTable',
107
107
  components: {
108
108
  styleText,
109
109
  btnClick,
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ const components = modulesFiles.keys().reduce((components, modulePath) => {
7
7
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, "$1");
8
8
  const value = modulesFiles(modulePath);
9
9
  components[moduleName] = value.default;
10
+
10
11
  return components;
11
12
  }, {});
12
13
 
@@ -17,6 +18,7 @@ const install = function (Vue) {
17
18
  if (install.installed) return;
18
19
  // 遍历注册全局组件
19
20
  Object.values(components).forEach((component) => {
21
+
20
22
  // 如果组件提供了 install 方法,则使用 install 方法注册
21
23
  if (typeof component.install === "function") {
22
24
  Vue.use(component);
@@ -34,6 +36,7 @@ const install = function (Vue) {
34
36
 
35
37
  // 判断是否是直接引入文件
36
38
  if (typeof window !== "undefined" && window.Vue) {
39
+
37
40
  install(window.Vue);
38
41
  }
39
42
 
@@ -16,6 +16,66 @@ export function isEmpty(value) {
16
16
  }
17
17
  return false;
18
18
  }
19
+ // 深拷贝
20
+ export function deepCopy(obj, hash = new WeakMap()) {
21
+ // 处理 null、undefined 和非对象类型(如数字、字符串、布尔值等)
22
+ if (obj === null || typeof obj !== 'object') {
23
+ return obj;
24
+ }
25
+
26
+ // 处理循环引用
27
+ if (hash.has(obj)) {
28
+ return hash.get(obj);
29
+ }
30
+
31
+ // 处理 Date 对象
32
+ if (obj instanceof Date) {
33
+ return new Date(obj);
34
+ }
35
+
36
+ // 处理 Array 对象
37
+ if (Array.isArray(obj)) {
38
+ const copy = [];
39
+ hash.set(obj, copy);
40
+ for (let i = 0; i < obj.length; i++) {
41
+ copy[i] = deepCopy(obj[i], hash);
42
+ }
43
+ return copy;
44
+ }
45
+
46
+ // 处理普通对象
47
+ const copy = {};
48
+ hash.set(obj, copy);
49
+ for (const key in obj) {
50
+ if (obj.hasOwnProperty(key)) {
51
+ copy[key] = deepCopy(obj[key], hash);
52
+ }
53
+ }
54
+
55
+ // 处理 Map 和 Set 对象(可选)
56
+ if (obj instanceof Map) {
57
+ const copy = new Map();
58
+ hash.set(obj, copy);
59
+ obj.forEach((value, key) => {
60
+ copy.set(deepCopy(key, hash), deepCopy(value, hash));
61
+ });
62
+ return copy;
63
+ }
64
+
65
+ if (obj instanceof Set) {
66
+ const copy = new Set();
67
+ hash.set(obj, copy);
68
+ obj.forEach(value => {
69
+ copy.add(deepCopy(value, hash));
70
+ });
71
+ return copy;
72
+ }
73
+
74
+ // 处理其他类型的对象(如自定义对象、TypedArray 等)可能需要额外的逻辑
75
+ // 这里默认返回空对象或基本类型的值(如果上述条件都不满足)
76
+ return copy;
77
+ }
78
+
19
79
  /**
20
80
  * @param {string} path
21
81
  * @returns {Boolean}
@@ -1,59 +0,0 @@
1
- // 深拷贝
2
- export default function deepCopy(obj, hash = new WeakMap()) {
3
- // 处理 null、undefined 和非对象类型(如数字、字符串、布尔值等)
4
- if (obj === null || typeof obj !== 'object') {
5
- return obj;
6
- }
7
-
8
- // 处理循环引用
9
- if (hash.has(obj)) {
10
- return hash.get(obj);
11
- }
12
-
13
- // 处理 Date 对象
14
- if (obj instanceof Date) {
15
- return new Date(obj);
16
- }
17
-
18
- // 处理 Array 对象
19
- if (Array.isArray(obj)) {
20
- const copy = [];
21
- hash.set(obj, copy);
22
- for (let i = 0; i < obj.length; i++) {
23
- copy[i] = deepCopy(obj[i], hash);
24
- }
25
- return copy;
26
- }
27
-
28
- // 处理普通对象
29
- const copy = {};
30
- hash.set(obj, copy);
31
- for (const key in obj) {
32
- if (obj.hasOwnProperty(key)) {
33
- copy[key] = deepCopy(obj[key], hash);
34
- }
35
- }
36
-
37
- // 处理 Map 和 Set 对象(可选)
38
- if (obj instanceof Map) {
39
- const copy = new Map();
40
- hash.set(obj, copy);
41
- obj.forEach((value, key) => {
42
- copy.set(deepCopy(key, hash), deepCopy(value, hash));
43
- });
44
- return copy;
45
- }
46
-
47
- if (obj instanceof Set) {
48
- const copy = new Set();
49
- hash.set(obj, copy);
50
- obj.forEach(value => {
51
- copy.add(deepCopy(value, hash));
52
- });
53
- return copy;
54
- }
55
-
56
- // 处理其他类型的对象(如自定义对象、TypedArray 等)可能需要额外的逻辑
57
- // 这里默认返回空对象或基本类型的值(如果上述条件都不满足)
58
- return copy;
59
- }