提交 f992e2ff 编写于 作者: Q qiang

fix(h5): useMaxWidth

上级 2072af59
......@@ -10569,7 +10569,7 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
layoutState,
windowState
} = __UNI_FEATURE_RESPONSIVE__ ? useState() : {};
useMaxWidth(layoutState, rootRef);
layoutState && useMaxWidth(layoutState, rootRef);
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
......
......@@ -18042,7 +18042,7 @@ function createTabBarMidButtonTsx(color, iconPath, midButton, tabBar2, index2, o
}, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, midButton, tabBar2)], 12, ["onClick"]);
}
const DEFAULT_CSS_VAR_VALUE = "0px";
let globalLayoutState;
let globalLayoutState = void 0;
function getLayoutState() {
return globalLayoutState;
}
......@@ -18058,7 +18058,7 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({
layoutState,
windowState
} = __UNI_FEATURE_RESPONSIVE__ ? useState() : {};
useMaxWidth(layoutState, rootRef);
layoutState && useMaxWidth(layoutState, rootRef);
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
......@@ -18442,27 +18442,33 @@ const hideRightWindow = /* @__PURE__ */ defineAsyncApi("hideRightWindow", (_, {r
});
const getTopWindowStyle = /* @__PURE__ */ defineSyncApi("getTopWindowStyle", () => {
const state2 = getLayoutState();
return Object.assign({}, state2.topWindowStyle);
return Object.assign({}, state2 && state2.topWindowStyle);
});
const setTopWindowStyle = /* @__PURE__ */ defineSyncApi("setTopWindowStyle", (style) => {
const state2 = getLayoutState();
state2.topWindowStyle = style;
if (state2) {
state2.topWindowStyle = style;
}
});
const getLeftWindowStyle = /* @__PURE__ */ defineSyncApi("getLeftWindowStyle", () => {
const state2 = getLayoutState();
return Object.assign({}, state2.leftWindowStyle);
return Object.assign({}, state2 && state2.leftWindowStyle);
});
const setLeftWindowStyle = /* @__PURE__ */ defineSyncApi("setLeftWindowStyle", (style) => {
const state2 = getLayoutState();
state2.leftWindowStyle = style;
if (state2) {
state2.leftWindowStyle = style;
}
});
const getRightWindowStyle = /* @__PURE__ */ defineSyncApi("getRightWindowStyle", () => {
const state2 = getLayoutState();
return Object.assign({}, state2.rightWindowStyle);
return Object.assign({}, state2 && state2.rightWindowStyle);
});
const setRightWindowStyle = /* @__PURE__ */ defineSyncApi("setRightWindowStyle", (style) => {
const state2 = getLayoutState();
state2.rightWindowStyle = style;
if (state2) {
state2.rightWindowStyle = style;
}
});
var api = /* @__PURE__ */ Object.freeze({
__proto__: null,
......
......@@ -35,7 +35,7 @@ type KeepAliveRoute = ReturnType<typeof useKeepAliveRoute>
const DEFAULT_CSS_VAR_VALUE = '0px'
let globalLayoutState: LayoutState
let globalLayoutState: LayoutState | undefined = undefined
export function getLayoutState() {
return globalLayoutState
}
......@@ -49,12 +49,12 @@ export default /*#__PURE__*/ defineSystemComponent({
useKeepAliveRoute()) as KeepAliveRoute
const { layoutState, windowState } = __UNI_FEATURE_RESPONSIVE__
? useState()
: ({} as ReturnType<typeof useState>)
useMaxWidth(layoutState, rootRef)
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState)
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState)
: ({} as { layoutState: undefined; windowState: undefined })
layoutState && useMaxWidth(layoutState, rootRef)
const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState!)
const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState!)
const rightWindow =
__UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState)
__UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState!)
const showTabBar = (__UNI_FEATURE_TABBAR__ &&
useShowTabBar(emit)) as ComputedRef<boolean>
const clazz = useAppClass(showTabBar)
......@@ -269,8 +269,8 @@ function useState() {
function createLayoutTsx(
keepAliveRoute: KeepAliveRoute,
layoutState: LayoutState,
windowState: WindowState,
layoutState?: LayoutState,
windowState?: WindowState,
topWindow?: unknown,
leftWindow?: unknown,
rightWindow?: unknown
......@@ -283,13 +283,13 @@ function createLayoutTsx(
return routerVNode
}
const topWindowTsx = __UNI_FEATURE_TOPWINDOW__
? createTopWindowTsx(topWindow, layoutState, windowState)
? createTopWindowTsx(topWindow, layoutState!, windowState!)
: null
const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__
? createLeftWindowTsx(leftWindow, layoutState, windowState)
? createLeftWindowTsx(leftWindow, layoutState!, windowState!)
: null
const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__
? createRightWindowTsx(rightWindow, layoutState, windowState)
? createRightWindowTsx(rightWindow, layoutState!, windowState!)
: null
return (
<uni-layout>
......
......@@ -137,41 +137,47 @@ export const hideRightWindow = <typeof uni.hideRightWindow>(
export const getTopWindowStyle = <typeof uni.getTopWindowStyle>(
defineSyncApi('getTopWindowStyle', () => {
const state = getLayoutState()
return Object.assign({}, state.topWindowStyle)
return Object.assign({}, state && state.topWindowStyle)
})
)
export const setTopWindowStyle = <typeof uni.setTopWindowStyle>(
defineSyncApi('setTopWindowStyle', (style) => {
const state = getLayoutState()
state.topWindowStyle = style
if (state) {
state.topWindowStyle = style
}
})
)
export const getLeftWindowStyle = <typeof uni.getLeftWindowStyle>(
defineSyncApi('getLeftWindowStyle', () => {
const state = getLayoutState()
return Object.assign({}, state.leftWindowStyle)
return Object.assign({}, state && state.leftWindowStyle)
})
)
export const setLeftWindowStyle = <typeof uni.setLeftWindowStyle>(
defineSyncApi('setLeftWindowStyle', (style) => {
const state = getLayoutState()
state.leftWindowStyle = style
if (state) {
state.leftWindowStyle = style
}
})
)
export const getRightWindowStyle = <typeof uni.getRightWindowStyle>(
defineSyncApi('getRightWindowStyle', () => {
const state = getLayoutState()
return Object.assign({}, state.rightWindowStyle)
return Object.assign({}, state && state.rightWindowStyle)
})
)
export const setRightWindowStyle = <typeof uni.setRightWindowStyle>(
defineSyncApi('setRightWindowStyle', (style) => {
const state = getLayoutState()
state.rightWindowStyle = style
if (state) {
state.rightWindowStyle = style
}
})
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册