Skip to content
On this page

系统参数

为了使框架更加灵活,很多配置并没有使用硬编码,而是在系统入口文件中配置相应的参数去控制变量。具体配置信息分为9类:

  • 环境配置
  • 路由配置
  • 页面及sso相关
  • 缓存设置
  • http设置
  • 语言设置
  • ui设置
  • 字典设置
  • structure

app配置

src/core/config/init.config.ts中的appConf属性配置。

ts
{
    appConf: {
        // 路由配置
        router?: routerConf

        // 需要的页面配置
        pages?: PagesConf

        // 缓存设置
        cache?: CacheConf

        // http设置
        http?: HttpConf

        // 语言设置
        locales?: LocalesConf

        // ui设置
        ui?: {
            // 表单配置
            form?: FormConf

            // 表格设置
            table?: TableConf

            // 信息设置
            message?: MessageConf
        },

        // 字典相关设置
        dict?: ApiSelectType,

        // structure 相关配置
        structure?: {
            [key: string]: ApiSelectType
        }
    },
    ...
}

API

路由配置 routerConf

属性说明类型默认值版本
useHashRoute路由模式(是否启用hash模式)booleantrue
useAuthRoute是否使用权限路由(根据菜单生成路由,还是根据views文件夹生成路由)booleanfalse
strictRoute是否使用全量路径(如果设置成true,则children中的路径均需要写全部路径,不能继承父路由的路径)booleanfalse
virtualRoute自动生成的路由(RouteRecordRaw | PageRoute)[][]
systemRoute支持静态路由RouteRecordRaw[][]
transition路由动画zoom-fade
zoom-out
fade-slide
fade
fade-bottom
fade-scale
'fade'
openPageLoading路由跳转是否显示遮罩层booleantrue
openNProgress是否开启顶部进度条动画booleantrue
closeDialogOnRouteChange路由跳转后 弹框是否关闭booleantrue
removeHttpPendding路由跳转后 所有的http请求是否取消booleantrue

页面配置 PagesConf

属性说明类型默认值版本
ssoLoginsso登录地址stringnull
ssoLogoutsso登出地址stringnull
queryColumnApi请求table表头信息的地址stringnull

缓存配置 CacheConf

属性说明类型默认值版本
cacheMode浏览器共享缓存数据存储位置localStorage
sessionStorage
'localStorage'
cacheTime默认缓存时长number24小时
cipher生产环境对缓存数据加密,设置一个值和偏移量Object"{ key: '1234567890ABCDEF',
iv: '@EDCBA0987654321' }"
hasEncrypt开发环境是否进行加密booleanfalse

http配置 HttpConf

属性说明类型默认值版本
tokenPreKey传给后台的token的key值string'Authorization'
tokenPrefixtoken修正,部分token需要在前面加上Bear 才能正常通信string'Bearer '
baseUrl基础路径(在请求前加一个路径)stringnull
timeOut超时时长 0表示前端不存在超时number60 * 1000
unAuthCode需要跳转到登录页面的错误码(number | string)[][401]
okCode请求正确,后台返回的code码number | string200
errorshttp错误信息
(400、500等提示信息)
{[key: number]: string}{}
headers默认请求头配置{ 'Content-Type': HttpContentTypeEnum }null

语言设置 LocalesConf

属性说明类型默认值版本
defaultLocale默认使用哪种语言Language | 'navigator'Language.ZH
message根据语言获取国际化内容(lang: Language) => RecordableFunction

当前系统仅支持中英文。

UI-表单配置 FormConf

属性说明类型默认值版本
autoFetch自动查询 只支持在 'search' 模式booleantrue
layout表单布局horizontal | vertical | inline'horizontal'
labelWidth标签的宽度number | string120
enLabelWidth英文标签宽度number | string120
labelAlign标签对齐方式'left' | 'right''right'
compact是否使用紧凑布局booleantrue
colonlabel后面是否需要':'booleantrue
autoFetchOnEnter回车键搜索booleantrue
alwaysShowLines是否一直显示所有条目(不显示折叠按钮)booleanfalse
minShowColumn查询条件折叠时最少显示几列number2
allowClear是否显示清除按钮booleantrue
scrollToFirstError提交失败自动滚动到第一个错误字段booleanfalse
scrollToFirstError提交失败自动滚动到第一个错误字段booleanfalse
colspan查询列控制'{md?:number, xl?:number, xxl?:number}''{md: 24, xl: 8, xxl: 6}'

表格设置 TableConf

属性说明类型默认值版本
pageSizeOptions下拉框,可供选择的页码大小string[][]
defaultPageSize默认分页大小number20
defaultPageNo默认指向页码number1
memorySelected切换页面是否需要记住已选中的数据booleantrue
multipleSorter是否支持多列排序booleantrue
align文字对齐方式'center' | 'left' | 'right''left'
exportTable支持导出页面的模式: current-当前页, select-当前选中, all-后台导出('current' | 'select' | 'all')[]
showUserDefineColumns是否支持用户自定义列booleantrue

弹框设置 TableConf

属性说明类型默认值版本
colspan弹框列控制'{md?:number, xl?:number, xxl?:number}''{md: 24, xl: 8, xxl: 6}'
width弹框默认宽度string | number'800px'

消息设置 MessageConf

属性说明类型默认值版本
top消息距离顶部的位置string8px
duration提示信息默认显示时常, 单位秒number3
maxCount最大显示数, 超过限制时,最早的消息会被自动关闭number1

字典设置 ApiSelectType

属性说明类型默认值版本
api请求接口stringnull
label作为标签值显示的属性string | ((item: Recordable) => string)'dictValue'
enLabel英文标签值显示的属性string | ((item: Recordable) => string)'dictValue'
value穿个后台属性string'dictKey'
params请求参数{}null
requestKey字典请求key值stringcode
listName返回的列表放在哪个数据中string | string[]['data']
numberToStringvalue是否需要将数字转为stringboolean
setOptions手动设置options(list:Array<any>) => Array<any>