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