nvue.ts 1.1 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2
export function initNVue(
  manifestJson: Record<string, any>,
fxy060608's avatar
fxy060608 已提交
3
  pagesJson: UniApp.PagesJson
fxy060608's avatar
fxy060608 已提交
4 5 6 7
) {}

export function getNVueCompiler(manifestJson: Record<string, any>) {
  const platformOptions = manifestJson['app-plus']
fxy060608's avatar
fxy060608 已提交
8 9 10 11 12 13 14 15
  if (platformOptions) {
    const { nvueCompiler } = platformOptions
    if (nvueCompiler === 'weex') {
      return 'weex'
    }
    if (nvueCompiler === 'vue') {
      return 'vue'
    }
fxy060608's avatar
fxy060608 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  }
  return 'uni-app'
}

export function getNVueStyleCompiler(manifestJson: Record<string, any>) {
  const platformOptions = manifestJson['app-plus']
  if (platformOptions && platformOptions.nvueStyleCompiler === 'uni-app') {
    return 'uni-app'
  }
  return 'weex'
}

const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'] as const

type FlexDir = typeof flexDirs[number]

export function getNVueFlexDirection(manifestJson: Record<string, any>) {
  let flexDir: FlexDir = 'column'
  if (manifestJson['app-plus']?.nvue?.['flex-direction']) {
    flexDir = manifestJson['app-plus'].nvue['flex-direction'] as FlexDir
    if (flexDirs.indexOf(flexDir) === -1) {
      flexDir = 'column'
    }
  }
  return flexDir
}