提交 75b816aa 编写于 作者: fxy060608's avatar fxy060608

chore: size-check

...@@ -189,7 +189,7 @@ function useBase( ...@@ -189,7 +189,7 @@ function useBase(
var maxlength = Number(props.maxlength) var maxlength = Number(props.maxlength)
return isNaN(maxlength) ? 140 : maxlength return isNaN(maxlength) ? 140 : maxlength
}) })
const value = getValueString(props.modelValue || props.value) const value = getValueString(props.modelValue) || getValueString(props.value)
const state: State = reactive({ const state: State = reactive({
value, value,
valueOrigin: value, valueOrigin: value,
......
...@@ -2869,7 +2869,7 @@ function useBase(props2, rootRef, emit2) { ...@@ -2869,7 +2869,7 @@ function useBase(props2, rootRef, emit2) {
var maxlength2 = Number(props2.maxlength); var maxlength2 = Number(props2.maxlength);
return isNaN(maxlength2) ? 140 : maxlength2; return isNaN(maxlength2) ? 140 : maxlength2;
}); });
const value = getValueString(props2.modelValue || props2.value); const value = getValueString(props2.modelValue) || getValueString(props2.value);
const state = vue.reactive({ const state = vue.reactive({
value, value,
valueOrigin: value, valueOrigin: value,
...@@ -10581,7 +10581,7 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({ ...@@ -10581,7 +10581,7 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
const { const {
layoutState, layoutState,
windowState windowState
} = useState(); } = __UNI_FEATURE_RESPONSIVE__ ? useState() : {};
useMaxWidth(layoutState, rootRef); useMaxWidth(layoutState, rootRef);
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState); const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState); const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
...@@ -10608,6 +10608,7 @@ function useAppClass(showTabBar) { ...@@ -10608,6 +10608,7 @@ function useAppClass(showTabBar) {
}); });
} }
function initMediaQuery(minWidth, callback) { function initMediaQuery(minWidth, callback) {
if (typeof window === "object" && window.matchMedia) {
const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)"); const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
if (mediaQueryList.addEventListener) { if (mediaQueryList.addEventListener) {
mediaQueryList.addEventListener("change", callback); mediaQueryList.addEventListener("change", callback);
...@@ -10615,6 +10616,8 @@ function initMediaQuery(minWidth, callback) { ...@@ -10615,6 +10616,8 @@ function initMediaQuery(minWidth, callback) {
mediaQueryList.addListener(callback); mediaQueryList.addListener(callback);
} }
return mediaQueryList.matches; return mediaQueryList.matches;
}
return false;
} }
function useMaxWidth(layoutState, rootRef) { function useMaxWidth(layoutState, rootRef) {
const route = usePageRoute(); const route = usePageRoute();
...@@ -10646,7 +10649,6 @@ function useMaxWidth(layoutState, rootRef) { ...@@ -10646,7 +10649,6 @@ function useMaxWidth(layoutState, rootRef) {
} }
} }
vue.watch([() => route.path], checkMaxWidth); vue.watch([() => route.path], checkMaxWidth);
window.addEventListener("resize", checkMaxWidth);
} }
function useState() { function useState() {
const topWindowMediaQuery = vue.ref(false); const topWindowMediaQuery = vue.ref(false);
......
...@@ -4656,7 +4656,7 @@ function useBase(props2, rootRef, emit2) { ...@@ -4656,7 +4656,7 @@ function useBase(props2, rootRef, emit2) {
var maxlength2 = Number(props2.maxlength); var maxlength2 = Number(props2.maxlength);
return isNaN(maxlength2) ? 140 : maxlength2; return isNaN(maxlength2) ? 140 : maxlength2;
}); });
const value = getValueString(props2.modelValue || props2.value); const value = getValueString(props2.modelValue) || getValueString(props2.value);
const state2 = reactive({ const state2 = reactive({
value, value,
valueOrigin: value, valueOrigin: value,
...@@ -14888,9 +14888,28 @@ const innerAudioContextOffEventNames = [ ...@@ -14888,9 +14888,28 @@ const innerAudioContextOffEventNames = [
"offSeeking", "offSeeking",
"offSeeked" "offSeeked"
]; ];
const initInnerAudioContextEventOnce = /* @__PURE__ */ once(() => {
innerAudioContextEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function(callback) {
if (typeof callback === "function") {
this._events[eventName].push(callback);
}
};
});
innerAudioContextOffEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function(callback) {
var handle = this._events[eventName.replace("off", "on")];
var index2 = handle.indexOf(callback);
if (index2 >= 0) {
handle.splice(index2, 1);
}
};
});
});
class InnerAudioContext { class InnerAudioContext {
constructor() { constructor() {
this._src = ""; this._src = "";
initInnerAudioContextEventOnce();
var audio = this._audio = new Audio(); var audio = this._audio = new Audio();
this._stoping = false; this._stoping = false;
const propertys = [ const propertys = [
...@@ -14989,22 +15008,6 @@ class InnerAudioContext { ...@@ -14989,22 +15008,6 @@ class InnerAudioContext {
this.stop(); this.stop();
} }
} }
innerAudioContextEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function(callback) {
if (typeof callback === "function") {
this._events[eventName].push(callback);
}
};
});
innerAudioContextOffEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function(callback) {
var handle = this._events[eventName.replace("off", "on")];
var index2 = handle.indexOf(callback);
if (index2 >= 0) {
handle.splice(index2, 1);
}
};
});
const createInnerAudioContext = /* @__PURE__ */ defineSyncApi(API_CREATE_INNER_AUDIO_CONTEXT, () => { const createInnerAudioContext = /* @__PURE__ */ defineSyncApi(API_CREATE_INNER_AUDIO_CONTEXT, () => {
return new InnerAudioContext(); return new InnerAudioContext();
}); });
...@@ -18054,7 +18057,7 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({ ...@@ -18054,7 +18057,7 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
const { const {
layoutState, layoutState,
windowState windowState
} = useState(); } = __UNI_FEATURE_RESPONSIVE__ ? useState() : {};
useMaxWidth(layoutState, rootRef); useMaxWidth(layoutState, rootRef);
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState); const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState); const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
...@@ -18092,6 +18095,7 @@ function initCssVar() { ...@@ -18092,6 +18095,7 @@ function initCssVar() {
}); });
} }
function initMediaQuery(minWidth, callback) { function initMediaQuery(minWidth, callback) {
if (typeof window === "object" && window.matchMedia) {
const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)"); const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
if (mediaQueryList.addEventListener) { if (mediaQueryList.addEventListener) {
mediaQueryList.addEventListener("change", callback); mediaQueryList.addEventListener("change", callback);
...@@ -18099,6 +18103,8 @@ function initMediaQuery(minWidth, callback) { ...@@ -18099,6 +18103,8 @@ function initMediaQuery(minWidth, callback) {
mediaQueryList.addListener(callback); mediaQueryList.addListener(callback);
} }
return mediaQueryList.matches; return mediaQueryList.matches;
}
return false;
} }
function useMaxWidth(layoutState, rootRef) { function useMaxWidth(layoutState, rootRef) {
const route = usePageRoute(); const route = usePageRoute();
...@@ -18130,8 +18136,10 @@ function useMaxWidth(layoutState, rootRef) { ...@@ -18130,8 +18136,10 @@ function useMaxWidth(layoutState, rootRef) {
} }
} }
watch([() => route.path], checkMaxWidth); watch([() => route.path], checkMaxWidth);
onMounted(checkMaxWidth); onMounted(() => {
checkMaxWidth();
window.addEventListener("resize", checkMaxWidth); window.addEventListener("resize", checkMaxWidth);
});
} }
function useState() { function useState() {
const topWindowMediaQuery = ref(false); const topWindowMediaQuery = ref(false);
......
...@@ -47,7 +47,9 @@ export default /*#__PURE__*/ defineSystemComponent({ ...@@ -47,7 +47,9 @@ export default /*#__PURE__*/ defineSystemComponent({
!__NODE_JS__ && initCssVar() !__NODE_JS__ && initCssVar()
const keepAliveRoute = (__UNI_FEATURE_PAGES__ && const keepAliveRoute = (__UNI_FEATURE_PAGES__ &&
useKeepAliveRoute()) as KeepAliveRoute useKeepAliveRoute()) as KeepAliveRoute
const { layoutState, windowState } = useState() const { layoutState, windowState } = __UNI_FEATURE_RESPONSIVE__
? useState()
: ({} as ReturnType<typeof useState>)
useMaxWidth(layoutState, rootRef) useMaxWidth(layoutState, rootRef)
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState) const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState)
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState) const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState)
...@@ -128,6 +130,7 @@ function initMediaQuery( ...@@ -128,6 +130,7 @@ function initMediaQuery(
minWidth: number, minWidth: number,
callback: (ev: MediaQueryListEvent) => void callback: (ev: MediaQueryListEvent) => void
) { ) {
if (typeof window === 'object' && window.matchMedia) {
const mediaQueryList = window.matchMedia('(min-width: ' + minWidth + 'px)') const mediaQueryList = window.matchMedia('(min-width: ' + minWidth + 'px)')
if (mediaQueryList.addEventListener) { if (mediaQueryList.addEventListener) {
mediaQueryList.addEventListener('change', callback) mediaQueryList.addEventListener('change', callback)
...@@ -135,6 +138,8 @@ function initMediaQuery( ...@@ -135,6 +138,8 @@ function initMediaQuery(
mediaQueryList.addListener(callback) mediaQueryList.addListener(callback)
} }
return mediaQueryList.matches return mediaQueryList.matches
}
return false
} }
function useMaxWidth( function useMaxWidth(
...@@ -173,8 +178,10 @@ function useMaxWidth( ...@@ -173,8 +178,10 @@ function useMaxWidth(
} }
} }
watch([() => route.path], checkMaxWidth) watch([() => route.path], checkMaxWidth)
onMounted(checkMaxWidth) onMounted(() => {
checkMaxWidth()
window.addEventListener('resize', checkMaxWidth) window.addEventListener('resize', checkMaxWidth)
})
} }
function useState() { function useState() {
......
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
defineSyncApi, defineSyncApi,
} from '@dcloudio/uni-api' } from '@dcloudio/uni-api'
import type { API_TYPE_CREATEE_INNER_AUDIO_CONTEXT } from '@dcloudio/uni-api' import type { API_TYPE_CREATEE_INNER_AUDIO_CONTEXT } from '@dcloudio/uni-api'
import { once } from '@dcloudio/uni-shared'
//#region types //#region types
type InnerAudioContextEvent = type InnerAudioContextEvent =
...@@ -72,6 +73,28 @@ const innerAudioContextOffEventNames: InnerAudioContextOff[] = [ ...@@ -72,6 +73,28 @@ const innerAudioContextOffEventNames: InnerAudioContextOff[] = [
'offSeeked', 'offSeeked',
] ]
const initInnerAudioContextEventOnce = /*#__PURE__*/ once(() => {
// 批量设置音频上下文事件监听方法
innerAudioContextEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function (callback: Function) {
if (typeof callback === 'function') {
this._events[eventName]!.push(callback)
}
}
})
// 批量设置音频上下文事件取消监听方法
innerAudioContextOffEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function (callback: Function) {
var handle =
this._events[eventName.replace('off', 'on') as InnerAudioContextEvent]
var index = handle!.indexOf(callback)
if (index >= 0) {
handle!.splice(index, 1)
}
}
})
})
/** /**
* 音频上下文对象 * 音频上下文对象
*/ */
...@@ -136,6 +159,7 @@ class InnerAudioContext implements UniApp.InnerAudioContext { ...@@ -136,6 +159,7 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
* 音频上下文初始化 * 音频上下文初始化
*/ */
constructor() { constructor() {
initInnerAudioContextEventOnce()
var audio = (this._audio = new Audio()) var audio = (this._audio = new Audio())
this._stoping = false this._stoping = false
// 和audio对象同名同效果的属性 // 和audio对象同名同效果的属性
...@@ -295,27 +319,6 @@ class InnerAudioContext implements UniApp.InnerAudioContext { ...@@ -295,27 +319,6 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
'offSeeked': UniApp.InnerAudioContext['offSeeked'] 'offSeeked': UniApp.InnerAudioContext['offSeeked']
} }
// 批量设置音频上下文事件监听方法
innerAudioContextEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function (callback: Function) {
if (typeof callback === 'function') {
this._events[eventName]!.push(callback)
}
}
})
// 批量设置音频上下文事件取消监听方法
innerAudioContextOffEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function (callback: Function) {
var handle =
this._events[eventName.replace('off', 'on') as InnerAudioContextEvent]
var index = handle!.indexOf(callback)
if (index >= 0) {
handle!.splice(index, 1)
}
}
})
/** /**
* 创建音频上下文 * 创建音频上下文
*/ */
......
...@@ -29,7 +29,7 @@ function initCostomDataset() { ...@@ -29,7 +29,7 @@ function initCostomDataset() {
}; };
} }
function getCostomDataset(el) { function getCostomDataset(el) {
return Object.assign({}, el.dataset, el.__uniDataset); return shared.extend({}, el.dataset, el.__uniDataset);
} }
const unitRE = new RegExp(`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`, 'g'); const unitRE = new RegExp(`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`, 'g');
......
import { camelize, isString, isHTMLTag, isSVGTag, isPlainObject, isArray } from '@vue/shared'; import { camelize, extend, isString, isHTMLTag, isSVGTag, isPlainObject, isArray } from '@vue/shared';
function formatKey(key) { function formatKey(key) {
return camelize(key.substring(5)); return camelize(key.substring(5));
...@@ -25,7 +25,7 @@ function initCostomDataset() { ...@@ -25,7 +25,7 @@ function initCostomDataset() {
}; };
} }
function getCostomDataset(el) { function getCostomDataset(el) {
return Object.assign({}, el.dataset, el.__uniDataset); return extend({}, el.dataset, el.__uniDataset);
} }
const unitRE = new RegExp(`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`, 'g'); const unitRE = new RegExp(`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`, 'g');
......
import { camelize } from '@vue/shared' import { extend, camelize } from '@vue/shared'
interface HTMLElementWithDataset extends HTMLElement { interface HTMLElementWithDataset extends HTMLElement {
__uniDataset?: Record<string, any> __uniDataset?: Record<string, any>
} }
...@@ -33,9 +33,5 @@ export function initCostomDataset() { ...@@ -33,9 +33,5 @@ export function initCostomDataset() {
} }
export function getCostomDataset(el: HTMLElement | HTMLElementWithDataset) { export function getCostomDataset(el: HTMLElement | HTMLElementWithDataset) {
return Object.assign( return extend({}, el.dataset, (el as HTMLElementWithDataset).__uniDataset)
{},
el.dataset,
(el as HTMLElementWithDataset).__uniDataset
)
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册