提交 e243f654 编写于 作者: D DCloud_LXH

fix: slider props.value watcher

上级 07b136d2
import { computed, inject, onMounted, onBeforeUnmount, ref } from 'vue'
import { computed, inject, onMounted, onBeforeUnmount, ref, watch } from 'vue'
import type { ExtractPropTypes, Ref } from 'vue'
import { defineBuiltInComponent } from '../../helpers/component'
import { useTouchtrack, TouchtrackEvent } from '../../helpers/useTouchtrack'
......@@ -77,6 +77,13 @@ export default /*#__PURE__*/ defineBuiltInComponent({
const sliderValueRef: HTMLRef = ref(null)
const sliderHandleRef: HTMLRef = ref(null)
const sliderValue = ref(Number(props.value))
watch(
() => props.value,
(val) => {
sliderValue.value = Number(val)
}
)
const trigger = useCustomEvent<EmitEvent<typeof emit>>(sliderRef, emit)
const state = useSliderState(props, sliderValue)
......
......@@ -6283,6 +6283,9 @@ var index$e = /* @__PURE__ */ defineBuiltInComponent({
const sliderValueRef = vue.ref(null);
const sliderHandleRef = vue.ref(null);
const sliderValue = vue.ref(Number(props2.value));
vue.watch(() => props2.value, (val) => {
sliderValue.value = Number(val);
});
const trigger = useCustomEvent(sliderRef, emit2);
const state = useSliderState(props2, sliderValue);
const {
......
......@@ -485,7 +485,7 @@ var safeAreaInsets = {
onChange,
offChange
};
var out = safeAreaInsets;
var D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => {
......@@ -497,10 +497,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right"));
return {
top: top ? top + out.top : 0,
bottom: bottom ? bottom + out.bottom : 0,
left: left ? left + out.left : 0,
right: right ? right + out.right : 0
top: top ? top + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top : 0,
bottom: bottom ? bottom + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom : 0,
left: left ? left + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left : 0,
right: right ? right + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right : 0
};
}
function updateCssVar(cssVars) {
......@@ -1190,7 +1190,7 @@ function normalizePageMeta(pageMeta) {
let offset = rpx2px(refreshOptions.offset);
const {type} = navigationBar;
if (type !== "transparent" && type !== "none") {
offset += NAVBAR_HEIGHT + out.top;
offset += NAVBAR_HEIGHT + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top;
}
refreshOptions.offset = offset;
refreshOptions.height = rpx2px(refreshOptions.height);
......@@ -8373,6 +8373,9 @@ var index$d = /* @__PURE__ */ defineBuiltInComponent({
const sliderValueRef = ref(null);
const sliderHandleRef = ref(null);
const sliderValue = ref(Number(props2.value));
watch(() => props2.value, (val) => {
sliderValue.value = Number(val);
});
const trigger = useCustomEvent(sliderRef, emit2);
const state2 = useSliderState(props2, sliderValue);
const {
......@@ -14778,20 +14781,20 @@ const innerAudioContextOffEventNames = [
"offSeeking",
"offSeeked"
];
const propertys = [
"src",
"autoplay",
"loop",
"duration",
"currentTime",
"paused",
"volume"
];
class InnerAudioContext {
constructor() {
this._src = "";
var audio = this._audio = new Audio();
this._stoping = false;
const propertys = [
"src",
"autoplay",
"loop",
"duration",
"currentTime",
"paused",
"volume"
];
propertys.forEach((property) => {
Object.defineProperty(this, property, {
set: property === "src" ? (src) => {
......@@ -14799,7 +14802,7 @@ class InnerAudioContext {
this._src = src;
return src;
} : (val) => {
audio.setAttribute(property, val);
audio[property] = val;
return val;
},
get: property === "src" ? () => {
......@@ -14815,7 +14818,6 @@ class InnerAudioContext {
get: () => false
});
Object.defineProperty(this, "buffered", {
set: () => false,
get() {
var buffered = audio.buffered;
if (buffered.length) {
......@@ -14835,18 +14837,13 @@ class InnerAudioContext {
audio.currentTime = startTime;
}
});
var eventNames = [
"canplay",
var stopEventNames = ["canplay", "pause", "seeking", "seeked", "timeUpdate"];
var eventNames = stopEventNames.concat([
"play",
"pause",
"ended",
"timeUpdate",
"error",
"waiting",
"seeking",
"seeked"
];
var stopEventNames = ["canplay", "pause", "seeking", "seeked", "timeUpdate"];
"waiting"
]);
eventNames.forEach((eventName) => {
audio.addEventListener(eventName.toLowerCase(), () => {
if (this._stoping && stopEventNames.indexOf(eventName) >= 0) {
......@@ -14917,7 +14914,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight;
const language = navigator.language;
const statusBarHeight = out.top;
const statusBarHeight = D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top;
let osname;
let osversion;
let model;
......@@ -15030,12 +15027,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase();
const safeArea = {
left: out.left,
right: windowWidth - out.right,
top: out.top,
bottom: windowHeight - out.bottom,
width: windowWidth - out.left - out.right,
height: windowHeight - out.top - out.bottom
left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left,
right: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top,
bottom: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom,
width: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
height: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom
};
const {top: windowTop, bottom: windowBottom} = getWindowOffset();
windowHeight -= windowTop;
......@@ -15055,10 +15052,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model,
safeArea,
safeAreaInsets: {
top: out.top,
right: out.right,
bottom: out.bottom,
left: out.left
top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top,
right: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
bottom: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom,
left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left
}
};
});
......@@ -16292,14 +16289,14 @@ ${e2};at socketTask.on${capitalize(name)} callback function
}
});
});
const propertys2 = [
const propertys = [
"CLOSED",
"CLOSING",
"CONNECTING",
"OPEN",
"readyState"
];
propertys2.forEach((property) => {
propertys.forEach((property) => {
Object.defineProperty(this, property, {
get() {
return webSocket[property];
......
......@@ -41,7 +41,6 @@ type Property =
type InnerAudioProperty = keyof Pick<HTMLMediaElement, Property>
type VoidFunction = (callback: (result: any) => void) => void
//#endregion
/**
......@@ -73,17 +72,6 @@ const innerAudioContextOffEventNames: InnerAudioContextOff[] = [
'offSeeked',
]
// 和audio对象同名同效果的属性
const propertys: InnerAudioProperty[] = [
'src',
'autoplay',
'loop',
'duration',
'currentTime',
'paused',
'volume',
]
/**
* 音频上下文对象
*/
......@@ -91,39 +79,39 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
/**
* 当前音频的长度(单位:s),只有在当前有合法的 src 时返回
*/
duration!: number
'duration': UniApp.InnerAudioContext['duration']
/**
* 当前音频的播放位置(单位:s),只有在当前有合法的 src 时返回
*/
currentTime!: number
'currentTime': UniApp.InnerAudioContext['currentTime']
/**
* 当前是是否暂停或停止状态,true 表示暂停或停止,false 表示正在播放
*/
paused!: boolean
'paused': UniApp.InnerAudioContext['paused']
/**
* 音频的数据链接,用于直接播放。
*/
src!: string
'src': UniApp.InnerAudioContext['src']
/**
* 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲
*/
buffered!: number
'buffered': UniApp.InnerAudioContext['buffered']
/**
* 是否自动开始播放,默认 false
*/
autoplay!: boolean
'autoplay': UniApp.InnerAudioContext['autoplay']
/**
* 是否循环播放,默认 false
*/
loop!: boolean
'loop': UniApp.InnerAudioContext['loop']
/**
* 是否遵循系统静音开关,当此参数为 false 时,即使用户打开了静音开关,也能继续发出声音,默认值 true
*/
obeyMuteSwitch!: boolean
'obeyMuteSwitch': UniApp.InnerAudioContext['obeyMuteSwitch']
/**
* 音量。范围 0~1。
*/
volume!: number
'volume': UniApp.InnerAudioContext['volume']
/**
* 原始音频对象
*/
......@@ -150,6 +138,16 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
constructor() {
var audio = (this._audio = new Audio())
this._stoping = false
// 和audio对象同名同效果的属性
const propertys: InnerAudioProperty[] = [
'src',
'autoplay',
'loop',
'duration',
'currentTime',
'paused',
'volume',
]
propertys.forEach((property) => {
Object.defineProperty(this, property, {
set:
......@@ -160,8 +158,7 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
return src
}
: (val) => {
// audio[property] = val
audio.setAttribute(property, val)
;(audio as any)[property] = val
return val
},
get:
......@@ -180,7 +177,6 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
get: () => false,
})
Object.defineProperty(this, 'buffered', {
set: () => false,
get() {
var buffered = audio.buffered
if (buffered.length) {
......@@ -202,18 +198,14 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
}
})
// 和audio对象同名同效果的事件
var eventNames = [
'canplay',
var stopEventNames = ['canplay', 'pause', 'seeking', 'seeked', 'timeUpdate']
var eventNames = stopEventNames.concat([
'play',
'pause',
'ended',
'timeUpdate',
'error',
'waiting',
'seeking',
'seeked',
]
var stopEventNames = ['canplay', 'pause', 'seeking', 'seeked', 'timeUpdate']
])
eventNames.forEach((eventName) => {
audio.addEventListener(
eventName.toLowerCase(),
......@@ -280,27 +272,27 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
this.stop()
}
'onCanplay': VoidFunction
'onPlay': VoidFunction
'onPause': VoidFunction
'onStop': VoidFunction
'onEnded': VoidFunction
'onTimeUpdate': VoidFunction
'onError': VoidFunction
'onWaiting': VoidFunction
'onSeeking': VoidFunction
'onSeeked': VoidFunction
'onCanplay': UniApp.InnerAudioContext['onCanplay']
'onPlay': UniApp.InnerAudioContext['onPlay']
'onPause': UniApp.InnerAudioContext['onPause']
'onStop': UniApp.InnerAudioContext['onStop']
'onEnded': UniApp.InnerAudioContext['onEnded']
'onTimeUpdate': UniApp.InnerAudioContext['onTimeUpdate']
'onError': UniApp.InnerAudioContext['onError']
'onWaiting': UniApp.InnerAudioContext['onWaiting']
'onSeeking': UniApp.InnerAudioContext['onSeeking']
'onSeeked': UniApp.InnerAudioContext['onSeeked']
'offCanplay': VoidFunction
'offPlay': VoidFunction
'offPause': VoidFunction
'offStop': VoidFunction
'offEnded': VoidFunction
'offTimeUpdate': VoidFunction
'offError': VoidFunction
'offWaiting': VoidFunction
'offSeeking': VoidFunction
'offSeeked': VoidFunction
'offCanplay': UniApp.InnerAudioContext['offCanplay']
'offPlay': UniApp.InnerAudioContext['offPlay']
'offPause': UniApp.InnerAudioContext['offPause']
'offStop': UniApp.InnerAudioContext['offStop']
'offEnded': UniApp.InnerAudioContext['offEnded']
'offTimeUpdate': UniApp.InnerAudioContext['offTimeUpdate']
'offError': UniApp.InnerAudioContext['offError']
'offWaiting': UniApp.InnerAudioContext['offWaiting']
'offSeeking': UniApp.InnerAudioContext['offSeeking']
'offSeeked': UniApp.InnerAudioContext['offSeeked']
}
// 批量设置音频上下文事件监听方法
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册