This commit is contained in:
2026-09-24 16:25:22 +08:00
commit 7428184f01
1198 changed files with 314515 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
## 1.0.82025-08-17
* 兼容原生鸿蒙
## 1.0.62024-09-22
* 修改可能的文件无法读取的问题,有的用户把文件存在到非缓存目录.可能导致文件无法读取.
## 1.0.52024-08-24
* 经过测试可以在uniapp上分享啦。也能在ios上分享,可以分享文本和链接到微信中,具体操作请购买后联系我。
## 1.0.42024-08-06
* 安卓端改了下判断逻辑
## 1.0.32024-08-05
* 解决uniapp项目无法在安卓上分享本地图片资源问题
## 1.0.22024-07-30
IOS支持分享文件,视频,音频,图片到微信。
## 1.0.12024-07-11
修改支持本地路径文件,兼容uniapp项目。
## 1.0.02024-06-01
分享内容到其它应用
安卓,ios支持。
+100
View File
@@ -0,0 +1,100 @@
{
"id": "x-share-s",
"displayName": "安卓,ios,鸿蒙文件视频文本任意文件分享到其它应用",
"version": "1.0.8",
"description": "可以让你的内容分享到其它应用中,安卓和ios支持",
"keywords": [
"ios,安卓,文件分享"
],
"repository": "",
"engines": {
"HBuilderX": "^4.15",
"uni-app": "",
"uni-app-x": "^4.75"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "68.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "读写文件权限"
},
"npmurl": "",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "√",
"aliyun": "√",
"alipay": "√"
},
"client": {
"uni-app": {
"vue": {
"vue2": "-",
"vue3": "-"
},
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"vue": "-",
"nvue": "-",
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-",
"alipay": "-",
"toutiao": "-",
"baidu": "-",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
},
"uni-app-x": {
"web": {
"safari": "x",
"chrome": "x"
},
"app": {
"android": {
"extVersion": "",
"minVersion": "21"
},
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "-"
}
}
}
}
}
}
+76
View File
@@ -0,0 +1,76 @@
# x-share-s
### 开发文档
通过接口简单使用可分享你的任意内容到其它app
前提:
- 需要打包时指定分享路径,请看下面的技术说明
- 安卓端请联系下载AndroidManifest.xml文件至你项目中,联系我技术支持,否则无法分享。
- vip用户请直接在demo中复制 `AndroidManifest.xml`到你根目录后,自己按照插件内的图文教程介绍配置好名称即可。
### tmui4.0Vip用户不需要购买已经集成在组件库中
[tmui4.0](https://ext.dcloud.net.cn/plugin?id=16369)
### 功能说明
- 安卓端可以分享任意文件,文本,视频,图片,音乐至其它app
- IOS端,支持分享任意文件到其它APP,可以分享图片,视频,音频到微信qq等等
- 文本分享到微信
### 兼容性
| Harmony | IOS | Android | WEB | 小程序 |
| --- | --- | --- | --- | --- |
| 支持 | 支持 | 支持 | x | x |
### 方法说明
差异说明:
- 安卓端title就是分享内容时所要展示的分享标题,但在ios端就是你的分享内容,ios端没有标题一说,系统不支持,安卓端如果同时提供了标题和content,最终分享的是content文本
- minType,如果为text/plain时,title是标题(安卓可用),content为分享的文本内容
- minType为其它时比如图片等格式 title是标题(安卓可用),content无用,path就是文件地址(文档,图片,视频等等任意文件)
```ts
/**
* title:分享的标题
* minType:分享的内容格式
* 文本:text/plain
* 图片:image/*
* 音频: audio/*
* 视频: video/*
* 任意文件: *\/*
*
*/
xShare(title : string, minType : string, content ?: string, path ?: string)
```
### 使用示例
如果是安卓请务必打自定义基座
如果是ios:你在mac环境下配置好了环境无需打包本地编译,如果win开发ios需要打包基座。
```vue
// 你的uts代码
<script>
import { xShare } from "@/uni_modules/x-share-s"
export default {
data() {
return {
url:''
}
},
methods: {
toWxMiniApp(){
//安卓和ios其它应用能收到内容:"我要分享的文本内容",微信无法接收,但其它应用可以。
xShare("我是标题","text/plain","我要分享的文本内容",null)
//安卓和ios其它应用能收到图片(微信也能接收可以发送给朋友,朋友圈,用户,自己)
xShare("我是标题","image/*",null,"img.jpg")
}
}
}
<\/script>
```
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:usesCleartextTraffic="true" package="io.dcloud.uni_modules.xShareS">
<meta-data android:name="ScopedStorage" android:value="true" />
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest>
@@ -0,0 +1,3 @@
{
"minSdkVersion": "21"
}
@@ -0,0 +1,51 @@
import Context from "android.content.Context";
import Build from 'android.os.Build'
import Uri from 'android.net.Uri';
import Intent from 'android.content.Intent';
import ContentResolver from 'android.content.ContentResolver'
import FileProvider from 'androidx.core.content.FileProvider'
import File from 'java.io.File';
import Files from 'android.provider.MediaStore.Files';
import InputStream from 'java.io.InputStream'
import FileOutputStream from 'java.io.FileOutputStream'
import MimeTypeMap from 'android.webkit.MimeTypeMap'
import OpenableColumns from 'android.provider.OpenableColumns'
import R from 'io.dcloud.uni_modules.xShareS.R'
/**
* title:分享的标题
* minType:分享的内容格式
* 文本:text/plain
* 图片:image/*
* 音频: audio/*
* 视频: video/*
* 任意文件: *//* ,注意不要//,只要单个/就行。编译器无法注释单个/
*
*/
export function xShare(title : string, minType : string, content ?: string, path ?: string) {
const context = UTSAndroid.getAppContext()!
if (minType == 'text/plain') {
let action = new Intent()
action.setAction(Intent.ACTION_SEND)
action.setType('text/plain')
if(content!=null){
action.putExtra(Intent.EXTRA_TEXT, content!)
}
UTSAndroid.getUniActivity()!.startActivity(Intent.createChooser(action, title))
} else {
if (path == null || minType == '') {
console.error("类型或者路径为空")
return;
}
let realfilepath = UTSAndroid.convert2AbsFullPath(path)
let file = new File(realfilepath)
let action = new Intent()
action.setAction(Intent.ACTION_SEND)
action.setType(minType)
let contentUri = FileProvider.getUriForFile(context, "xShareS.FileProvider", file);
action.putExtra(Intent.EXTRA_STREAM, contentUri);
UTSAndroid.getUniActivity()!.startActivity(Intent.createChooser(action, title))
}
}
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-cache-path name="externalCachePath" path="." />
<root-path name="apps" path="." />
</paths>
@@ -0,0 +1,5 @@
{
"dependencies": {
"x_library_s": "./lib/x_library_s.har"
}
}
@@ -0,0 +1,21 @@
import { x_share } from "x_library_s";
/**
* title:分享的标题
* minType:分享的内容格式
* 文本:text/plain
* 图片:image/*
* 音频: audio/*
* 视频: video/*
* 任意文件: *//* ,注意不要//,只要单个/就行。编译器无法注释单个/
*
*/
export function xShare(title : string, minType : string, content ?: string, path ?: string) {
const context = UTSHarmony.getCurrentWindow()!.getUIContext();
x_share(context,{
minType,
title,
content:content??"",
path:path??""
} as UTSJSONObject)
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>
@@ -0,0 +1,3 @@
{
"deploymentTarget": "12"
}
@@ -0,0 +1,44 @@
import { UIActivity , UIActivityViewController , UIImage } from 'UIKit';
import { CGRect } from 'CoreFoundation';
import { URL , FileManager } from 'Foundation';
/**
* ios端如何要分享文本和图片之外的文件,可能需要对应的目标应用sdk,比如微信需要微信的sdk
* 但很多应用不需要,比如我分享个pdf文件,大多应用是可以接收,但微信不行,必须要人家的sdk
* 图片不需要,可以给任何应用
* 文本不能微信,但其它应用可以,比如记事本,备忘录等等。
*/
/**
* title:分享的标题
* minType:分享的内容格式
* 文本:text/plain
* 图片:image/*
* 音频: audio/*
* 视频: video/*
* 任意文件: *//* ,注意不要//,只要单个/就行。编译器无法注释单个/
*
*/
export function xShare(title : string, minType : string, content ?: string, path ?: string) {
let items = [] as any[];
if(minType=='text/plain'){
items = [content];
}else if(minType=='image/*'&&path!=null){
items = [new UIImage(contentsOfFile = path!)]
}else{
let pfh = path! as string;
let filepath = UTSiOS.convert2AbsFullPath(pfh)
let dataURL = new URL(fileURLWithPath = filepath)
let data = UTSiOS.try(new Data(contentsOf = dataURL),"?")
if(data==null) return;
// items = [FileManager.default.contents(atPath =path!),new URL.init(fileURLWithPath=pfh)]
items = [data,new URL.init(fileURLWithPath=filepath)]
}
DispatchQueue.main.async(execute=():void => {
let activityViewController =new UIActivityViewController(activityItems = items,applicationActivities = nil)
UTSiOS.getCurrentViewController().present(activityViewController, animated = true, completion = () => {
console.log('分享成功。')
})
})
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB