提交 f992e2ff 编写于 作者: Q qiang

fix(h5): useMaxWidth

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