Skip to content

Functions

clientRun()

clientRun<R>(task, profile): R

在客户端中执行任务,可通过 resolveClientRunProfile 获取特定执行配置(仅限同步代码)

Type Parameters

Type ParameterDefault type
Rvoid

Parameters

ParameterTypeDescription
task() => R待执行任务
profileClientRunProfile执行配置,未设置默认获取当前环境配置

Returns

R

Example

ts
// 获取窗口大小
function getWindowSize() {
  const { window } = resolveClientRunProfile()
  return { width: window.innerWidth, height: window.innerHeight }
}

// 新开窗口
const win = window.open(...)

// 获取新窗口大小
clientRun(getWindowSize, { window: win.window })

resolveClientRunProfile()

resolveClientRunProfile(): object

获取当前执行配置(仅限同步代码)

Returns

object

document

document: Document

location

location: Location

navigator: Navigator

window

window: Window

Interfaces

ClientRunProfile

Properties

PropertyType
document?Document
location?Location
navigator?Navigator
window?Window