kk-vue-hooks 1.0.0 → 1.0.3
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/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +25 -10
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useStorage.ts +0 -43
- package/src/index.ts +0 -4
package/dist/index.cjs.js
CHANGED
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/hooks/useStorage.ts"],"sourcesContent":["// src/hooks/useStorage.ts\n/**\n * 本地存储 Hook(localStorage 封装)\n * @param key 存储键名\n * @param defaultValue 默认值\n * @returns 获取值、设置值、删除值的方法\n */\nexport function useStorage<T>(key: string, defaultValue: T) {\n // 获取存储值\n const getStorage = (): T => {\n try {\n const value = localStorage.getItem(key)
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/hooks/useStorage.ts"],"sourcesContent":["// src/hooks/useStorage.ts\n/**\n * 本地存储 Hook(localStorage 封装)\n * @param key 存储键名\n * @param defaultValue 默认值\n * @returns 获取值、设置值、删除值的方法\n */\nexport function useStorage<T>(key: string, defaultValue: T) {\n // 获取存储值\n const getStorage = (): T => {\n try {\n const value = localStorage.getItem(key)\n return value ? JSON.parse(value) : defaultValue\n }\n catch (error) {\n console.error('获取本地存储失败:', error)\n return defaultValue\n }\n }\n\n // 设置存储值\n const setStorage = (value: T) => {\n try {\n localStorage.setItem(key, JSON.stringify(value))\n }\n catch (error) {\n console.error('设置本地存储失败:', error)\n }\n }\n\n // 删除存储值\n const removeStorage = () => {\n try {\n localStorage.removeItem(key)\n }\n catch (error) {\n console.error('删除本地存储失败:', error)\n }\n }\n\n return {\n value: getStorage(),\n setStorage,\n removeStorage,\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;;;;;AAKG;AACG,SAAU,UAAU,CAAI,GAAW,EAAE,YAAe,EAAA;;IAExD,MAAM,UAAU,GAAG,MAAQ;AACzB,QAAA,IAAI;YACF,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;AACvC,YAAA,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,YAAY;QACjD;QACA,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC;AACjC,YAAA,OAAO,YAAY;QACrB;AACF,IAAA,CAAC;;AAGD,IAAA,MAAM,UAAU,GAAG,CAAC,KAAQ,KAAI;AAC9B,QAAA,IAAI;AACF,YAAA,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAClD;QACA,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC;QACnC;AACF,IAAA,CAAC;;IAGD,MAAM,aAAa,GAAG,MAAK;AACzB,QAAA,IAAI;AACF,YAAA,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QAC9B;QACA,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC;QACnC;AACF,IAAA,CAAC;IAED,OAAO;QACL,KAAK,EAAE,UAAU,EAAE;QACnB,UAAU;QACV,aAAa;KACd;AACH;;;;"}
|
package/dist/index.esm.js
CHANGED
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/hooks/useStorage.ts"],"sourcesContent":["// src/hooks/useStorage.ts\n/**\n * 本地存储 Hook(localStorage 封装)\n * @param key 存储键名\n * @param defaultValue 默认值\n * @returns 获取值、设置值、删除值的方法\n */\nexport function useStorage<T>(key: string, defaultValue: T) {\n // 获取存储值\n const getStorage = (): T => {\n try {\n const value = localStorage.getItem(key)
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/hooks/useStorage.ts"],"sourcesContent":["// src/hooks/useStorage.ts\n/**\n * 本地存储 Hook(localStorage 封装)\n * @param key 存储键名\n * @param defaultValue 默认值\n * @returns 获取值、设置值、删除值的方法\n */\nexport function useStorage<T>(key: string, defaultValue: T) {\n // 获取存储值\n const getStorage = (): T => {\n try {\n const value = localStorage.getItem(key)\n return value ? JSON.parse(value) : defaultValue\n }\n catch (error) {\n console.error('获取本地存储失败:', error)\n return defaultValue\n }\n }\n\n // 设置存储值\n const setStorage = (value: T) => {\n try {\n localStorage.setItem(key, JSON.stringify(value))\n }\n catch (error) {\n console.error('设置本地存储失败:', error)\n }\n }\n\n // 删除存储值\n const removeStorage = () => {\n try {\n localStorage.removeItem(key)\n }\n catch (error) {\n console.error('删除本地存储失败:', error)\n }\n }\n\n return {\n value: getStorage(),\n setStorage,\n removeStorage,\n }\n}\n"],"names":[],"mappings":"AAAA;AACA;;;;;AAKG;AACG,SAAU,UAAU,CAAI,GAAW,EAAE,YAAe,EAAA;;IAExD,MAAM,UAAU,GAAG,MAAQ;AACzB,QAAA,IAAI;YACF,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;AACvC,YAAA,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,YAAY;QACjD;QACA,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC;AACjC,YAAA,OAAO,YAAY;QACrB;AACF,IAAA,CAAC;;AAGD,IAAA,MAAM,UAAU,GAAG,CAAC,KAAQ,KAAI;AAC9B,QAAA,IAAI;AACF,YAAA,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAClD;QACA,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC;QACnC;AACF,IAAA,CAAC;;IAGD,MAAM,aAAa,GAAG,MAAK;AACzB,QAAA,IAAI;AACF,YAAA,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QAC9B;QACA,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC;QACnC;AACF,IAAA,CAAC;IAED,OAAO;QACL,KAAK,EAAE,UAAU,EAAE;QACnB,UAAU;QACV,aAAa;KACd;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kk-vue-hooks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "自定义 Vue/React Hooks 集合",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
9
|
-
"files": [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
14
|
"keywords": [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
"vue-hooks",
|
|
16
|
+
"react-hooks",
|
|
17
|
+
"useRequest",
|
|
18
|
+
"useStorage"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "rollup -c",
|
|
22
22
|
"prebuild": "rm -rf dist",
|
|
23
|
+
"lint": "eslint src --ext .ts",
|
|
24
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
25
|
+
"lint:style": "stylelint \"src/**/*.{css,scss}\"",
|
|
26
|
+
"pack:check": "npm pack",
|
|
27
|
+
"publish:pkg": "npm run lint && npm run build && npm run pack:check && npm publish",
|
|
28
|
+
"publish:patch": "npm version patch && npm run publish:pkg",
|
|
29
|
+
"publish:minor": "npm version minor && npm run publish:pkg",
|
|
30
|
+
"publish:major": "npm version major && npm run publish:pkg",
|
|
23
31
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
32
|
},
|
|
25
33
|
"author": "kk",
|
|
26
34
|
"license": "MIT",
|
|
27
35
|
"devDependencies": {
|
|
36
|
+
"@antfu/eslint-config": "^6.7.3",
|
|
28
37
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
29
38
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
30
39
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
41
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
31
42
|
"@vue/tsconfig": "^0.8.1",
|
|
43
|
+
"eslint": "^9.35.0",
|
|
44
|
+
"eslint-plugin-check-file": "^3.3.0",
|
|
45
|
+
"eslint-plugin-format": "^1.0.1",
|
|
46
|
+
"eslint-plugin-spellcheck": "^0.0.20",
|
|
32
47
|
"rollup": "^4.54.0",
|
|
33
48
|
"typescript": "^5.9.3"
|
|
34
49
|
},
|
package/src/hooks/index.ts
DELETED
package/src/hooks/useStorage.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/hooks/useStorage.ts
|
|
2
|
-
/**
|
|
3
|
-
* 本地存储 Hook(localStorage 封装)
|
|
4
|
-
* @param key 存储键名
|
|
5
|
-
* @param defaultValue 默认值
|
|
6
|
-
* @returns 获取值、设置值、删除值的方法
|
|
7
|
-
*/
|
|
8
|
-
export function useStorage<T>(key: string, defaultValue: T) {
|
|
9
|
-
// 获取存储值
|
|
10
|
-
const getStorage = (): T => {
|
|
11
|
-
try {
|
|
12
|
-
const value = localStorage.getItem(key);
|
|
13
|
-
return value ? JSON.parse(value) : defaultValue;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.error('获取本地存储失败:', error);
|
|
16
|
-
return defaultValue;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// 设置存储值
|
|
21
|
-
const setStorage = (value: T) => {
|
|
22
|
-
try {
|
|
23
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error('设置本地存储失败:', error);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// 删除存储值
|
|
30
|
-
const removeStorage = () => {
|
|
31
|
-
try {
|
|
32
|
-
localStorage.removeItem(key);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('删除本地存储失败:', error);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
value: getStorage(),
|
|
40
|
-
setStorage,
|
|
41
|
-
removeStorage
|
|
42
|
-
};
|
|
43
|
-
}
|
package/src/index.ts
DELETED