Skip to content

Common Types

定义了一些基础对象类型,目的是为了统一类型及属性名称

IdKeyType

Id KEY的类型,用于对象主键值的类型

  • Type
ts
export type IdKeyType = string | number
export type IdKeyType = string | number
  • Details

一般用于dino-spring后台定义的接口中的id类型

  • Example
ts
import { IdKeyType } from '@dino-dev/vue3-core'

interface Animal<K extends IdKeyType> {
  id: K;
  // other fields
}
import { IdKeyType } from '@dino-dev/vue3-core'

interface Animal<K extends IdKeyType> {
  id: K;
  // other fields
}

VoBase

Vo的基础类型,用于dino-spring后台返回的接口类型

  • Type
ts
export interface VoBase<K extends IdKeyType> {
  id: K
  createAt: number
  updateAt: number
  createBy: string
  status: number
}

/**
 * 添加VoBase扩展
 */
export type withVoBase<T, K extends IdKeyType> = T & VoBase<K>
export interface VoBase<K extends IdKeyType> {
  id: K
  createAt: number
  updateAt: number
  createBy: string
  status: number
}

/**
 * 添加VoBase扩展
 */
export type withVoBase<T, K extends IdKeyType> = T & VoBase<K>
  • Details
nametypeoptionaldefaultdescription
idKfalsen/a对象 ID
createAtnumberfalsen/a对象创建时间戳,unix时间戳,到毫秒
updateAtnumberfalsen/a对象更新时间戳,unix时间戳,到毫秒
createBystringfalsen/a对象创建者
statusnumberfalsen/a用户status
  • Example
ts
import { VoBase, withVoBase } from '@dino-dev/vue3-core'

interface Animal extends VoBase<number>  {
  name: string
  // other fields
}

// use withVoBase
interface A{
  name: string
}

type AVo = withVoBase<A, string>
import { VoBase, withVoBase } from '@dino-dev/vue3-core'

interface Animal extends VoBase<number>  {
  name: string
  // other fields
}

// use withVoBase
interface A{
  name: string
}

type AVo = withVoBase<A, string>

Orderable

用于可排序对象,带排序码

  • Type
ts
export interface Orderable {
  orderNum?: number
}

export type withOrderable<T> = T & Orderable
export interface Orderable {
  orderNum?: number
}

export type withOrderable<T> = T & Orderable
  • Details

可排序对象,带排序码

nametypeoptionaldefaultdescription
orderNumnumbertruen/a排序号
  • Example
ts
import { Orderable, VoBase, withOrderable } from '@dino-dev/vue3-core'

interface Animal extends VoBase<number>, Orderable{
  name: string
  // other fields
}

// use withOrderable
interface A{
  name: string
}

type AOrderable = withOrderable<A>
import { Orderable, VoBase, withOrderable } from '@dino-dev/vue3-core'

interface Animal extends VoBase<number>, Orderable{
  name: string
  // other fields
}

// use withOrderable
interface A{
  name: string
}

type AOrderable = withOrderable<A>

Tenant

用于多租户系统

  • Type
ts
export interface Tenant {
  [K: string]: any
  id: string
  name: string
  shortName: string
  iconUrl: string
}
export interface Tenant {
  [K: string]: any
  id: string
  name: string
  shortName: string
  iconUrl: string
}
  • Details

租户信息

nametypeoptionaldefaultdescription
[K: string]anytruen/a其他扩展属性
idstringfalsen/a租户ID
namestringfalsen/a租户名称
shortNamestringfalsen/a租户简称
iconUrlstringfalsen/a租户logo
  • Example
ts
import { Tenant } from '@dino-dev/vue3-core'

const tenant:Tenant = getTenant(...);
import { Tenant } from '@dino-dev/vue3-core'

const tenant:Tenant = getTenant(...);

Tenantable

  • Type
ts
export interface Tenantable {
  tenantId: string
}

export type withTenantable<T> = T & Tenantable
export interface Tenantable {
  tenantId: string
}

export type withTenantable<T> = T & Tenantable
  • Details

分租户,添加租户ID信息

nametypeoptionaldefaultdescription
tenantIdstringfalsen/a租户ID
  • Example
ts
import { Tenantable, withTenantable } from '@dino-dev/vue3-core'

interface Animal extends Tenantable{
  name: string
  // other fields
}

// use withTenantable
interface A{
  name: string
}

type ATenantable = withTenantable<A>
import { Tenantable, withTenantable } from '@dino-dev/vue3-core'

interface Animal extends Tenantable{
  name: string
  // other fields
}

// use withTenantable
interface A{
  name: string
}

type ATenantable = withTenantable<A>

User

用户信息,区分用户类型,建议为每个用户类型定义单独的interface

  • Type
ts
export interface User<K extends IdKeyType> {
  id: K
  userType: string
  displayName: string
  avatarUrl: string
  tenantId?: string
  status: number
}
export interface User<K extends IdKeyType> {
  id: K
  userType: string
  displayName: string
  avatarUrl: string
  tenantId?: string
  status: number
}
  • Details

用户信息

nametypeoptionaldefaultdescription
idKfalsen/a用户ID
userTypestringfalsen/a用户类型
displayNamestringfalsen/a用户名称
avatarUrlstringfalsen/a用户头像
tenantIdstringtruen/a用户所属租户
statusnumberfalsen/a用户status
  • Example
ts
import { User } from '@dino-dev/vue3-core'

// 定义ClientUser类型
export interface ClientUser extends User<number> {
  userType: 'client'
}

const user: ClientUser = {
  id: 1,
  userType: 'client',
  // 其他属性...
}
import { User } from '@dino-dev/vue3-core'

// 定义ClientUser类型
export interface ClientUser extends User<number> {
  userType: 'client'
}

const user: ClientUser = {
  id: 1,
  userType: 'client',
  // 其他属性...
}

GeoPoint

坐标点类型

  • Type
ts
export interface GeoPoint {
  lon: number
  lat: number
}
export interface GeoPoint {
  lon: number
  lat: number
}
  • Details

GeoPoint

nametypeoptionaldefaultdescription
lonnumberfalsen/a坐标点:经度
latnumberfalsen/a坐标点:纬度
  • Example
ts
import { GeoPoint } from '@dino-dev/vue3-core'

const beijingGp: GeoPoint = {
  lon: 116.405285,
  lat: 39.904989
}
import { GeoPoint } from '@dino-dev/vue3-core'

const beijingGp: GeoPoint = {
  lon: 116.405285,
  lat: 39.904989
}

Address

地址信息类型定义

  • Type
ts
export interface Address extends Partial<GeoPoint> {
  privince: string
  city: string
  area: string
  street: string
  detail: string
}
export interface Address extends Partial<GeoPoint> {
  privince: string
  city: string
  area: string
  street: string
  detail: string
}
  • Details

Address

nametypeoptionaldefaultdescription
privincestringfalsen/a省份
citystringfalsen/a城市
areastringfalsen/a区域/县
streetstringfalsen/a街道
detailstringfalsen/a详细地址
lonnumbertruen/a坐标点:经度
latnumbertruen/a坐标点:纬度
  • Example
ts
import { Address } from '@dino-dev/vue3-core'

const address: Address = {
  privince: "北京市",
  city: "北京市",
  area: "朝阳区",
  street: "来广营街道",
  detail: "16号院1栋101室",
  lon: 116.405285,
  lat: 39.904989
}
import { Address } from '@dino-dev/vue3-core'

const address: Address = {
  privince: "北京市",
  city: "北京市",
  area: "朝阳区",
  street: "来广营街道",
  detail: "16号院1栋101室",
  lon: 116.405285,
  lat: 39.904989
}

Contact

联系人类型定义

  • Type
ts
export interface Contact {
  name: string
  phone: string
}
export interface Contact {
  name: string
  phone: string
}
  • Details

Contact

nametypeoptionaldefaultdescription
namestringfalsen/a联系人姓名
phonestringfalsen/a联系人手机号
  • Example
ts
import { Contact } from '@dino-dev/vue3-core'

const contact: Contact = {
  name: "赵某某",
  phone: "18888888888"
}
import { Contact } from '@dino-dev/vue3-core'

const contact: Contact = {
  name: "赵某某",
  phone: "18888888888"
}

Place

地点信息类型定义

  • Type
ts
export interface Place extends Partial<GeoPoint> {
  name: string
}
export interface Place extends Partial<GeoPoint> {
  name: string
}
  • Details

Place

nametypeoptionaldefaultdescription
namestringfalsen/a地点名称
lonnumbertruen/a坐标点:经度
latnumbertruen/a坐标点:纬度
  • Example
ts
import { Place } from '@dino-dev/vue3-core'

const beijingPlace: Place = {
  name: '北京市',
  lon: 116.405285,
  lat: 39.904989
}
import { Place } from '@dino-dev/vue3-core'

const beijingPlace: Place = {
  name: '北京市',
  lon: 116.405285,
  lat: 39.904989
}

Range

  • Type
ts
// @param T 范围类型,如:number、string、Date等
export interface Range<T> {
  begin: T
  end: T
}
// @param T 范围类型,如:number、string、Date等
export interface Range<T> {
  begin: T
  end: T
}
  • Details

Range<T>

nametypeoptionaldefaultdescription
<T>anyfalsen/a范围类型,如:number、string、Date等
beginTtruen/a开始值,如:[begin, end];
若begin为null则代表:(-∞, end)
endTtruen/a结束值,如:[begin, end];
若end为null则代表:[begin, +∞)
  • Example
ts
import { Range } from '@dino-dev/vue3-core'

// 北京早上公交车道限行时间为早7点至9点,9:00后不限行
const limitTime: Range<number> = {
  begin: 7,
  end: 9
}
import { Range } from '@dino-dev/vue3-core'

// 北京早上公交车道限行时间为早7点至9点,9:00后不限行
const limitTime: Range<number> = {
  begin: 7,
  end: 9
}

TimePeriod

TimePeriod类型,到秒的unix时间戳

  • Type
ts
export type TimePeriod = Range<number>
export type TimePeriod = Range<number>
  • Details

TimePeriod

nametypeoptionaldefaultdescription
beginnumbertruen/a开始值,包含,如:[begin, end);
若begin为null则代表:(-∞, end)
endnumbertruen/a结束值,不包含,如:[begin, end);
若end为null则代表:[begin, +∞)
  • Example
ts
import { TimePeriod } from '@dino-dev/vue3-core'

const updateBetween: TimePeriod = {
  begin: 1673437025,
  end: 1703338350
}
import { TimePeriod } from '@dino-dev/vue3-core'

const updateBetween: TimePeriod = {
  begin: 1673437025,
  end: 1703338350
}

ValueLabel

ValueLabel类型定义

  • Type
ts
export interface ValueLabel<T extends IdKeyType> {
  value: T
  label: string
}
export interface ValueLabel<T extends IdKeyType> {
  value: T
  label: string
}
  • Details

ValueLabel<T>

nametypeoptionaldefaultdescription
valueTfalsen/a
labelstringfalsen/a名称
  • Example
ts
import { ValueLabel } from '@dino-dev/vue3-core'

const contractTypes: ValueLabel<string>[] = [
  {
    value: "hr-outsource",
    label: "人力外包"
  },
  {
    value: "hr-formal",
    label: "正式用工"
  },
]
import { ValueLabel } from '@dino-dev/vue3-core'

const contractTypes: ValueLabel<string>[] = [
  {
    value: "hr-outsource",
    label: "人力外包"
  },
  {
    value: "hr-formal",
    label: "正式用工"
  },
]

Option

Option类型定义,是对ValueLabel的扩展

  • Type
ts
export interface Option<T extends IdKeyType> {
  value: T
  label: string
  icon?: string
  style?: string
  desc?: string
}
export interface Option<T extends IdKeyType> {
  value: T
  label: string
  icon?: string
  style?: string
  desc?: string
}
  • Details

Option<T>

nametypeoptionaldefaultdescription
valueTfalsen/a选项值
labelstringfalsen/a选项名称
iconstringtruen/a选项图标
stylestringtruen/a选项样式
descstringtruen/a选项描述
  • Example
ts
import { Option } from '@dino-dev/vue3-core'

const contractOptions: Option<string>[] = [
  {
    value: "hr-outsource",
    label: "人力外包",
    icon: "outsource",
    desc: "从外包公司派遣的合同"
  },
  {
    value: "hr-formal",
    label: "正式用工",
    icon: "formal",
    desc: "正式员工及实习生合同"
  },
]
import { Option } from '@dino-dev/vue3-core'

const contractOptions: Option<string>[] = [
  {
    value: "hr-outsource",
    label: "人力外包",
    icon: "outsource",
    desc: "从外包公司派遣的合同"
  },
  {
    value: "hr-formal",
    label: "正式用工",
    icon: "formal",
    desc: "正式员工及实习生合同"
  },
]

OptionGroup

OptionGroup类型定义

  • Type
ts
export interface OptionGroup<T extends IdKeyType> {
  label: string
  options: Option<T>[]
  desc?: string
}
export interface OptionGroup<T extends IdKeyType> {
  label: string
  options: Option<T>[]
  desc?: string
}
  • Details

OptionGroup<T>

nametypeoptionaldefaultdescription
labelstringfalsen/a分组名称
optionsOption<T>[]falsen/a分组选项
descstringtruen/a分组描述
  • Example
ts
import { Option, OptionGroup } from '@dino-dev/vue3-core'

const hrContractOptions: Option<string>[] = [ ...]

const salesContractOptions: Option<string>[] = [ ...]

const contractOptionGroups: OptionGroup<string>[] = [
  {
    label: '人力合同',
    options: hrContractOptions
  },
  {
    label: '销售合同',
    options: salesContractOptions
  }
]
import { Option, OptionGroup } from '@dino-dev/vue3-core'

const hrContractOptions: Option<string>[] = [ ...]

const salesContractOptions: Option<string>[] = [ ...]

const contractOptionGroups: OptionGroup<string>[] = [
  {
    label: '人力合同',
    options: hrContractOptions
  },
  {
    label: '销售合同',
    options: salesContractOptions
  }
]

Released under the Apache-2.0 License.