For the complete documentation index, see llms.txt. This page is also available as Markdown.

屏幕属性


1. 设置屏幕方向 (setDeviceOrientation)

将设备屏幕方向设置为横屏或竖屏。如果只需要在特定页面更改方向,请在离开页面时务必恢复为原来的方向。

签名

function setDeviceOrientation(options: { type: 'portrait' | 'landscape' }): Promise<void>;

参数

  • options.type · 必填 · 'portrait' | 'landscape'

    指定屏幕方向。 portrait是竖屏模式, landscape是横屏模式。

示例

import { setDeviceOrientation } from '@apps-in-toss/web-framework';

setDeviceOrientation({ type: 'landscape' });
import { setDeviceOrientation } from '@apps-in-toss/web-framework';
import { useEffect } from 'react';

function VideoScreen() {
  useEffect(() => {
    setDeviceOrientation({ type: 'landscape' });

    return () => {
      setDeviceOrientation({ type: 'portrait' }); // 离开页面时恢复。
    };
  }, []);
}
import { setDeviceOrientation } from '@apps-in-toss/framework';
import { useEffect } from 'react';

function VideoScreen() {
  useEffect(() => {
    setDeviceOrientation({ type: 'landscape' });

    return () => {
      setDeviceOrientation({ type: 'portrait' }); // 离开页面时恢复。
    };
  }, []);
}

2. 设置屏幕常亮 (setScreenAwakeMode)

设置为屏幕不会自动关闭。在漫画、视频、阅读文档等需要持续保持屏幕开启的场景中很有用。如果只在特定页面使用,请在离开页面时务必停用。

签名

function setScreenAwakeMode(options: { enabled: boolean }): Promise<{ enabled: boolean }>;

参数

  • options.enabled · 必填 · boolean

    true设为后,屏幕不会关闭, false设为后,会根据默认屏幕保护时间关闭。

示例


3. 阻止屏幕截图 (setSecureScreen)

在原生层面阻止屏幕截图。可用于显示账户余额、交易记录等敏感信息的页面。

签名

参数

  • options.enabled · 必填 · boolean

    true则会阻止屏幕截图, false则允许。

示例

最后更新于

这有帮助吗?