atomm Object

atomm is a global object injected into the page once the platform SDK (platform-sdk.js) loads. It exposes platform capabilities and UI utilities, and can be used directly in your generator code.

Lifecycle lifecycle

Register platform lifecycle hooks via lifecycle.on:

atomm.lifecycle.on('export', async () => { ... })

UI Tools ui

Shows a platform-wide toast notification. Takes an object as its argument:

  • type: optional, one of success / warning / error / info, defaults to success
  • message: the notification text
  • duration: optional, how long the toast stays visible, in seconds; 0 means it won't auto-close; defaults to 3 seconds if omitted

toast() returns the id of that toast; call closeToast(id) to close it manually. A persistent toast with duration: 0 must be closed this way, or it will stay on screen indefinitely.

atomm.ui.toast({ type: 'success', message: '已完成' })

// Show for 5 seconds
atomm.ui.toast({ type: 'info', message: '正在处理…', duration: 5 })

// duration: 0 keeps it on screen; close it with closeToast once the task finishes
const id = await atomm.ui.toast({ type: 'info', message: '导出中…', duration: 0 })
// …task finishes…
await atomm.ui.closeToast(id)
toast requires an object

Passing a string (e.g. toast('已完成')) won't work — the platform only reads message and type off an object, so a string is treated as an empty message. The ui namespace currently provides toast (which returns the toast's id) and closeToast.

App Info app

// Current locale code (zh / en / ja… 17 in total)
const locale = await atomm.app.getLocale()

// All supported locales (code + display name), for building a language selector consistent with the platform
const locales = await atomm.app.getSupportedLocales()
// → [{ code: 'zh', name: '简体中文' }, { code: 'en', name: 'English' }, …]

User user

// Whether the user is currently logged in (returns only a boolean, no token or profile data)
const loggedIn = await atomm.user.isLoggedIn()

// If not logged in, opens the login dialog and waits for the user to finish; returns whether they ended up logged in
if (!loggedIn) {
  const ok = await atomm.user.login()
  if (!ok) return // User canceled or login failed
}
// Reaching here means the user is logged in — continue with your logic
Call login from within a user gesture

login() opens a login window, so call it from within a user gesture handler (e.g. a click callback) to avoid having it blocked by the browser's popup blocker. Logging in is a long-running interaction, so the platform already extends its timeout for it (about 5 minutes) — you don't need to add your own.

Safe Invocation

If you're not sure whether your code is running inside the platform, use optional chaining to avoid errors:

window.atomm?.ui?.toast?.({ type: 'info', message: 'hi' })
Esc
Search all docs · to navigate · to open