From 9bce51f651aad297ef9eb6df832bfdaf1de05d84 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 14:27:54 +0800
Subject: [PATCH] 青岛推送
---
node_modules/@dcloudio/uni-ui/lib/uni-rate/uni-rate.vue | 50 ++++++++++++++++++++++++++++++--------------------
1 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/node_modules/@dcloudio/uni-ui/lib/uni-rate/uni-rate.vue b/node_modules/@dcloudio/uni-ui/lib/uni-rate/uni-rate.vue
index 857f5f9..34ddf18 100644
--- a/node_modules/@dcloudio/uni-ui/lib/uni-rate/uni-rate.vue
+++ b/node_modules/@dcloudio/uni-ui/lib/uni-rate/uni-rate.vue
@@ -119,7 +119,8 @@
valueSync: "",
userMouseFristMove: true,
userRated: false,
- userLastRate: 1
+ userLastRate: 1,
+ PC: false
};
},
watch: {
@@ -162,31 +163,31 @@
this.valueSync = Number(this.value || this.modelValue);
this._rateBoxLeft = 0
this._oldValue = null
+ // #ifdef H5
+ this.PC = this.IsPC()
+ // #endif
},
mounted() {
setTimeout(() => {
this._getSize()
}, 100)
- // #ifdef H5
- this.PC = this.IsPC()
- // #endif
},
methods: {
touchstart(e) {
// #ifdef H5
- if (this.IsPC()) return
+ if (this.PC) return
// #endif
if (this.readonly || this.disabled) return
const {
clientX,
screenX
} = e.changedTouches[0]
- // TODO 鍋氫竴涓嬪吋瀹癸紝鍙湁 Nvue 涓嬫墠鏈� screenX锛屽叾浠栧钩鍙板紡 clientX
+ // TODO 鍋氫竴涓嬪吋瀹癸紝鍙湁 Nvue 涓嬫墠鏈� screenX锛屽叾浠栧钩鍙版槸 clientX
this._getRateCount(clientX || screenX)
},
touchmove(e) {
// #ifdef H5
- if (this.IsPC()) return
+ if (this.PC) return
// #endif
if (this.readonly || this.disabled || !this.touchable) return
const {
@@ -202,7 +203,7 @@
mousedown(e) {
// #ifdef H5
- if (!this.IsPC()) return
+ if (!this.PC) return
if (this.readonly || this.disabled) return
const {
clientX,
@@ -214,10 +215,9 @@
},
mousemove(e) {
// #ifdef H5
- if (!this.IsPC()) return
+ if (!this.PC) return
if (this.userRated) return
if (this.userMouseFristMove) {
- console.log('---mousemove----', this.valueSync);
this.userLastRate = this.valueSync
this.userMouseFristMove = false
}
@@ -230,7 +230,7 @@
},
mouseleave(e) {
// #ifdef H5
- if (!this.IsPC()) return
+ if (!this.PC) return
if (this.readonly || this.disabled || !this.touchable) return
if (this.userRated) {
this.userRated = false
@@ -241,16 +241,26 @@
},
// #ifdef H5
IsPC() {
- var userAgentInfo = navigator.userAgent;
- var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
- var flag = true;
- for (let v = 0; v < Agents.length - 1; v++) {
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
- flag = false;
- break;
- }
+ var userAgentInfo = navigator.userAgent || '';
+ var info = typeof uni !== 'undefined' && uni.getSystemInfoSync ? uni.getSystemInfoSync() : null;
+ if (info && info.deviceType) {
+ if (info.deviceType === 'pc') return true;
+ if (info.deviceType === 'phone' || info.deviceType === 'pad') return false;
}
- return flag;
+ var isMobileUA = /Android|iPhone|SymbianOS|Windows Phone|iPad|iPod|Mobile|Harmony|HarmonyOS/i.test(userAgentInfo);
+ if (isMobileUA) return false;
+ var hasTouch = false;
+ if (typeof navigator.maxTouchPoints === 'number') {
+ hasTouch = navigator.maxTouchPoints > 0;
+ } else if (typeof window !== 'undefined') {
+ hasTouch = 'ontouchstart' in window;
+ }
+ if (hasTouch && typeof window !== 'undefined' && window.matchMedia) {
+ var finePointer = window.matchMedia('(pointer: fine)').matches;
+ var canHover = window.matchMedia('(hover: hover)').matches;
+ return finePointer || canHover;
+ }
+ return !hasTouch;
},
// #endif
--
Gitblit v1.9.3