Merge branch 'fanpeng' into 'develop'

Fanpeng

See merge request StarlockTeam/wx-starlock!45
This commit is contained in:
范鹏 2025-06-19 06:48:34 +00:00
commit bc00f73b6f
17 changed files with 1029 additions and 127 deletions

View File

@ -30,6 +30,38 @@ module.exports = {
'plugin:prettier/recommended'
],
ignorePatterns: ['utils/log.js', 'unpackage/**/*'],
// 针对不同文件类型使用不同配置
overrides: [
{
files: ['**/*.uts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
globals: {
IUniError: 'readonly',
UniError: 'readonly',
uni: 'readonly',
getApp: 'readonly',
wx: 'readonly',
getCurrentPages: 'readonly',
requirePlugin: 'readonly',
plus: 'readonly'
},
rules: {
'func-names': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
eqeqeq: 'warn',
'no-undef': 'off',
'prettier/prettier': 'off',
'import/no-unresolved': 'off' // 禁用模块解析检查
}
}
],
/**
* "off" 0 ==> 关闭规则
* "warn" 1 ==> 打开的规则作为警告不影响代码执行

View File

@ -31,7 +31,7 @@
return 'XHJ'
}
// #endif
return 'XHJ'
return 'DEV'
}
},
computed: {

View File

@ -2,9 +2,7 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": [
"./*"
]
"@/*": ["./*"]
},
"target": "es2020",
"module": "esnext",
@ -15,14 +13,6 @@
"strict": true,
"skipLibCheck": true
},
"include": [
"**/*.js",
"**/*.jsx",
"**/*.vue"
],
"exclude": [
"node_modules",
"unpackage",
"dist"
]
}
"include": ["**/*.js", "**/*.jsx", "**/*.vue", "pages/p2p/p2pPlayer.nvue"],
"exclude": ["node_modules", "unpackage", "dist"]
}

View File

@ -15,7 +15,6 @@
"desc" : "蓝牙将用于控制和管理您的智能门锁"
}
},
"requiredPrivateInfos" : [ "getLocation" ],
"usingComponents" : true,
"lazyCodeLoading" : "requiredComponents",
"optimization" : {
@ -90,7 +89,10 @@
"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" />"
"<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" />",
"<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.MANAGE_EXTERNAL_STORAGE\"/>"
],
"targetSdkVersion" : 34,
"abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]
@ -100,7 +102,11 @@
}
},
"modules" : {
"Bluetooth" : {}
"Bluetooth" : {},
"VideoPlayer" : {},
"LivePusher" : {},
"Camera" : {},
"Record" : {}
},
"splashscreen" : {
"waiting" : false

299
package-lock.json generated
View File

@ -16,6 +16,8 @@
"@iconify-json/material-symbols": "^1.2.22",
"@iconify-json/solar": "^1.2.2",
"@iconify/utils": "^2.3.0",
"@typescript-eslint/eslint-plugin": "^8.34.0",
"@typescript-eslint/parser": "^8.34.0",
"@unocss/preset-icons": "^66.1.2",
"commitizen": "^4.3.1",
"crc": "^4.3.2",
@ -37,6 +39,7 @@
"stylelint-config-recess-order": "^6.0.0",
"stylelint-config-recommended-scss": "^14.1.0",
"stylelint-config-standard": "^37.0.0",
"typescript": "^5.8.3",
"unocss": "^65.4.3",
"unocss-preset-weapp": "^65.4.1",
"vite-plugin-eslint": "^1.8.1"
@ -930,9 +933,9 @@
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.5.1.tgz",
"integrity": "sha512-soEIOALTfTK6EjmKMMoLugwaP0rzkad90iIWd1hMO9ARkSAyjfMfkRRhLvD5qH7vvM0Cg72pieUfR6yh6XxC4w==",
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz",
"integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -1639,6 +1642,276 @@
"undici-types": "~6.20.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.34.0.tgz",
"integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.34.0",
"@typescript-eslint/type-utils": "8.34.0",
"@typescript-eslint/utils": "8.34.0",
"@typescript-eslint/visitor-keys": "8.34.0",
"graphemer": "^1.4.0",
"ignore": "^7.0.0",
"natural-compare": "^1.4.0",
"ts-api-utils": "^2.1.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"@typescript-eslint/parser": "^8.34.0",
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz",
"integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 4"
}
},
"node_modules/@typescript-eslint/parser": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.34.0.tgz",
"integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/scope-manager": "8.34.0",
"@typescript-eslint/types": "8.34.0",
"@typescript-eslint/typescript-estree": "8.34.0",
"@typescript-eslint/visitor-keys": "8.34.0",
"debug": "^4.3.4"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/project-service": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.34.0.tgz",
"integrity": "sha512-iEgDALRf970/B2YExmtPMPF54NenZUf4xpL3wsCRx/lgjz6ul/l13R81ozP/ZNuXfnLCS+oPmG7JIxfdNYKELw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/tsconfig-utils": "^8.34.0",
"@typescript-eslint/types": "^8.34.0",
"debug": "^4.3.4"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.34.0.tgz",
"integrity": "sha512-9Ac0X8WiLykl0aj1oYQNcLZjHgBojT6cW68yAgZ19letYu+Hxd0rE0veI1XznSSst1X5lwnxhPbVdwjDRIomRw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.34.0",
"@typescript-eslint/visitor-keys": "8.34.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.34.0.tgz",
"integrity": "sha512-+W9VYHKFIzA5cBeooqQxqNriAP0QeQ7xTiDuIOr71hzgffm3EL2hxwWBIIj4GuofIbKxGNarpKqIq6Q6YrShOA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.34.0.tgz",
"integrity": "sha512-n7zSmOcUVhcRYC75W2pnPpbO1iwhJY3NLoHEtbJwJSNlVAZuwqu05zY3f3s2SDWWDSo9FdN5szqc73DCtDObAg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/typescript-estree": "8.34.0",
"@typescript-eslint/utils": "8.34.0",
"debug": "^4.3.4",
"ts-api-utils": "^2.1.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/types": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.34.0.tgz",
"integrity": "sha512-9V24k/paICYPniajHfJ4cuAWETnt7Ssy+R0Rbcqo5sSFr3QEZ/8TSoUi9XeXVBGXCaLtwTOKSLGcInCAvyZeMA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.34.0.tgz",
"integrity": "sha512-rOi4KZxI7E0+BMqG7emPSK1bB4RICCpF7QD3KCLXn9ZvWoESsOMlHyZPAHyG04ujVplPaHbmEvs34m+wjgtVtg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/project-service": "8.34.0",
"@typescript-eslint/tsconfig-utils": "8.34.0",
"@typescript-eslint/types": "8.34.0",
"@typescript-eslint/visitor-keys": "8.34.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
"minimatch": "^9.0.4",
"semver": "^7.6.0",
"ts-api-utils": "^2.1.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/@typescript-eslint/utils": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.34.0.tgz",
"integrity": "sha512-8L4tWatGchV9A1cKbjaavS6mwYwp39jql8xUmIIKJdm+qiaeHy5KMKlBrf30akXAWBzn2SqKsNOtSENWUwg7XQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.7.0",
"@typescript-eslint/scope-manager": "8.34.0",
"@typescript-eslint/types": "8.34.0",
"@typescript-eslint/typescript-estree": "8.34.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.34.0.tgz",
"integrity": "sha512-qHV7pW7E85A0x6qyrFn+O+q1k1p3tQCsqIZ1KZ5ESLXY57aTvUd3/a4rdPTeXisvhXn2VQG0VSKUqs8KHF2zcA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.34.0",
"eslint-visitor-keys": "^4.2.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/@ungap/structured-clone": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz",
@ -9164,6 +9437,19 @@
"node": ">=6"
}
},
"node_modules/ts-api-utils": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
"integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18.12"
},
"peerDependencies": {
"typescript": ">=4.8.4"
}
},
"node_modules/tsconfig-paths": {
"version": "3.15.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",
@ -9299,12 +9585,11 @@
}
},
"node_modules/typescript": {
"version": "5.8.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
"version": "5.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"devOptional": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"

View File

@ -11,6 +11,8 @@
"@iconify-json/material-symbols": "^1.2.22",
"@iconify-json/solar": "^1.2.2",
"@iconify/utils": "^2.3.0",
"@typescript-eslint/eslint-plugin": "^8.34.0",
"@typescript-eslint/parser": "^8.34.0",
"@unocss/preset-icons": "^66.1.2",
"commitizen": "^4.3.1",
"crc": "^4.3.2",
@ -32,15 +34,16 @@
"stylelint-config-recess-order": "^6.0.0",
"stylelint-config-recommended-scss": "^14.1.0",
"stylelint-config-standard": "^37.0.0",
"typescript": "^5.8.3",
"unocss": "^65.4.3",
"unocss-preset-weapp": "^65.4.1",
"vite-plugin-eslint": "^1.8.1"
},
"scripts": {
"prepare": "husky install",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,vue,json,css,scss}\"",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,vue,json,css,scss}\"",
"lint": "eslint --fix \"**/*.{js,jsx,ts,tsx,vue}\"",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,vue,uts,json,css,scss}\"",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,vue,uts,json,css,scss}\"",
"lint": "eslint --fix \"**/*.{js,jsx,ts,tsx,vue,uts}\"",
"lint:style": "stylelint --fix \"**/*.{css,scss,vue}\"",
"lint:all": "npm run format && npm run lint && npm run lint:style"
}

View File

@ -175,7 +175,7 @@
<view
v-if="$bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN"
class="menu-main-view"
@click="$basic.routeJump({ name: 'p2pPlayer' })"
@click="jumpToPlayer"
>
<image
class="menu-main-image transform-scale-140"
@ -309,6 +309,10 @@
await getServeTime()
})
const jumpToPlayer = () => {
$basic.routeJump({ name: 'p2pPlayer' })
}
const openDoorOperate = async type => {
const timestamp = new Date().getTime()
if (

View File

@ -42,6 +42,12 @@
<view v-if="requestFinish" class="mt-4 text-center text-base font-bold text-[#999]">
微信会收到视频通话请求
</view>
<view
class="fixed bottom-120rpx w-400rpx h-88rpx rounded-md leading-88rpx left-1/2 -translate-x-1/2 bg-[#63b8af] text-center text-base font-bold text-[#ffffff]"
@click="getTicket"
>
获取ticket
</view>
</view>
</template>
@ -100,6 +106,41 @@
}
})
const getTicket = async () => {
uni.showLoading({
title: '加载中...'
})
const result = await getInfo()
uni.hideLoading()
if (result.code === 0) {
const ticket = result.data.WXIoTDeviceInfo.SNTicket
uni.showModal({
title: '票据',
content: ticket,
showCancel: false,
confirmText: '复制',
success: ({ confirm }) => {
if (confirm) {
uni.setClipboardData({
data: ticket,
success: () => {
uni.showToast({
title: '复制成功',
icon: 'none'
})
}
})
}
}
})
} else {
uni.showToast({
title: result.message,
icon: 'none'
})
}
}
const getDeviceVoIPList = async () => {
return new Promise(resolve => {
wx.getDeviceVoIPList({

View File

@ -1,48 +1,67 @@
<template>
<view>
<iot-p2p-player-with-mjpg
v-if="deviceInfo"
id="playerRef"
:deviceInfo="deviceInfo"
:xp2pInfo="xp2pInfo"
:rotate="90"
:muted="isMute"
mode="RTC"
:acceptPlayerEvents="true"
soundMode="speaker"
sceneType="live"
:streamQuality="range[index].value"
:minCache="0.2"
:maxCache="0.8"
:fill="true"
orientation="horizontal"
@playsuccess="handlePlaySuccess"
>
</iot-p2p-player-with-mjpg>
<view
v-if="buttonInfo"
:style="{
top: buttonInfo.bottom + 15 + 'px'
}"
class="bg-[rgba(0,0,0,0.35)] rounded-full px-2 py-1.5 fixed right-32"
>
<picker :value="index" mode="selector" :range="range" range-key="name" @change="changeEvent">
<up-icon
:label="range[index].name"
color="#ffffff"
label-color="#ffffff"
labelPos="left"
name="arrow-down-fill"
size="32rpx"
space="16rpx"
></up-icon>
</picker>
<view>
<!-- #ifdef MP-WEIXIN -->
<iot-p2p-player-with-mjpg
v-if="deviceInfo"
id="playerRef"
:deviceInfo="deviceInfo"
:xp2pInfo="xp2pInfo"
:rotate="90"
:muted="isMute"
mode="RTC"
:acceptPlayerEvents="true"
soundMode="speaker"
sceneType="live"
:streamQuality="range[index].value"
:minCache="0.2"
:maxCache="0.8"
:fill="true"
orientation="horizontal"
@playsuccess="handlePlaySuccess"
>
</iot-p2p-player-with-mjpg>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<video
autoplay
id="playerRef"
v-if="url"
:muted="isMute"
:src="urlPrefix"
object-fit="cover"
class="w-[100vw] h-[100vh]"
:is-live="true"
:play-strategy="2"
:controls="false"
:show-progress="false"
:show-fullscreen-btn="false"
:show-play-btn="false"
:enable-progress-gesture="false"
:vslide-gesture="true"
/>
<!-- #endif -->
</view>
<image
v-if="!isVideoLoaded"
src="https://oss-lock.xhjcn.ltd/mp/background_monitor.png"
class="w-full h-full absolute top-0 left-0"
></image>
<cover-view
v-if="isApp || buttonInfo"
:style="{
top: isApp ? '60px' : buttonInfo.bottom + 15 + 'px'
}"
class="bg-[rgba(0,0,0,0.35)] rounded-full px-4 py-1.5 fixed right-32"
>
<cover-view class="text-white text-xs" @click="showQualitySelector">
{{ range[index].name }}
</cover-view>
</cover-view>
<!-- #ifdef MP-WEIXIN -->
<iot-p2p-voice
v-if="deviceInfo"
id="voiceComponent"
@ -51,58 +70,94 @@
voiceType="Pusher"
>
</iot-p2p-voice>
<!-- #endif -->
<view
<cover-view
v-if="isVideoLoaded"
class="fixed bottom-[calc(32rpx+env(safe-area-inset-bottom))] bg-[rgba(0,0,0,0.3)] rounded-xl p-4 shadow-lg left-1/2 -translate-x-1/2 w-622"
>
<view class="flex items-center justify-around mx-15">
<image
@click="isMute = !isMute"
:src="
isMute
? 'https://oss-lock.xhjcn.ltd/mp/icon_mute.png'
: 'https://oss-lock.xhjcn.ltd/mp/icon_not_mute.png'
"
class="w-48 h-48 p-2"
></image>
<image
@click="handleScreenshot"
src="https://oss-lock.xhjcn.ltd/mp/icon_screenshot.png"
class="w-48 h-48 p-2"
></image>
</view>
<view class="flex items-center justify-between text-white mt-2 px-10">
<view class="flex flex-col items-center" @longpress="startVoice" @touchend="stopVoice">
<view class="bg-white w-80 h-80 rounded-full flex items-center justify-center">
<image
<cover-view class="flex items-center justify-around mx-15">
<cover-view class="relative">
<cover-image
v-show="isMute"
src="https://oss-lock.xhjcn.ltd/mp/icon_mute.png"
:class="isApp ? 'size-48' : 'size-48 p-2'"
></cover-image>
<cover-image
v-show="!isMute"
src="https://oss-lock.xhjcn.ltd/mp/icon_not_mute.png"
:class="isApp ? 'size-48' : 'size-48 p-2'"
></cover-image>
<cover-view
@click="toggleMute"
class="absolute top-0 left-0 w-full h-full size-48 p-2"
></cover-view>
</cover-view>
<cover-view class="relative">
<cover-image
src="https://oss-lock.xhjcn.ltd/mp/icon_screenshot.png"
:class="isApp ? 'size-48' : 'size-48 p-2'"
></cover-image>
<cover-view
@click="handleScreenshot"
class="absolute top-0 left-0 w-full h-full"
></cover-view>
</cover-view>
</cover-view>
<cover-view class="flex items-center justify-between text-white mt-2 px-10">
<cover-view class="flex flex-col items-center">
<cover-view
class="bg-white w-80 h-80 rounded-full flex items-center justify-center relative"
>
<cover-image
:src="
isVoice
? 'https://oss-lock.xhjcn.ltd/mp/icon_microphone.png'
: 'https://oss-lock.xhjcn.ltd/mp/icon_no_microphone.png'
"
class="w-55 h-55"
></image>
</view>
<view class="mt-2 text-center whitespace-nowrap text-xs">长按说话</view>
</view>
<view class="flex flex-col items-center" @click="handleHangUp">
<view class="bg-[#eb292b] w-80 h-80 rounded-full flex items-center justify-center">
<image src="https://oss-lock.xhjcn.ltd/mp/icon_hang_up.png" class="w-60 h-60"></image>
</view>
<view class="mt-2 text-center whitespace-nowrap text-xs">挂断</view>
</view>
<view class="flex flex-col items-center" @click="handleLock">
<view class="bg-[#63b8af] w-80 h-80 rounded-full flex items-center justify-center">
<image
></cover-image>
<cover-view
@click="toggleVoice"
class="absolute top-0 left-0 w-full h-full"
></cover-view>
</cover-view>
<cover-view class="mt-2 text-center whitespace-nowrap text-xs">{{
isVoice ? '点击停止' : '点击说话'
}}</cover-view>
</cover-view>
<cover-view class="flex flex-col items-center">
<cover-view
class="bg-[#eb292b] w-80 h-80 rounded-full flex items-center justify-center relative"
>
<cover-image
src="https://oss-lock.xhjcn.ltd/mp/icon_hang_up.png"
class="w-60 h-60"
></cover-image>
<cover-view
@click="handleHangUp"
class="absolute top-0 left-0 w-full h-full"
></cover-view>
</cover-view>
<cover-view class="mt-2 text-center whitespace-nowrap text-xs">挂断</cover-view>
</cover-view>
<cover-view class="flex flex-col items-center">
<cover-view
class="bg-[#63b8af] w-80 h-80 rounded-full flex items-center justify-center relative"
>
<cover-image
src="https://oss-lock.xhjcn.ltd/mp/icon_lock_white.png"
class="w-60 h-60"
></image>
</view>
<view class="mt-2 text-center whitespace-nowrap text-xs">开锁</view>
</view>
</view>
</view>
></cover-image>
<cover-view
@click="handleLock"
class="absolute top-0 left-0 w-full h-full"
></cover-view>
</cover-view>
<cover-view class="mt-2 text-center whitespace-nowrap text-xs">开锁</cover-view>
</cover-view>
</cover-view>
</cover-view>
<view
v-if="!isVideoLoaded"
class="fixed bottom-[calc(48rpx+env(safe-area-inset-bottom))] w-full flex justify-center"
@ -119,7 +174,7 @@
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { onMounted, ref, computed } from 'vue'
import { onUnload } from '@dcloudio/uni-app'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic'
@ -131,17 +186,27 @@
import * as B from './exportForPlayerPlugin'
// #endif
// #ifdef APP-PLUS
import {
startService,
getLiveUrl,
stopService,
runSendService,
stopSendService,
dataSend
} from '@/uni_modules/xhj-tencent-xp2p'
// #endif
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()
const $user = useUserStore()
const buttonInfo = ref(null)
const isApp = ref(false)
const onlineToken = ref('0')
const lockId = ref()
const time = ref(0)
const pending = ref(false)
const index = ref(1)
@ -153,13 +218,22 @@
const deviceInfo = ref()
const xp2pInfo = ref()
const url = ref()
const isVoice = ref(false)
const isMute = ref(false)
const isVideoLoaded = ref(false)
const urlPrefix = computed(() => {
return url.value + `ipc.flv?action=live&channel=0&quality=${range.value[index.value].value}`
})
onMounted(async () => {
// #ifdef APP-PLUS
isApp.value = true
//
initRecorder()
// #endif
// #ifdef MP-WEIXIN
console.log(A, B)
// #endif
@ -173,6 +247,7 @@
}
})
// #ifdef MP-WEIXIN
if (code === 0) {
deviceInfo.value = {
deviceId: `${data.productId}/${data.deviceName}`,
@ -183,23 +258,76 @@
} else {
$basic.backAndToast(message)
}
await getServeTime()
// #endif
// #ifdef APP-PLUS
if (code === 0) {
deviceInfo.value = data
const result = await startService({
appKey: 'aanuJXFtISXFYVVsd',
appSecret: 'SsnOMHJUcazCvpULSVWY',
productId: deviceInfo.value.productId,
deviceName: deviceInfo.value.deviceName,
xp2pInfo: deviceInfo.value.xp2pInfo
})
if (result.code === 0) {
setTimeout(async () => {
const urlResult = await getLiveUrl({
id: `${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`
})
if (urlResult.code === 0) {
url.value = urlResult.data.url
runSendService(
`${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`,
'channel=0',
true
)
handlePlaySuccess()
} else {
$basic.backAndToast(message)
}
}, 200)
} else {
$basic.backAndToast(message)
}
} else {
$basic.backAndToast(message)
}
// #endif
})
onUnload(() => {
// #ifdef APP-PLUS
//
if (isVoice.value && recorderManager.value) {
stopRecording()
}
stopSendService(`${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`)
stopService({
id: `${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`
})
// #endif
// #ifdef MP-WEIXIN
const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef')
if (player.stopAll) {
player.stopAll()
}
// #endif
})
const changeEvent = e => {
index.value = e.detail.value
const showQualitySelector = () => {
uni.showActionSheet({
itemList: range.value.map(item => item.name),
success: res => {
index.value = res.tapIndex
}
})
}
const handleScreenshot = () => {
// #ifdef MP-WEIXIN
const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef')
@ -220,14 +348,26 @@
}
})
})
// #endif
// #ifdef APP-PLUS
uni.showModal({
title: '提示',
content:
'由于技术限制APP端无法直接截取视频画面。请使用手机系统截图功能\n\niOS同时按下电源键+音量上键\nAndroid同时按下电源键+音量下键',
confirmText: '我知道了',
showCancel: false
})
// #endif
}
const handleHangUp = () => {
// #ifdef MP-WEIXIN
const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef')
if (player.stopAll) {
player.stopAll()
}
// #endif
uni.navigateBack()
}
@ -340,24 +480,144 @@
return false
}
const startVoice = () => {
uni.vibrateLong()
isVoice.value = true
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
voice.startVoice()
// #ifdef APP-PLUS
const recorderManager = ref(null)
const recordingFilePath = ref('')
// #endif
const convertAudioFileToUint8Array = filePath => {
// #ifdef APP-PLUS
try {
plus.io.resolveLocalFileSystemURL(filePath, entry => {
entry.file(
file => {
console.log(11111, file)
if (file.size === 0) return
const fileReader = new plus.io.FileReader()
fileReader.onloadend = async evt => {
try {
console.log(evt)
const base64 = evt.target.result.split(',')[1]
const binaryString = atob(base64)
const byteArray = []
for (let i = 0; i < binaryString.length; i++) {
byteArray[i] = binaryString.charCodeAt(i)
}
const id = `${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`
await dataSend(id, byteArray)
} catch (error) {
console.error('音频数据转换失败:', error)
}
}
fileReader.onerror = () => {
console.error('音频文件读取失败')
}
fileReader.readAsDataURL(file)
},
error => console.error('获取文件对象失败:', error)
)
})
} catch (error) {
console.error('音频文件处理异常:', error)
}
// #endif
}
const stopVoice = () => {
isVoice.value = false
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
voice.stopVoice()
const initRecorder = () => {
// #ifdef APP-PLUS
recorderManager.value = uni.getRecorderManager()
recorderManager.value.onStart(() => {
console.log('录音开始')
})
recorderManager.value.onError(error => {
console.error('录音出错:', error)
})
recorderManager.value.onStop(res => {
console.log('录音结束:', res)
recordingFilePath.value = res.tempFilePath
convertAudioFileToUint8Array(res.tempFilePath)
})
// #endif
}
//
const startRecording = () => {
// #ifdef APP-PLUS
if (!recorderManager.value) {
initRecorder()
}
recorderManager.value.start({
duration: 60000,
sampleRate: 16000,
format: 'aac'
})
console.log('开始录音')
// #endif
}
//
const stopRecording = () => {
// #ifdef APP-PLUS
if (recorderManager.value) {
recorderManager.value.stop()
console.log('停止录音')
}
// #endif
}
const toggleVoice = () => {
// #ifdef MP-WEIXIN
if (isVoice.value) {
isVoice.value = false
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
if (voice) {
voice.stopVoice()
}
} else {
uni.vibrateLong()
isVoice.value = true
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
if (voice) {
voice.startVoice()
}
}
// #endif
// #ifdef APP-PLUS
if (isVoice.value) {
isVoice.value = false
stopRecording()
} else {
uni.vibrateLong()
isVoice.value = true
//
startRecording()
}
// #endif
}
const handlePlaySuccess = () => {
isVideoLoaded.value = true
}
const toggleMute = () => {
isMute.value = !isMute.value
}
</script>
<style lang="scss" scoped>

View File

@ -21,7 +21,12 @@
>
<view class="flex items-center">
<view class="w-80 h-full flex items-center justify-center">
<up-icon v-if="isAllDay === 0" name="checkbox-mark" color="#2a85ec" size="40rpx"></up-icon>
<up-icon
v-if="isAllDay === 0"
name="checkbox-mark"
color="#2a85ec"
size="40rpx"
></up-icon>
</view>
<view class="flex-1">
<view class="text-lg font-bold" :class="[isAllDay === 0 ? 'text-#2a85ec' : 'text-black']">

16
tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"strict": false,
"skipLibCheck": true,
"allowJs": true,
"noEmit": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "bundler"
},
"include": ["**/*.vue", "**/*.js", "**/*.uts", "uni_modules/**/*.uts"],
"exclude": ["node_modules", "unpackage", "dist"]
}

View File

@ -0,0 +1,72 @@
{
"id": "xhj-tencent-xp2p",
"displayName": "xhj-tencent-xp2p",
"version": "1.0.0",
"description": "xhj-tencent-xp2p",
"keywords": [
"xhj-tencent-xp2p"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.8"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u",
"alipay": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-android": "u",
"app-ios": "u",
"app-harmony": "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"
}
}
}
}
}

View File

@ -0,0 +1,7 @@
# xhj-tencent-xp2p
### 开发文档
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
[UTS uni-app兼容模式组件](https://uniapp.dcloud.net.cn/plugin/uts-component.html)
[UTS 标准模式组件](https://doc.dcloud.net.cn/uni-app-x/plugin/uts-vue-component.html)
[Hello UTS](https://gitcode.net/dcloud/hello-uts)

View File

@ -0,0 +1,4 @@
{
"minSdkVersion": "21",
"dependencies": ["com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.54"]
}

View File

@ -0,0 +1,160 @@
import { UTSAndroid } from 'io.dcloud.uts'
import { XP2PAppConfig, XP2P } from 'com.tencent.xnet'
import { Result, InitParams, IdParams } from '../interface.uts'
export const startService = async function (params: InitParams): Promise<Result> {
try {
const context = UTSAndroid.getAppContext()
let xp2pConfig: XP2PAppConfig = new XP2PAppConfig()
xp2pConfig.appKey = params.appKey
xp2pConfig.appSecret = params.appSecret
await XP2P.startService(
context,
params.productId,
params.deviceName,
params.xp2pInfo,
xp2pConfig
)
return {
code: 0,
data: {},
message: '成功'
}
} catch (error) {
return {
code: -1,
data: {},
message: error.toString()
}
}
}
export const getLiveUrl = async function (params: IdParams): Promise<Result> {
try {
const liveUrl = await XP2P.delegateHttpFlv(params.id)
return {
code: 0,
data: {
url: liveUrl
},
message: '成功'
}
} catch (error) {
return {
code: -1,
data: {},
message: error.toString()
}
}
}
export const stopService = async function (params: IdParams): Promise<Result> {
try {
await XP2P.stopService(params.id)
return {
code: 0,
data: {},
message: '成功'
}
} catch (error) {
return {
code: -1,
data: {},
message: error.toString()
}
}
}
// export const setCallback = function (callback: XP2PCallback) {
// try {
// XP2P.setCallback(callback)
// } catch (error) {
// console.log(2, error)
// }
// }
export const runSendService = async function (
id: string,
cmd: string,
crypto: boolean
): Promise<Result> {
try {
await XP2P.runSendService(id, cmd, crypto)
console.log('开始发送服务')
return {
code: 0,
data: {},
message: '成功'
}
} catch (error) {
return {
code: -1,
data: {},
message: error.toString()
}
}
}
export const stopSendService = async function (id: string): Promise<Result> {
try {
await XP2P.stopSendService(id, null)
console.log('停止发送服务')
return {
code: 0,
data: {},
message: '成功'
}
} catch (error) {
return {
code: -1,
data: {},
message: error.toString()
}
}
}
export const dataSend = async function (id: string, data: Array<number>): Promise<Result> {
try {
let byteTest = new ByteArray(data.length.toInt())
// byteTest.set(0, (0xff).toByte())
// byteTest.set(1, (0xf9).toByte())
// let profile = 2
// let freqIdx = 8
// let chanCfg = 1
// let packetLen = data.length + 7
// byteTest.set(2, (((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2)).toByte())
// byteTest.set(3, (((chanCfg & 3) << 6) + (packetLen >> 11)).toByte())
// byteTest.set(4, ((packetLen & 0x7ff) >> 3).toByte())
// byteTest.set(5, (((packetLen & 7) << 5) + 0x1f).toByte())
// byteTest.set(6, (0xfc).toByte())
for (let i = 0; i < data.length; i++) {
byteTest.set(i.toInt(), data[i].toByte())
}
console.log(byteTest)
console.log(1, id, byteTest[0], byteTest[1], data.length.toInt())
const result = await XP2P.dataSend(id, byteTest, data.length.toInt())
console.log('发送数据', result)
return {
code: 0,
data: {},
message: '成功'
}
} catch (error) {
return {
code: -1,
data: {},
message: error.toString()
}
}
}

View File

@ -0,0 +1,17 @@
export type Result = {
code: number
data: object
message: string
}
export type InitParams = {
appKey: string
appSecret: string
productId: string
deviceName: string
xp2pInfo: string
}
export type IdParams = {
id: string
}