Skip to content

配置项

ts
createFlux(options: IFluxAppOption)
createFlux(options: IFluxAppOption)

appId

  • 类型:string
  • 默认值:undefined

应用 ID,必填。

appName

  • 类型:string
  • 默认值:Gauss

应用名称,必填。

clientId

  • 类型:string
  • 默认值:undefined

客户端 ID。

BASE_URL

  • 类型:string
  • 默认值:undefined

项目根目录,必填。

构建工具使用 webpack 时值应为 process.env.BASE_URL,构建工具使用 vite 时通过 (await import.meta.env).BASE_URL 获取。

routes

  • 类型:RouteRecordRaw[]
  • 默认值:[]
js
createPrime({
    routes: [
        {
            path: '/home',
            name: 'home',
            component: () => import('./home.vue'),
        },
        ...
    ],
})
createPrime({
    routes: [
        {
            path: '/home',
            name: 'home',
            component: () => import('./home.vue'),
        },
        ...
    ],
})

path

  • 类型:string
  • 默认值:undefined

路径名称

name

  • 类型:string
  • 默认值:undefined

别名

component

  • 类型:Component
  • 默认值:undefined

组件

meta

  • 类型:IMeta
  • 默认值:undefined
ts
interface IMeta {
    // 配置 document.title
    title?: string
}
interface IMeta {
    // 配置 document.title
    title?: string
}

home

  • 类型:string
  • 默认值:undefined

首页地址。必填。

gondar

埋点配置。

gondar.enabled

  • 类型:boolean
  • 默认值:false

是否开启。

gondar.collectUrl

  • 类型:string
  • 默认值://cloud-api.tineco.com/sensorsdata/${appId}

采集地址,默认值内的 appId 为应用 ID。

gondar.debugger

  • 类型:boolean
  • 默认值:false

是否开启 debugger。

gondar.platform

  • 类型:string
  • 默认值:web

平台,可选值 web h5

redirectPath

  • 类型:string
  • 默认值:undefined

路由重定向地址,根路径下默认跳转到 /login 登录页面。

isRememberLogin

  • 类型:boolean
  • 默认值:false

是否记住用户登录状态,开启后,用户首次登录后再次进入会直接进入首页。

onAfterLogin

  • 类型:({ router }: { router: Router }): void
  • 默认值:undefined

登录成功后的回调,在此阶段可做些额外操作,比如:跳转到首页。

js
createFlux({
    onAfterLogin({ router }) {
        router.push('/home')
    },
})
createFlux({
    onAfterLogin({ router }) {
        router.push('/home')
    },
})

openAuth

  • 类型:boolean
  • 默认值:true

是否开启路由鉴权。

onFrameLoad

  • 类型:({ router }: { router: Router }): void
  • 默认值:undefined

框架加载完成后的回调函数,返回一个 router 参数,在此阶段可做些额外操作,比如:自定义路由拦截。

js
createFlux({
    onFrameLoad({ router }) {
        router.afterEach(to => {
            // TODO
        })
        // TODO
    },
})
createFlux({
    onFrameLoad({ router }) {
        router.afterEach(to => {
            // TODO
        })
        // TODO
    },
})