本文整理匯總了TypeScript中@bhmb/ui.UIExtensionExports類的典型用法代碼示例。如果您正苦於以下問題:TypeScript UIExtensionExports類的具體用法?TypeScript UIExtensionExports怎麽用?TypeScript UIExtensionExports使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了UIExtensionExports類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createUI
async function createUI(list: keyof WorldLists, tab: HTMLDivElement, ui: UIExtensionExports) {
// Show worlds
const { worlds, settings } = await showWorlds(tab, ui)
// Get the lists and modify as required
ui.notify('Getting lists')
const lists = await Promise.all(worlds.map(getWorldLists))
let superList = flatten(pluck(lists, list))
if (settings.alphabetical) superList.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
if (settings.removeDuplicates) superList = unique(superList)
// Let the user edit the list
superList = await displayList(tab, superList)
// Choose which worlds to push the new list to
const { worlds: pushWorlds, settings: pushSettings } = await choosePushWorlds(tab, ui)
ui.notify('Pushing lists...')
const requests = pushWorlds.map(async world => {
const api = new MessageBot.dependencies.Api(world)
const lists = await getWorldLists(world)
pushSettings.mode == 'overwrite' ? lists[list] = superList : lists[list].push(...superList)
await api.setLists(lists)
})
await Promise.all(requests)
setTimeout(createUI, 1, list, tab, ui)
}
示例2: resolve
button.addEventListener('click', () => {
const ids = Array.from(worldsDiv.querySelectorAll('input'))
.filter(input => input.checked)
.map(input => input.value)
if (ids.length < 1) {
ui.notify('Please select at least one world')
return
}
const settings: PushSettings = {
mode: (tab.querySelector('[name=mode]:checked') as HTMLInputElement).value as 'overwrite' | 'append',
}
resolve({ worlds: worlds.filter(({ id }) => ids.includes(id)), settings })
})
示例3:
worlds.forEach(world => {
ui.buildTemplate(template, worldsDiv, [
{ selector: '[data-for=worldId]', value: world.id },
{ selector: '[data-for=worldName]', text: world.name }
])
})