fix(uni-app): 🐛 修复vue3没导出

This commit is contained in:
CodiceFabbrica 2026-05-29 20:01:09 +08:00
parent f9eb267988
commit 4759dfe6b2
5 changed files with 27 additions and 4 deletions

View File

@ -8,7 +8,7 @@
| ---- | ---- | ---- | | ---- | ---- | ---- |
| `@r-utils/common` | `packages/common` | 通用 JS/TS 工具(权限、倒计时、打印、时间等) | | `@r-utils/common` | `packages/common` | 通用 JS/TS 工具(权限、倒计时、打印、时间等) |
| `@r-utils/vue3` | `packages/vue3` | Vue3 工具class 处理、dispatch 等) | | `@r-utils/vue3` | `packages/vue3` | Vue3 工具class 处理、dispatch 等) |
| `@r-utils/uni-app` | `packages/uni-app` | uni-app 工具请求封装、蓝牙、NFC、打印等 | | `@r-utils/uni-app` | `packages/uni-app` | uni-app 工具请求封装、蓝牙、NFC、打印、Vue3 Hooks 等) |
| `@r-utils/uview-plus` | `packages/uview-plus` | uview-plus 组合式 API HooksPicker、Calendar 等) | | `@r-utils/uview-plus` | `packages/uview-plus` | uview-plus 组合式 API HooksPicker、Calendar 等) |
| `@r-utils/vue2` | `packages/vue2` | Vue2 工具visibility 插件) | | `@r-utils/vue2` | `packages/vue2` | Vue2 工具visibility 插件) |
@ -86,6 +86,9 @@ import { mergeClass, dispatch } from '@r-utils/vue3';
// uni-app 工具 // uni-app 工具
import { Request } from '@r-utils/uni-app'; import { Request } from '@r-utils/uni-app';
// uni-app Vue3 Hooks
import { useShare } from '@r-utils/uni-app/vue3';
// uview-plus Hooks // uview-plus Hooks
import { usePickerSingle, usePicker, useCalendar } from '@r-utils/uview-plus'; import { usePickerSingle, usePicker, useCalendar } from '@r-utils/uview-plus';

View File

@ -1,11 +1,11 @@
# @r-utils/uni-app # @r-utils/uni-app
仅用于 uni-app 项目的工具包封装请求、上传、NFC、蓝牙、打印和常用 uni API 辅助方法。 仅用于 uni-app 项目的工具包封装请求、上传、NFC、蓝牙、打印、Vue3 Hooks 和常用 uni API 辅助方法。
## 适用范围 ## 适用范围
- 适用于 uni-app 项目(含 uni 运行时能力)。 - 适用于 uni-app 项目(含 uni 运行时能力)。
- 适用于需要复用请求、上传、蓝牙、NFC、打印等能力的业务项目。 - 适用于需要复用请求、上传、蓝牙、NFC、打印、Vue3 Hooks 等能力的业务项目。
## 不适用范围 ## 不适用范围
@ -25,7 +25,7 @@ pnpm add @r-utils/uni-app
大多数场景推荐从根入口导入,路径简单,使用心智负担更低。 大多数场景推荐从根入口导入,路径简单,使用心智负担更低。
```ts ```ts
import { Request, showToast, toPromise, upload, Printer } from "@r-utils/uni-app"; import { Request, showToast, toPromise, upload, Printer, useShare } from "@r-utils/uni-app";
``` ```
### 兼容:子路径导入 ### 兼容:子路径导入
@ -39,6 +39,7 @@ import { upload } from "@r-utils/uni-app/upload";
import { Printer } from "@r-utils/uni-app/printer"; import { Printer } from "@r-utils/uni-app/printer";
import { nfcScan } from "@r-utils/uni-app/nfc"; import { nfcScan } from "@r-utils/uni-app/nfc";
import { BluetoothUtils } from "@r-utils/uni-app/bluetooth-utils"; import { BluetoothUtils } from "@r-utils/uni-app/bluetooth-utils";
import { useShare, usePageTab, useTopSticky } from "@r-utils/uni-app/vue3";
``` ```
## 导出模块 ## 导出模块
@ -51,6 +52,7 @@ import { BluetoothUtils } from "@r-utils/uni-app/bluetooth-utils";
| `@r-utils/uni-app/printer` | 打印机相关工具 | | `@r-utils/uni-app/printer` | 打印机相关工具 |
| `@r-utils/uni-app/nfc` | NFC 相关工具 | | `@r-utils/uni-app/nfc` | NFC 相关工具 |
| `@r-utils/uni-app/bluetooth-utils` | 蓝牙相关工具 | | `@r-utils/uni-app/bluetooth-utils` | 蓝牙相关工具 |
| `@r-utils/uni-app/vue3` | uni-app Vue3 Hooks |
## 使用示例 ## 使用示例
@ -86,6 +88,17 @@ const request = new Request({
}); });
``` ```
### 使用 Vue3 Hooks
```ts
import { useShare } from "@r-utils/uni-app/vue3";
const { getShareOptions } = useShare({
title: "页面标题",
query: { id: "1" },
});
```
## 注意事项 ## 注意事项
- 推荐优先使用根入口导入;如果需要更精确的模块边界,也可以使用子路径导入。 - 推荐优先使用根入口导入;如果需要更精确的模块边界,也可以使用子路径导入。

View File

@ -46,6 +46,11 @@
"types": "./dist/upload/index.d.ts", "types": "./dist/upload/index.d.ts",
"import": "./dist/upload/index.mjs", "import": "./dist/upload/index.mjs",
"require": "./dist/upload/index.cjs" "require": "./dist/upload/index.cjs"
},
"./vue3": {
"types": "./dist/vue3/index.d.ts",
"import": "./dist/vue3/index.mjs",
"require": "./dist/vue3/index.cjs"
} }
}, },
"keywords": [ "keywords": [

View File

@ -4,3 +4,4 @@ export * from "./printer";
export * from "./request"; export * from "./request";
export * from "./uni-helper"; export * from "./uni-helper";
export * from "./upload"; export * from "./upload";
export * from "./vue3";

View File

@ -19,6 +19,7 @@ export default defineConfig({
"request/index": resolve(__dirname, "src/request/index.ts"), "request/index": resolve(__dirname, "src/request/index.ts"),
"uni-helper/index": resolve(__dirname, "src/uni-helper/index.ts"), "uni-helper/index": resolve(__dirname, "src/uni-helper/index.ts"),
"upload/index": resolve(__dirname, "src/upload/index.ts"), "upload/index": resolve(__dirname, "src/upload/index.ts"),
"vue3/index": resolve(__dirname, "src/vue3/index.ts"),
}, },
formats: ["es", "cjs"], formats: ["es", "cjs"],
fileName: (format, entryName) => fileName: (format, entryName) =>