PCalc
PCalc 是一款适用于 iPad、iPhone、Apple Vision Pro、Apple Watch 和 Mac 的计算器。Protocol Launcher 允许您生成官方 PCalc URL scheme 链接。
使用方式
有两种使用此库的方式:
- 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
- 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。
生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
因为 clearAll() 会清空当前 PCalc 状态,而 x-callback helpers 是回调目标,这些函数只展示代码示例。
打开 PCalc
ts
import { open } from 'protocol-launcher/pcalc'
const url = open()设置数值
ts
import { setValue } from 'protocol-launcher/pcalc'
const url = setValue({
value: 12345,
})换算数值
ts
import { convertValue } from 'protocol-launcher/pcalc'
const url = convertValue({
value: 12345,
})打开常数
ts
import { openConstants } from 'protocol-launcher/pcalc'
const url = openConstants()打开纸带
ts
import { openTape } from 'protocol-launcher/pcalc'
const url = openTape()打开寄存器
ts
import { openRegisters } from 'protocol-launcher/pcalc'
const url = openRegisters()打开栈
ts
import { openStack } from 'protocol-launcher/pcalc'
const url = openStack()打开设置
ts
import { openSettings } from 'protocol-launcher/pcalc'
const url = openSettings()清空全部
ts
import { clearAll } from 'protocol-launcher/pcalc'
const url = clearAll()打开布局
ts
import { openLayout } from 'protocol-launcher/pcalc'
const url = openLayout({
name: 'Engineering',
})打开计算器
ts
import { openCalculator } from 'protocol-launcher/pcalc'
const url = openCalculator({
name: 'name',
})X-Callback Set
ts
import { xCallbackSet } from 'protocol-launcher/pcalc'
const url = xCallbackSet()X-Callback Error
ts
import { xCallbackError } from 'protocol-launcher/pcalc'
const url = xCallbackError()生成的 URL
ts
open()
// => 'pcalc://'
setValue({ value: 12345 })
// => 'pcalc://set/12345'
convertValue({ value: 12345 })
// => 'pcalc://convert/12345'
openConstants()
// => 'pcalc://constants'
openTape()
// => 'pcalc://tape'
openRegisters()
// => 'pcalc://registers'
openStack()
// => 'pcalc://stack'
openSettings()
// => 'pcalc://settings'
clearAll()
// => 'pcalc://ac'
openLayout({ name: 'Engineering' })
// => 'pcalc://layout/Engineering'
openCalculator({ name: 'name' })
// => 'pcalc://calculator/name'
xCallbackSet()
// => 'pcalc://x-callback-url/set'
xCallbackError()
// => 'pcalc://x-callback-url/error'