From 39ecb50ef43756604cc8c5058ac35a408f8af55f Mon Sep 17 00:00:00 2001 From: yanyilin Date: Fri, 27 Oct 2023 16:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=94=AF=E6=8C=81uni-app=20x?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 9 + App.uvue | 44 +++++ main.uts | 9 + manifest.json | 132 ++++++------- pages.json | 46 +++-- pages/animation-view/animation-view.nvue | 70 +++++++ pages/animation-view/animation-view.uvue | 70 +++++++ pages/index/index.nvue | 120 ++++++------ pages/index/index.uvue | 68 +++++++ pages/video-view/video-view.nvue | 65 +++++++ pages/video-view/video-view.uvue | 72 +++++++ readme.md | 21 +++ uni_modules/uni-animation-view/changelog.md | 7 +- uni_modules/uni-animation-view/package.json | 2 +- uni_modules/uni-animation-view/readme.md | 165 ++++++++-------- .../utssdk/app-android/index.vue | 2 +- .../uni-animation-view/utssdk/web/index.vue | 13 -- uni_modules/uni-video/changelog.md | 2 + uni_modules/uni-video/package.json | 176 ++++++++---------- uni_modules/uni-video/readme.md | 13 +- .../uni-video/utssdk/app-android/index.vue | 6 +- .../uni-video/utssdk/app-ios/index.vue | 20 -- uni_modules/uni-video/utssdk/index.uts | 58 ------ uni_modules/uni-video/utssdk/interface.uts | 25 --- 24 files changed, 776 insertions(+), 439 deletions(-) create mode 100644 .editorconfig create mode 100644 App.uvue create mode 100644 main.uts create mode 100644 pages/animation-view/animation-view.nvue create mode 100644 pages/animation-view/animation-view.uvue create mode 100644 pages/index/index.uvue create mode 100644 pages/video-view/video-view.nvue create mode 100644 pages/video-view/video-view.uvue create mode 100644 readme.md delete mode 100644 uni_modules/uni-animation-view/utssdk/web/index.vue delete mode 100644 uni_modules/uni-video/utssdk/app-ios/index.vue delete mode 100644 uni_modules/uni-video/utssdk/index.uts diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1a3af92 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/App.uvue b/App.uvue new file mode 100644 index 0000000..a1ead0e --- /dev/null +++ b/App.uvue @@ -0,0 +1,44 @@ + + + \ No newline at end of file diff --git a/main.uts b/main.uts new file mode 100644 index 0000000..89d8f15 --- /dev/null +++ b/main.uts @@ -0,0 +1,9 @@ +import App from './App' + +import { createSSRApp } from 'vue' +export function createApp() { + const app = createSSRApp(App) + return { + app + } +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 969da0b..2d0bfae 100644 --- a/manifest.json +++ b/manifest.json @@ -1,72 +1,60 @@ -{ - "name" : "uni-component", - "appid" : "__UNI__0094991", - "description" : "uts组件示例", - "versionName" : "1.0.0", - "versionCode" : "100", - "transformPx" : false, - /* 5+App特有相关 */ - "app-plus" : { - "usingComponents" : true, - "nvueStyleCompiler" : "uni-app", - "compilerVersion" : 3, - "splashscreen" : { - "alwaysShowBeforeRender" : true, - "waiting" : true, - "autoclose" : true, - "delay" : 0 - }, - /* 模块配置 */ - "modules" : {}, - /* 应用发布信息 */ - "distribute" : { - /* android打包配置 */ - "android" : { - "permissions" : [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ] - }, - /* ios打包配置 */ - "ios" : {}, - /* SDK配置 */ - "sdkConfigs" : {} - } - }, - /* 快应用特有相关 */ - "quickapp" : {}, - /* 小程序特有相关 */ - "mp-weixin" : { - "appid" : "", - "setting" : { - "urlCheck" : false - }, - "usingComponents" : true - }, - "mp-alipay" : { - "usingComponents" : true - }, - "mp-baidu" : { - "usingComponents" : true - }, - "mp-toutiao" : { - "usingComponents" : true - }, - "uniStatistics" : { - "enable" : false - }, - "vueVersion" : "3" -} +{ + "name": "uni-component", + "appid": "__UNI__0094991", + "description": "uts组件示例", + "versionName": "1.0.0", + "versionCode": "100", + "transformPx": false, + /* uni-app x 特有相关 */ + // "uni-app-x": {}, + /* uni-app特有相关 */ + "app-plus": { + "usingComponents": true, + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + /* 模块配置 */ + "modules": {}, + /* 应用发布信息 */ + "distribute": { + /* android打包配置 */ + "android": {}, + /* ios打包配置 */ + "ios": { + "dSYMs": false + }, + /* SDK配置 */ + "sdkConfigs": { + "ad": {} + } + } + }, + /* 快应用特有相关 */ + "quickapp": {}, + /* 小程序特有相关 */ + "mp-weixin": { + "appid": "", + "setting": { + "urlCheck": false + }, + "usingComponents": true + }, + "mp-alipay": { + "usingComponents": true + }, + "mp-baidu": { + "usingComponents": true + }, + "mp-toutiao": { + "usingComponents": true + }, + "uniStatistics": { + "enable": false + }, + "vueVersion": "3" +} \ No newline at end of file diff --git a/pages.json b/pages.json index 869105d..d58033c 100644 --- a/pages.json +++ b/pages.json @@ -1,17 +1,31 @@ -{ - "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "uni-app" - } - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "uni-app", - "navigationBarBackgroundColor": "#F8F8F8", - "backgroundColor": "#F8F8F8" - }, - "uniIdRouter": {} +{ + "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "uni-app" + } + }, + { + "path": "pages/animation-view/animation-view", + "style": { + "navigationBarTitleText": "animation-view", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/video-view/video-view", + "style": { + "navigationBarTitleText": "video-view", + "enablePullDownRefresh": false + } + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "uni-app", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + }, + "uniIdRouter": {} } diff --git a/pages/animation-view/animation-view.nvue b/pages/animation-view/animation-view.nvue new file mode 100644 index 0000000..1927c6e --- /dev/null +++ b/pages/animation-view/animation-view.nvue @@ -0,0 +1,70 @@ + + + + + diff --git a/pages/animation-view/animation-view.uvue b/pages/animation-view/animation-view.uvue new file mode 100644 index 0000000..1927c6e --- /dev/null +++ b/pages/animation-view/animation-view.uvue @@ -0,0 +1,70 @@ + + + + + diff --git a/pages/index/index.nvue b/pages/index/index.nvue index 0aa8945..bc330a2 100644 --- a/pages/index/index.nvue +++ b/pages/index/index.nvue @@ -1,52 +1,68 @@ - - - - - + + + + + \ No newline at end of file diff --git a/pages/index/index.uvue b/pages/index/index.uvue new file mode 100644 index 0000000..c498ecc --- /dev/null +++ b/pages/index/index.uvue @@ -0,0 +1,68 @@ + + + + + diff --git a/pages/video-view/video-view.nvue b/pages/video-view/video-view.nvue new file mode 100644 index 0000000..2926218 --- /dev/null +++ b/pages/video-view/video-view.nvue @@ -0,0 +1,65 @@ + + + + + diff --git a/pages/video-view/video-view.uvue b/pages/video-view/video-view.uvue new file mode 100644 index 0000000..3f2f62f --- /dev/null +++ b/pages/video-view/video-view.uvue @@ -0,0 +1,72 @@ + + + + + diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..6e3b678 --- /dev/null +++ b/readme.md @@ -0,0 +1,21 @@ +此项目为开源uts组件插件。 + + +## 注意事项 +uts组件插件基本都会依赖三方SDK,需要使用自定义基座才能正常运行。 + +此项目默认为uni-app项目,如果要切换为uni-app x项目,需打开manifest.json,去掉uni-app-x节点的注释: +``` + /* uni-app x 特有相关 */ + // "uni-app-x": {}, +``` +关闭manifest.json后重新打开即可。 + + +## uni-animation-view +动画组件 animation-view + + +## uni-video +视频播放组件 video-view,暂时仅支持Android平台的 uni-app x 项目 + diff --git a/uni_modules/uni-animation-view/changelog.md b/uni_modules/uni-animation-view/changelog.md index a5a3c3d..778834e 100644 --- a/uni_modules/uni-animation-view/changelog.md +++ b/uni_modules/uni-animation-view/changelog.md @@ -1,2 +1,5 @@ -## 1.0.0(2023-01-16) -实现android/ios平台animation-view组件,仅支持nvue页面 +## 1.0.0(2023-01-16) +实现android/ios平台 animation-view 组件,仅支持 nvue 页面 + +## 1.0.1(2023-10-23) +android平台适配 uni-app x 项目,支持 uvue 页面,需使用 HBuilderX3.94+ 版本 diff --git a/uni_modules/uni-animation-view/package.json b/uni_modules/uni-animation-view/package.json index 1ab51db..afd95ec 100644 --- a/uni_modules/uni-animation-view/package.json +++ b/uni_modules/uni-animation-view/package.json @@ -1,7 +1,7 @@ { "id": "uni-animation-view", "displayName": "animation-view", - "version": "1.0.0", + "version": "1.0.1", "description": "使用uts组件开发,实现animation-view组件", "keywords": [ "animation-view", diff --git a/uni_modules/uni-animation-view/readme.md b/uni_modules/uni-animation-view/readme.md index 118c91f..b8692ca 100644 --- a/uni_modules/uni-animation-view/readme.md +++ b/uni_modules/uni-animation-view/readme.md @@ -1,79 +1,86 @@ -# animation-view - -> animation-view组件是[uts插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html),需 HBuilderX 3.7.0+ - -> 使用文档:[https://uniapp.dcloud.net.cn/component/animation-view.html](https://uniapp.dcloud.net.cn/component/animation-view.html) - - -### 属性说明 - -|属性名|类型|默认值|说明| -|:-|:-|:-|:-| -| path | String | | 动画资源地址,支持本地路径和网络路径 | -| loop | Boolean | false | 动画是否循环播放 | -| autoplay | Boolean | true | 动画是否自动播放 | -| action | String | play | 动画操作,可取值 play、pause、stop | -| hidden | Boolean | true | 是否隐藏动画 | -| @bindended | EventHandle | | 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发) | - - -**注意** -* animation-view 仅App端nvue页面支持 -* App端实现使用了Lottie三方SDK,参考开源项目:[Lottie for Android](https://github.com/airbnb/lottie-android),[Lottie for iOS](https://github.com/airbnb/lottie-ios) -* App-Android平台要求Android5(API Leavel 21)及以上系统 -* App-iOS平台要求iOS11及以上版本系统 - - -### 代码示例 - -```html - - - - - -``` - - - - - - +## uts插件开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) + + +## animation-view + +> animation-view组件是[uts插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html),需 HBuilderX 3.7.0+ + +> 使用文档:[https://uniapp.dcloud.net.cn/component/animation-view.html](https://uniapp.dcloud.net.cn/component/animation-view.html) + + +### 属性说明 + +|属性名|类型|默认值|说明| +|:-|:-|:-|:-| +| path | String | | 动画资源地址,支持本地路径和网络路径 | +| loop | Boolean | false | 动画是否循环播放 | +| autoplay | Boolean | true | 动画是否自动播放 | +| action | String | play | 动画操作,可取值 play、pause、stop | +| hidden | Boolean | true | 是否隐藏动画 | +| @bindended | EventHandle | | 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发) | + + +**注意** +* animation-view 仅App端nvue页面支持 +* App端实现使用了Lottie三方SDK,参考开源项目:[Lottie for Android](https://github.com/airbnb/lottie-android),[Lottie for iOS](https://github.com/airbnb/lottie-ios) +* App-Android平台要求Android5(API Leavel 21)及以上系统 +* App-iOS平台要求iOS11及以上版本系统 + + +### 代码示例 + +```html + + + + + +``` + + + + + + diff --git a/uni_modules/uni-animation-view/utssdk/app-android/index.vue b/uni_modules/uni-animation-view/utssdk/app-android/index.vue index d47fe88..1b5a767 100644 --- a/uni_modules/uni-animation-view/utssdk/app-android/index.vue +++ b/uni_modules/uni-animation-view/utssdk/app-android/index.vue @@ -35,7 +35,7 @@ //原生提供以下属性或方法的实现 export default { - name: "uts-animation-view", + name: "animation-view", /** * 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发) */ diff --git a/uni_modules/uni-animation-view/utssdk/web/index.vue b/uni_modules/uni-animation-view/utssdk/web/index.vue deleted file mode 100644 index efaa0bb..0000000 --- a/uni_modules/uni-animation-view/utssdk/web/index.vue +++ /dev/null @@ -1,13 +0,0 @@ - - diff --git a/uni_modules/uni-video/changelog.md b/uni_modules/uni-video/changelog.md index e69de29..1dfcf18 100644 --- a/uni_modules/uni-video/changelog.md +++ b/uni_modules/uni-video/changelog.md @@ -0,0 +1,2 @@ +## 1.0.0(2023-10-26) +实现android平台 video-view 组件,仅支持 uni-app x项目的 uvue 页面 diff --git a/uni_modules/uni-video/package.json b/uni_modules/uni-video/package.json index 8edcfae..3a7d33a 100644 --- a/uni_modules/uni-video/package.json +++ b/uni_modules/uni-video/package.json @@ -1,95 +1,83 @@ -{ - "id": "uni-video", - "displayName": "uni-video", - "version": "1.0.0", - "description": "uni-video", - "keywords": [ - "uni-video" -], - "repository": "", - "engines": { - "HBuilderX": "^3.7.0" - }, - "dcloudext": { - "type": "component-uts", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "", - "data": "", - "permissions": "" - }, - "npmurl": "" - }, - "uni_modules": { - "dependencies": [ - "uni-framework" - ], - "uni-ext-api": { - "uni": { - "createVideoContext": { - "name": "createVideoContext", - "app": { - "js": false, - "kotlin": true, - "swift": false - } - } - } - }, - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "u", - "aliyun": "u" - }, - "client": { - "Vue": { - "vue2": "u", - "vue3": "u" - }, - "App": { - "app-android": "u", - "app-ios": "u" - }, - "H5-mobile": { - "Safari": "u", - "Android Browser": "u", - "微信浏览器(Android)": "u", - "QQ浏览器(Android)": "u" - }, - "H5-pc": { - "Chrome": "u", - "IE": "u", - "Edge": "u", - "Firefox": "u", - "Safari": "u" - }, - "小程序": { - "微信": "u", - "阿里": "u", - "百度": "u", - "字节跳动": "u", - "QQ": "u", - "钉钉": "u", - "快手": "u", - "飞书": "u", - "京东": "u" - }, - "快应用": { - "华为": "u", - "联盟": "u" - } - } - } - } +{ + "id": "uni-video", + "displayName": "uni-video", + "version": "1.0.0", + "description": "uni-video", + "keywords": [ + "uni-video" + ], + "repository": "", + "engines": { + "HBuilderX": "^3.7.0" + }, + "dcloudext": { + "type": "component-uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [ + "uni-framework" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "y", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } } \ No newline at end of file diff --git a/uni_modules/uni-video/readme.md b/uni_modules/uni-video/readme.md index 2745019..f97b72a 100644 --- a/uni_modules/uni-video/readme.md +++ b/uni_modules/uni-video/readme.md @@ -1,6 +1,13 @@ -# uni-video -### 开发文档 +## uts插件开发文档 [UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) [UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) [UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) -[Hello UTS](https://gitcode.net/dcloud/hello-uts) \ No newline at end of file +[Hello UTS](https://gitcode.net/dcloud/hello-uts) + + +## video-view +此插件为uni-app x项目中内置 video 组件的开源uts组件插件,为了避免与内置 video 组件冲突,开源uts组件插件注册为 video-view 组件。 + +**注意** +- video-view组件不支持[uni.createVideoContext](https://uniapp.dcloud.net.cn/uni-app-x/api/create-video-context.html) + diff --git a/uni_modules/uni-video/utssdk/app-android/index.vue b/uni_modules/uni-video/utssdk/app-android/index.vue index 727fa64..e511cee 100644 --- a/uni_modules/uni-video/utssdk/app-android/index.vue +++ b/uni_modules/uni-video/utssdk/app-android/index.vue @@ -28,7 +28,7 @@ import { Danmu, RequestFullScreenOptions } from '../interface.uts'; export default { - name: "video", + name: "video-view", data() { return { rootView: null as FrameLayout | null, @@ -580,8 +580,8 @@ override onInfo(iMediaPlayer : IMediaPlayer | null, status : Int, extra : Int) : boolean { switch (status) { case MediaPlayerParams.STATE_COMPLETED: - if ((this.comp as VideoComponent).loop) { - let initialTime = (this.comp as VideoComponent).initialTime as Int; + if ((this.comp as VideoViewComponent).loop) { + let initialTime = (this.comp as VideoViewComponent).initialTime as Int; if (initialTime > 0) this.playerView.seekTo(initialTime * 1000); this.playerView.start(); } diff --git a/uni_modules/uni-video/utssdk/app-ios/index.vue b/uni_modules/uni-video/utssdk/app-ios/index.vue deleted file mode 100644 index 1b0b528..0000000 --- a/uni_modules/uni-video/utssdk/app-ios/index.vue +++ /dev/null @@ -1,20 +0,0 @@ - - diff --git a/uni_modules/uni-video/utssdk/index.uts b/uni_modules/uni-video/utssdk/index.uts deleted file mode 100644 index 0f13918..0000000 --- a/uni_modules/uni-video/utssdk/index.uts +++ /dev/null @@ -1,58 +0,0 @@ -import { ComponentPublicInstance } from 'vue' -import { CreateVideoContext, VideoContext, RequestFullScreenOptions, Danmu } from './interface' -import { UniVideoElement } from './app-android/index.vue' - -export const createVideoContext : CreateVideoContext = function (videoId : VideoIdString, component : ComponentPublicInstance | null) : VideoContext | null { - let videoElement : Element | null = null; - if (component == null) { - const pages = getCurrentPages(); - if (pages.length > 0) { - videoElement = pages[pages.length - 1].$querySelector('#' + videoId); - } - } else { - videoElement = component.$querySelector('#' + videoId); - } - if (videoElement == null) return null; - return new VideoContextImpl(videoElement as UniVideoElement); -} - -class VideoContextImpl implements VideoContext { - - private videoElement : UniVideoElement; - - constructor(videoElement : UniVideoElement) { - this.videoElement = videoElement; - } - - play() { - this.videoElement.play(); - } - - pause() { - this.videoElement.pause(); - } - - seek(position : number) { - this.videoElement.seek(position); - } - - stop() { - this.videoElement.stop(); - } - - sendDanmu(danmu : Danmu) { - this.videoElement.sendDanmu(danmu); - } - - playbackRate(rate : number) { - this.videoElement.playbackRate(rate); - } - - requestFullScreen(direction : RequestFullScreenOptions | null) { - this.videoElement.requestFullScreen(direction); - } - - exitFullScreen() { - this.videoElement.exitFullScreen(); - } -} \ No newline at end of file diff --git a/uni_modules/uni-video/utssdk/interface.uts b/uni_modules/uni-video/utssdk/interface.uts index dbba10d..c274855 100644 --- a/uni_modules/uni-video/utssdk/interface.uts +++ b/uni_modules/uni-video/utssdk/interface.uts @@ -1,6 +1,3 @@ -import { ComponentPublicInstance } from 'vue' - -export type CreateVideoContext = (videoId: VideoIdString, component?: ComponentPublicInstance | null) => VideoContext | null; export type Danmu = { /** @@ -147,25 +144,3 @@ export interface VideoContext { */ exitFullScreen(): void; } - -export interface Uni { - /** - * 创建并返回 video 上下文 videoContext 对象 - * @description 创建并返回 video 上下文 videoContext 对象 - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "√", - * "unixVer": "√" - * } - * } - * } - * @uniVueVersion 2,3 - * @return {VideoContext} 视频对象 - * - * @tutorial http://uniapp.dcloud.io/api/media/video-context?id=createVideoContext - * - */ - createVideoContext(videoId : string | HBuilderX.VideoIdString, component?: ComponentPublicInstance | null) : VideoContext | null -} \ No newline at end of file -- GitLab