types.ts 3.0 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
export interface ComponentJson {
  component: true
  usingComponents?: UsingComponents
}

interface ShareWindowOptions {
  navigationBarBackgroundColor?: string // #000000
  navigationBarTextStyle?: 'white' | 'black' // white
  navigationBarTitleText?: string
  navigationStyle?: 'default' | 'custom' // default
  backgroundColor?: string // #ffffff
  backgroundTextStyle?: 'dark' | 'light' // dark
  backgroundColorTop?: string // #ffffff
  backgroundColorBottom?: string // #ffffff
  enablePullDownRefresh?: boolean // false
  onReachBottomDistance?: number // 50
  pageOrientation?: 'portrait' | 'landscape' | 'auto' // portrait
}

type Style = 'v2' | string
type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string

export interface PageWindowOptions extends ShareWindowOptions {
fxy060608's avatar
fxy060608 已提交
24
  component?: true // 百度小程序页面必须配置component: true
fxy060608's avatar
fxy060608 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  disableScroll?: boolean // false
  usingComponents?: UsingComponents
  initialRenderingCache?: 'static' | string
  style?: Style
  singlePage?: SinglePage
  restartStrategy?: RestartStrategy
}

export interface AppWindowOptions extends ShareWindowOptions {
  visualEffectInBackground?: 'none' | 'hidden' // none
}

interface SubPackage {
  name?: string
  root: string
  pages: string[]
  independent?: boolean
}

interface TabBarItem {
  pagePath: string
  text: string
  iconPath?: string
  selectedIconPath?: string
}

export interface TabBar {
  color: string
  selectedColor: string
  backgroundColor: string
  borderStyle?: 'black' | 'white' // black
  list: TabBarItem[]
  position?: 'bottom' | 'top' // bottom
  custom?: boolean
}

export interface NetworkTimeout {
  request?: number // 60000
  requeconnectSocketst?: number // 60000
  uploadFile?: number // 60000
  downloadFile?: number // 60000
}

interface Plugins {
  [name: string]: {
    version: string
    provider: string
  }
}

interface PreloadRule {
  [name: string]: {
    network: 'wifi' | 'all' // wifi
    packages: string[]
  }
}
export interface UsingComponents {
  [name: string]: string
}
interface Permission {
  [name: string]: {
    desc: string
  }
}
interface UseExtendedLib {
  kbone: boolean
  weui: boolean
}
interface EntranceDeclare {
  locationMessage: {
    path: string
    query: string
  }
}
interface SinglePage {
  navigationBarFit?: 'squeezed' | 'float'
}

export interface AppJson {
  entryPagePath?: string // mp-weixin
  pages: string[]
  window?: AppWindowOptions
  tabBar?: TabBar
  networkTimeout?: NetworkTimeout
  debug?: boolean
  functionalPages?: boolean
  subPackages?: SubPackage[]
  workers?: string
  requiredBackgroundModes?: string[] // audio,location
  plugins?: Plugins
  preloadRule?: PreloadRule
  resizable?: boolean
  usingComponents?: UsingComponents
  permission?: Permission
  sitemapLocation?: string
  style?: Style
  useExtendedLib?: UseExtendedLib
  entranceDeclare?: EntranceDeclare
  darkmode?: boolean
  themeLocation?: string
  lazyCodeLoading?: 'requiredComponents' | string
  singlePage?: SinglePage
  restartStrategy?: RestartStrategy
128
  [name: string]: unknown
fxy060608's avatar
fxy060608 已提交
129
}