@cloudcome/utils-uni 0.0.0 → 1.1.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const VERSION = "1.1.0";
4
+ exports.VERSION = VERSION;
5
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export const VERSION = PKG_VERSION;\n"],"names":[],"mappings":";;AAAO,MAAM,UAAU;;"}
@@ -0,0 +1 @@
1
+ export declare const VERSION: string;
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ const VERSION = "1.1.0";
2
+ export {
3
+ VERSION
4
+ };
5
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["export const VERSION = PKG_VERSION;\n"],"names":[],"mappings":"AAAO,MAAM,UAAU;"}
package/dist/page.cjs ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const uniApp = require("@dcloudio/uni-app");
4
+ const vue = require("vue");
5
+ function usePageQuery(onPageLoad) {
6
+ const query = vue.reactive({});
7
+ uniApp.onLoad((_query) => {
8
+ Object.assign(query, _query);
9
+ onPageLoad == null ? void 0 : onPageLoad(query);
10
+ });
11
+ return query;
12
+ }
13
+ exports.usePageQuery = usePageQuery;
14
+ //# sourceMappingURL=page.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.cjs","sources":["../src/page.ts"],"sourcesContent":["import type { AnyObject } from '@cloudcome/utils-core/types';\nimport { onLoad } from '@dcloudio/uni-app';\nimport { type Reactive, reactive, unref } from 'vue';\n\n/**\n * 用于获取页面参数的 hook 函数\n * @template T - 页面参数对象的类型,继承自 AnyObject\n * @param {function} [onPageLoad] - 页面加载时的回调函数\n * @param {T} onLoad.query - 页面参数对象\n * @returns {T} 响应式的页面参数对象\n * @example\n * // 基本用法\n * const query = usePageQuery();\n *\n * // 带回调的用法\n * const query = usePageQuery((query) => {\n * console.log('页面参数:', query);\n * });\n *\n * // 指定参数类型\n * interface PageParams {\n * id: string;\n * name?: string;\n * }\n * const query = usePageQuery<PageParams>();\n */\nexport function usePageQuery<T extends AnyObject>(onPageLoad?: (query: Reactive<T>) => void) {\n const query = reactive<T>({} as T);\n\n onLoad((_query) => {\n Object.assign(query, _query);\n onPageLoad?.(query);\n });\n\n return query;\n}\n"],"names":["reactive","onLoad"],"mappings":";;;;AA0BO,SAAS,aAAkC,YAA2C;AACrF,QAAA,QAAQA,IAAY,SAAA,EAAO;AAEjCC,SAAA,OAAO,CAAC,WAAW;AACV,WAAA,OAAO,OAAO,MAAM;AAC3B,6CAAa;AAAA,EAAK,CACnB;AAEM,SAAA;AACT;;"}
package/dist/page.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { AnyObject } from '@cloudcome/utils-core/types';
2
+ import { Reactive } from 'vue';
3
+ /**
4
+ * 用于获取页面参数的 hook 函数
5
+ * @template T - 页面参数对象的类型,继承自 AnyObject
6
+ * @param {function} [onPageLoad] - 页面加载时的回调函数
7
+ * @param {T} onLoad.query - 页面参数对象
8
+ * @returns {T} 响应式的页面参数对象
9
+ * @example
10
+ * // 基本用法
11
+ * const query = usePageQuery();
12
+ *
13
+ * // 带回调的用法
14
+ * const query = usePageQuery((query) => {
15
+ * console.log('页面参数:', query);
16
+ * });
17
+ *
18
+ * // 指定参数类型
19
+ * interface PageParams {
20
+ * id: string;
21
+ * name?: string;
22
+ * }
23
+ * const query = usePageQuery<PageParams>();
24
+ */
25
+ export declare function usePageQuery<T extends AnyObject>(onPageLoad?: (query: Reactive<T>) => void): Reactive<T>;
package/dist/page.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { onLoad } from "@dcloudio/uni-app";
2
+ import { reactive } from "vue";
3
+ function usePageQuery(onPageLoad) {
4
+ const query = reactive({});
5
+ onLoad((_query) => {
6
+ Object.assign(query, _query);
7
+ onPageLoad == null ? void 0 : onPageLoad(query);
8
+ });
9
+ return query;
10
+ }
11
+ export {
12
+ usePageQuery
13
+ };
14
+ //# sourceMappingURL=page.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.mjs","sources":["../src/page.ts"],"sourcesContent":["import type { AnyObject } from '@cloudcome/utils-core/types';\nimport { onLoad } from '@dcloudio/uni-app';\nimport { type Reactive, reactive, unref } from 'vue';\n\n/**\n * 用于获取页面参数的 hook 函数\n * @template T - 页面参数对象的类型,继承自 AnyObject\n * @param {function} [onPageLoad] - 页面加载时的回调函数\n * @param {T} onLoad.query - 页面参数对象\n * @returns {T} 响应式的页面参数对象\n * @example\n * // 基本用法\n * const query = usePageQuery();\n *\n * // 带回调的用法\n * const query = usePageQuery((query) => {\n * console.log('页面参数:', query);\n * });\n *\n * // 指定参数类型\n * interface PageParams {\n * id: string;\n * name?: string;\n * }\n * const query = usePageQuery<PageParams>();\n */\nexport function usePageQuery<T extends AnyObject>(onPageLoad?: (query: Reactive<T>) => void) {\n const query = reactive<T>({} as T);\n\n onLoad((_query) => {\n Object.assign(query, _query);\n onPageLoad?.(query);\n });\n\n return query;\n}\n"],"names":[],"mappings":";;AA0BO,SAAS,aAAkC,YAA2C;AACrF,QAAA,QAAQ,SAAY,EAAO;AAEjC,SAAO,CAAC,WAAW;AACV,WAAA,OAAO,OAAO,MAAM;AAC3B,6CAAa;AAAA,EAAK,CACnB;AAEM,SAAA;AACT;"}
package/package.json CHANGED
@@ -1,8 +1 @@
1
- {
2
- "name": "@cloudcome/utils-uni",
3
- "version": "0.0.0",
4
- "publishConfig": {
5
- "access": "public",
6
- "registry": "https://registry.npmjs.org/"
7
- }
8
- }
1
+ {"name":"@cloudcome/utils-uni","version":"1.1.0","description":"cloudcome utils for uni-app","engines":{"node":">=22"},"engineStrict":true,"sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json","./page":{"types":"./dist/page.d.ts","import":"./dist/page.mjs","require":"./dist/page.cjs"}},"typesVersions":{"*":{"page":["./dist/page.d.ts"]}},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","files":["dist"],"repository":{"url":"https://github.com/cloudcome/utils","directory":"packages/utils-uni"},"dependencies":{"@cloudcome/utils-core":"1.1.0","@dcloudio/uni-app":"3.0.0-4060620250520001","vue":"^3.5.13"}}