當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ui.UIExtensionExports類代碼示例

本文整理匯總了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)
}
開發者ID:Bibliofile,項目名稱:BHMB-List-Manager,代碼行數:27,代碼來源:index.ts

示例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 })
    })
開發者ID:Bibliofile,項目名稱:BHMB-List-Manager,代碼行數:16,代碼來源:index.ts

示例3:

 worlds.forEach(world => {
   ui.buildTemplate(template, worldsDiv, [
     { selector: '[data-for=worldId]', value: world.id },
     { selector: '[data-for=worldName]', text: world.name }
   ])
 })
開發者ID:Bibliofile,項目名稱:BHMB-List-Manager,代碼行數:6,代碼來源:index.ts


注:本文中的@bhmb/ui.UIExtensionExports類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。