feat(doctor): 新增医生端功能模块
- 添加医生注册申请页面及表单逻辑- 实现医生银行卡信息管理功能 - 开发患者报备与签约管理界面 - 集成微信手机号获取与头像上传功能 - 添加表单验证与数据提交逻辑 - 实现页面配置文件与路由集成- 添加日期选择器与数据格式化工具 - 集成API接口调用与错误处理机制
This commit is contained in:
365
types/business.d.ts
vendored
Normal file
365
types/business.d.ts
vendored
Normal file
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
* 业务相关类型定义
|
||||
*/
|
||||
|
||||
// 用户相关类型
|
||||
declare namespace User {
|
||||
/** 用户状态 */
|
||||
type Status = 'active' | 'inactive' | 'banned';
|
||||
|
||||
/** 用户性别 */
|
||||
type Gender = 'male' | 'female' | 'unknown';
|
||||
|
||||
/** 用户角色 */
|
||||
interface Role extends BaseEntity {
|
||||
roleCode: string;
|
||||
roleName: string;
|
||||
description?: string;
|
||||
permissions?: Permission[];
|
||||
}
|
||||
|
||||
/** 用户权限 */
|
||||
interface Permission extends BaseEntity {
|
||||
authority: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/** 用户基础信息 */
|
||||
interface BaseInfo extends BaseEntity {
|
||||
userId: ID;
|
||||
username: string;
|
||||
nickname?: string;
|
||||
realName?: string;
|
||||
avatar?: string;
|
||||
avatarUrl?: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
gender?: Gender;
|
||||
sexName?: string;
|
||||
birthday?: string;
|
||||
status: Status;
|
||||
tenantId?: ID;
|
||||
companyId?: ID;
|
||||
}
|
||||
|
||||
/** 完整用户信息 */
|
||||
interface Info extends BaseInfo {
|
||||
roles?: Role[];
|
||||
authorities?: Permission[];
|
||||
balance?: number;
|
||||
points?: number;
|
||||
openid?: string;
|
||||
certification?: boolean;
|
||||
isAdmin?: boolean;
|
||||
lastLoginTime?: string;
|
||||
}
|
||||
|
||||
/** 用户登录参数 */
|
||||
interface LoginParams {
|
||||
username?: string;
|
||||
password?: string;
|
||||
phone?: string;
|
||||
code?: string;
|
||||
captcha?: string;
|
||||
tenantId?: ID;
|
||||
}
|
||||
|
||||
/** 用户注册参数 */
|
||||
interface RegisterParams {
|
||||
username: string;
|
||||
password: string;
|
||||
phone: string;
|
||||
code: string;
|
||||
nickname?: string;
|
||||
tenantId?: ID;
|
||||
}
|
||||
}
|
||||
|
||||
// 商品相关类型
|
||||
declare namespace Product {
|
||||
/** 商品状态 */
|
||||
type Status = 'draft' | 'published' | 'offline' | 'deleted';
|
||||
|
||||
/** 商品规格 */
|
||||
interface Spec {
|
||||
specName: string;
|
||||
specValues: string[];
|
||||
}
|
||||
|
||||
/** 商品SKU */
|
||||
interface SKU extends BaseEntity {
|
||||
skuId: ID;
|
||||
goodsId: ID;
|
||||
sku: string;
|
||||
price: number;
|
||||
originalPrice?: number;
|
||||
stock: number;
|
||||
weight?: number;
|
||||
volume?: number;
|
||||
image?: string;
|
||||
barcode?: string;
|
||||
}
|
||||
|
||||
/** 商品分类 */
|
||||
interface Category extends BaseEntity, BaseTreeNode<Category> {
|
||||
categoryName: string;
|
||||
categoryCode?: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
sort?: number;
|
||||
status: Status;
|
||||
}
|
||||
|
||||
/** 商品基础信息 */
|
||||
interface BaseInfo extends BaseEntity {
|
||||
goodsId: ID;
|
||||
goodsName: string;
|
||||
goodsCode?: string;
|
||||
categoryId: ID;
|
||||
categoryName?: string;
|
||||
brand?: string;
|
||||
description?: string;
|
||||
content?: string;
|
||||
images?: string[];
|
||||
mainImage?: string;
|
||||
status: Status;
|
||||
sort?: number;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
/** 完整商品信息 */
|
||||
interface Info extends BaseInfo {
|
||||
category?: Category;
|
||||
specs?: Spec[];
|
||||
skus?: SKU[];
|
||||
minPrice?: number;
|
||||
maxPrice?: number;
|
||||
totalStock?: number;
|
||||
salesCount?: number;
|
||||
viewCount?: number;
|
||||
favoriteCount?: number;
|
||||
}
|
||||
|
||||
/** 商品查询参数 */
|
||||
interface QueryParams extends BasePaginationParams {
|
||||
categoryId?: ID;
|
||||
categoryIds?: ID[];
|
||||
keywords?: string;
|
||||
status?: Status;
|
||||
minPrice?: number;
|
||||
maxPrice?: number;
|
||||
brand?: string;
|
||||
tags?: string[];
|
||||
sortBy?: 'price' | 'sales' | 'createTime' | 'updateTime';
|
||||
}
|
||||
}
|
||||
|
||||
// 订单相关类型
|
||||
declare namespace Order {
|
||||
/** 订单状态 */
|
||||
type Status = 'pending' | 'paid' | 'shipped' | 'delivered' | 'completed' | 'cancelled' | 'refunded';
|
||||
|
||||
/** 支付状态 */
|
||||
type PayStatus = 0 | 1 | 2; // 0-未支付 1-已支付 2-已退款
|
||||
|
||||
/** 配送状态 */
|
||||
type DeliveryStatus = 10 | 20 | 30; // 10-待发货 20-已发货 30-已收货
|
||||
|
||||
/** 支付方式 */
|
||||
type PaymentType = 0 | 1 | 2 | 3; // 0-余额 1-微信 2-支付宝 3-其他
|
||||
|
||||
/** 订单商品 */
|
||||
interface Goods extends BaseEntity {
|
||||
orderGoodsId: ID;
|
||||
orderId: ID;
|
||||
goodsId: ID;
|
||||
goodsName: string;
|
||||
goodsImage?: string;
|
||||
skuId?: ID;
|
||||
sku?: string;
|
||||
price: number;
|
||||
quantity: number;
|
||||
totalPrice: number;
|
||||
refundQuantity?: number;
|
||||
refundAmount?: number;
|
||||
}
|
||||
|
||||
/** 收货地址 */
|
||||
interface Address {
|
||||
name: string;
|
||||
phone: string;
|
||||
province: string;
|
||||
city: string;
|
||||
district: string;
|
||||
detail: string;
|
||||
postalCode?: string;
|
||||
}
|
||||
|
||||
/** 订单基础信息 */
|
||||
interface BaseInfo extends BaseEntity {
|
||||
orderId: ID;
|
||||
orderNo: string;
|
||||
userId: ID;
|
||||
status: Status;
|
||||
payStatus: PayStatus;
|
||||
deliveryStatus?: DeliveryStatus;
|
||||
paymentType?: PaymentType;
|
||||
totalAmount: number;
|
||||
payAmount: number;
|
||||
discountAmount?: number;
|
||||
shippingFee?: number;
|
||||
remark?: string;
|
||||
payTime?: string;
|
||||
shipTime?: string;
|
||||
deliveryTime?: string;
|
||||
completeTime?: string;
|
||||
cancelTime?: string;
|
||||
}
|
||||
|
||||
/** 完整订单信息 */
|
||||
interface Info extends BaseInfo {
|
||||
goods?: Goods[];
|
||||
address?: Address;
|
||||
user?: User.BaseInfo;
|
||||
goodsCount?: number;
|
||||
trackingNumber?: string;
|
||||
expressCompany?: string;
|
||||
}
|
||||
|
||||
/** 订单创建参数 */
|
||||
interface CreateParams {
|
||||
goods: Array<{
|
||||
goodsId: ID;
|
||||
skuId?: ID;
|
||||
quantity: number;
|
||||
price?: number;
|
||||
}>;
|
||||
address: Address;
|
||||
paymentType: PaymentType;
|
||||
remark?: string;
|
||||
couponId?: ID;
|
||||
usePoints?: number;
|
||||
}
|
||||
|
||||
/** 订单查询参数 */
|
||||
interface QueryParams extends BasePaginationParams {
|
||||
userId?: ID;
|
||||
status?: Status;
|
||||
payStatus?: PayStatus;
|
||||
deliveryStatus?: DeliveryStatus;
|
||||
orderNo?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// 购物车相关类型
|
||||
declare namespace Cart {
|
||||
/** 购物车商品 */
|
||||
interface Item {
|
||||
cartId: ID;
|
||||
goodsId: ID;
|
||||
goodsName: string;
|
||||
goodsImage?: string;
|
||||
skuId?: ID;
|
||||
sku?: string;
|
||||
price: number;
|
||||
originalPrice?: number;
|
||||
quantity: number;
|
||||
stock: number;
|
||||
selected: boolean;
|
||||
invalid?: boolean;
|
||||
addTime: string;
|
||||
}
|
||||
|
||||
/** 购物车统计 */
|
||||
interface Summary {
|
||||
totalCount: number;
|
||||
selectedCount: number;
|
||||
totalAmount: number;
|
||||
selectedAmount: number;
|
||||
discountAmount?: number;
|
||||
finalAmount: number;
|
||||
}
|
||||
}
|
||||
|
||||
// 内容管理相关类型
|
||||
declare namespace CMS {
|
||||
/** 文章状态 */
|
||||
type ArticleStatus = 'draft' | 'published' | 'archived';
|
||||
|
||||
/** 文章分类 */
|
||||
interface Category extends BaseEntity, BaseTreeNode<Category> {
|
||||
categoryName: string;
|
||||
categoryCode?: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
sort?: number;
|
||||
}
|
||||
|
||||
/** 文章信息 */
|
||||
interface Article extends BaseEntity {
|
||||
articleId: ID;
|
||||
title: string;
|
||||
summary?: string;
|
||||
content: string;
|
||||
coverImage?: string;
|
||||
categoryId?: ID;
|
||||
categoryName?: string;
|
||||
author?: string;
|
||||
status: ArticleStatus;
|
||||
publishTime?: string;
|
||||
viewCount?: number;
|
||||
likeCount?: number;
|
||||
tags?: string[];
|
||||
seoTitle?: string;
|
||||
seoKeywords?: string;
|
||||
seoDescription?: string;
|
||||
}
|
||||
|
||||
/** 文章查询参数 */
|
||||
interface ArticleQueryParams extends BasePaginationParams {
|
||||
categoryId?: ID;
|
||||
status?: ArticleStatus;
|
||||
keywords?: string;
|
||||
author?: string;
|
||||
tags?: string[];
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// 系统相关类型
|
||||
declare namespace System {
|
||||
/** 字典类型 */
|
||||
interface Dict extends BaseEntity {
|
||||
dictCode: string;
|
||||
dictName: string;
|
||||
dictValue: string;
|
||||
description?: string;
|
||||
sort?: number;
|
||||
status?: 'active' | 'inactive';
|
||||
}
|
||||
|
||||
/** 配置项 */
|
||||
interface Config extends BaseEntity {
|
||||
configKey: string;
|
||||
configValue: string;
|
||||
configName?: string;
|
||||
description?: string;
|
||||
type?: 'string' | 'number' | 'boolean' | 'json';
|
||||
}
|
||||
|
||||
/** 菜单项 */
|
||||
interface Menu extends BaseEntity, BaseTreeNode<Menu> {
|
||||
menuName: string;
|
||||
menuCode?: string;
|
||||
path?: string;
|
||||
icon?: string;
|
||||
component?: string;
|
||||
permission?: string;
|
||||
sort?: number;
|
||||
visible?: boolean;
|
||||
type?: 'menu' | 'button';
|
||||
}
|
||||
}
|
||||
301
types/components.d.ts
vendored
Normal file
301
types/components.d.ts
vendored
Normal file
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
* 组件相关类型定义
|
||||
*/
|
||||
|
||||
import { ReactNode, CSSProperties } from 'react';
|
||||
|
||||
// 基础组件Props类型
|
||||
declare namespace ComponentProps {
|
||||
/** 基础Props */
|
||||
interface Base {
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
/** 可点击组件Props */
|
||||
interface Clickable extends Base {
|
||||
onClick?: (event?: any) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/** 表单组件基础Props */
|
||||
interface FormItem extends Base {
|
||||
label?: string;
|
||||
required?: boolean;
|
||||
error?: string;
|
||||
help?: string;
|
||||
}
|
||||
|
||||
/** 输入组件Props */
|
||||
interface Input extends FormItem {
|
||||
value?: string;
|
||||
defaultValue?: string;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
readonly?: boolean;
|
||||
maxLength?: number;
|
||||
onChange?: (value: string, event?: any) => void;
|
||||
onFocus?: (event?: any) => void;
|
||||
onBlur?: (event?: any) => void;
|
||||
}
|
||||
|
||||
/** 选择器组件Props */
|
||||
interface Selector<T = any> extends FormItem {
|
||||
value?: T;
|
||||
defaultValue?: T;
|
||||
options: Option<T>[];
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
multiple?: boolean;
|
||||
onChange?: (value: T, option?: Option<T>) => void;
|
||||
}
|
||||
|
||||
/** 分页组件Props */
|
||||
interface Pagination extends Base {
|
||||
current: number;
|
||||
total: number;
|
||||
pageSize?: number;
|
||||
showSizeChanger?: boolean;
|
||||
showQuickJumper?: boolean;
|
||||
showTotal?: boolean;
|
||||
onChange?: (page: number, pageSize?: number) => void;
|
||||
}
|
||||
|
||||
/** 表格列定义 */
|
||||
interface TableColumn<T = any> {
|
||||
key: string;
|
||||
title: string;
|
||||
dataIndex?: string;
|
||||
width?: number | string;
|
||||
align?: 'left' | 'center' | 'right';
|
||||
fixed?: 'left' | 'right';
|
||||
sortable?: boolean;
|
||||
filterable?: boolean;
|
||||
render?: (value: any, record: T, index: number) => ReactNode;
|
||||
}
|
||||
|
||||
/** 表格组件Props */
|
||||
interface Table<T = any> extends Base {
|
||||
columns: TableColumn<T>[];
|
||||
dataSource: T[];
|
||||
rowKey?: string | ((record: T) => string);
|
||||
loading?: boolean;
|
||||
pagination?: false | Pagination;
|
||||
scroll?: { x?: number; y?: number };
|
||||
onRow?: (record: T, index: number) => any;
|
||||
onChange?: (pagination: any, filters: any, sorter: any) => void;
|
||||
}
|
||||
|
||||
/** 模态框组件Props */
|
||||
interface Modal extends Base {
|
||||
visible: boolean;
|
||||
title?: string;
|
||||
width?: number | string;
|
||||
closable?: boolean;
|
||||
maskClosable?: boolean;
|
||||
keyboard?: boolean;
|
||||
centered?: boolean;
|
||||
destroyOnClose?: boolean;
|
||||
footer?: ReactNode | null;
|
||||
onOk?: () => void | Promise<void>;
|
||||
onCancel?: () => void;
|
||||
afterClose?: () => void;
|
||||
}
|
||||
|
||||
/** 抽屉组件Props */
|
||||
interface Drawer extends Base {
|
||||
visible: boolean;
|
||||
title?: string;
|
||||
width?: number | string;
|
||||
placement?: 'left' | 'right' | 'top' | 'bottom';
|
||||
closable?: boolean;
|
||||
maskClosable?: boolean;
|
||||
keyboard?: boolean;
|
||||
destroyOnClose?: boolean;
|
||||
onClose?: () => void;
|
||||
afterVisibleChange?: (visible: boolean) => void;
|
||||
}
|
||||
|
||||
/** 上传组件Props */
|
||||
interface Upload extends Base {
|
||||
action?: string;
|
||||
accept?: string;
|
||||
multiple?: boolean;
|
||||
maxCount?: number;
|
||||
maxSize?: number;
|
||||
fileList?: UploadFile[];
|
||||
beforeUpload?: (file: File) => boolean | Promise<boolean>;
|
||||
onChange?: (fileList: UploadFile[]) => void;
|
||||
onPreview?: (file: UploadFile) => void;
|
||||
onRemove?: (file: UploadFile) => boolean | Promise<boolean>;
|
||||
}
|
||||
|
||||
/** 图片预览组件Props */
|
||||
interface ImagePreview extends Base {
|
||||
visible: boolean;
|
||||
images: string[];
|
||||
current?: number;
|
||||
onClose?: () => void;
|
||||
onChange?: (current: number) => void;
|
||||
}
|
||||
|
||||
/** 搜索组件Props */
|
||||
interface Search extends Base {
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
loading?: boolean;
|
||||
onSearch?: (value: string) => void;
|
||||
onChange?: (value: string) => void;
|
||||
onClear?: () => void;
|
||||
}
|
||||
|
||||
/** 筛选器组件Props */
|
||||
interface Filter extends Base {
|
||||
filters: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
type: 'input' | 'select' | 'date' | 'dateRange';
|
||||
options?: Option[];
|
||||
placeholder?: string;
|
||||
}>;
|
||||
values?: Record<string, any>;
|
||||
onChange?: (values: Record<string, any>) => void;
|
||||
onReset?: () => void;
|
||||
}
|
||||
|
||||
/** 商品列表组件Props */
|
||||
interface GoodsList extends Base {
|
||||
goods: Product.Info[];
|
||||
loading?: boolean;
|
||||
layout?: 'grid' | 'list';
|
||||
columns?: number;
|
||||
showPrice?: boolean;
|
||||
showStock?: boolean;
|
||||
showSales?: boolean;
|
||||
onItemClick?: (goods: Product.Info) => void;
|
||||
onAddToCart?: (goods: Product.Info, sku?: Product.SKU) => void;
|
||||
}
|
||||
|
||||
/** 商品卡片组件Props */
|
||||
interface GoodsCard extends Base {
|
||||
goods: Product.Info;
|
||||
layout?: 'vertical' | 'horizontal';
|
||||
showPrice?: boolean;
|
||||
showStock?: boolean;
|
||||
showSales?: boolean;
|
||||
onClick?: () => void;
|
||||
onAddToCart?: (sku?: Product.SKU) => void;
|
||||
}
|
||||
|
||||
/** 规格选择器组件Props */
|
||||
interface SpecSelector extends Base {
|
||||
specs: Product.Spec[];
|
||||
skus: Product.SKU[];
|
||||
selectedSku?: Product.SKU;
|
||||
onChange?: (sku: Product.SKU) => void;
|
||||
}
|
||||
|
||||
/** 数量选择器组件Props */
|
||||
interface QuantitySelector extends Base {
|
||||
value: number;
|
||||
min?: number;
|
||||
max?: number;
|
||||
step?: number;
|
||||
disabled?: boolean;
|
||||
onChange?: (value: number) => void;
|
||||
}
|
||||
|
||||
/** 购物车商品项组件Props */
|
||||
interface CartItem extends Base {
|
||||
item: Cart.Item;
|
||||
editable?: boolean;
|
||||
onSelect?: (selected: boolean) => void;
|
||||
onQuantityChange?: (quantity: number) => void;
|
||||
onRemove?: () => void;
|
||||
}
|
||||
|
||||
/** 订单列表组件Props */
|
||||
interface OrderList extends Base {
|
||||
orders: Order.Info[];
|
||||
loading?: boolean;
|
||||
showActions?: boolean;
|
||||
onItemClick?: (order: Order.Info) => void;
|
||||
onPay?: (order: Order.Info) => void;
|
||||
onCancel?: (order: Order.Info) => void;
|
||||
onConfirm?: (order: Order.Info) => void;
|
||||
onRefresh?: () => void;
|
||||
}
|
||||
|
||||
/** 订单卡片组件Props */
|
||||
interface OrderCard extends Base {
|
||||
order: Order.Info;
|
||||
showActions?: boolean;
|
||||
onClick?: () => void;
|
||||
onPay?: () => void;
|
||||
onCancel?: () => void;
|
||||
onConfirm?: () => void;
|
||||
}
|
||||
|
||||
/** 地址选择器组件Props */
|
||||
interface AddressSelector extends Base {
|
||||
value?: Order.Address;
|
||||
addresses?: Order.Address[];
|
||||
onSelect?: (address: Order.Address) => void;
|
||||
onAdd?: () => void;
|
||||
onEdit?: (address: Order.Address) => void;
|
||||
onDelete?: (address: Order.Address) => void;
|
||||
}
|
||||
|
||||
/** 支付方式选择器组件Props */
|
||||
interface PaymentSelector extends Base {
|
||||
value?: Order.PaymentType;
|
||||
methods: Array<{
|
||||
type: Order.PaymentType;
|
||||
name: string;
|
||||
icon?: string;
|
||||
disabled?: boolean;
|
||||
}>;
|
||||
onChange?: (type: Order.PaymentType) => void;
|
||||
}
|
||||
|
||||
/** 用户头像组件Props */
|
||||
interface UserAvatar extends Base {
|
||||
user?: User.BaseInfo;
|
||||
size?: 'small' | 'medium' | 'large' | number;
|
||||
shape?: 'circle' | 'square';
|
||||
showName?: boolean;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
/** 错误边界组件Props */
|
||||
interface ErrorBoundary extends Base {
|
||||
fallback?: ReactNode;
|
||||
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
||||
}
|
||||
|
||||
/** 加载状态组件Props */
|
||||
interface Loading extends Base {
|
||||
loading: boolean;
|
||||
tip?: string;
|
||||
size?: 'small' | 'medium' | 'large';
|
||||
overlay?: boolean;
|
||||
}
|
||||
|
||||
/** 空状态组件Props */
|
||||
interface Empty extends Base {
|
||||
image?: string;
|
||||
description?: string;
|
||||
action?: ReactNode;
|
||||
}
|
||||
|
||||
/** 骨架屏组件Props */
|
||||
interface Skeleton extends Base {
|
||||
loading: boolean;
|
||||
rows?: number;
|
||||
avatar?: boolean;
|
||||
title?: boolean;
|
||||
active?: boolean;
|
||||
}
|
||||
}
|
||||
160
types/global.d.ts
vendored
Normal file
160
types/global.d.ts
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
/// <reference types="@tarojs/taro" />
|
||||
|
||||
// 静态资源模块声明
|
||||
declare module '*.png' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.gif' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.jpg' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.jpeg' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.svg' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.css' {
|
||||
const content: Record<string, string>;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.less' {
|
||||
const content: Record<string, string>;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.scss' {
|
||||
const content: Record<string, string>;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.sass' {
|
||||
const content: Record<string, string>;
|
||||
export default content;
|
||||
}
|
||||
declare module '*.styl' {
|
||||
const content: Record<string, string>;
|
||||
export default content;
|
||||
}
|
||||
|
||||
// 环境变量类型定义
|
||||
declare namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
|
||||
NODE_ENV: 'development' | 'production' | 'test';
|
||||
/** 当前构建的平台 */
|
||||
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd';
|
||||
/**
|
||||
* 当前构建的小程序 appid
|
||||
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
|
||||
* @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
|
||||
*/
|
||||
TARO_APP_ID: string;
|
||||
/** API基础URL */
|
||||
API_BASE_URL?: string;
|
||||
/** 应用名称 */
|
||||
APP_NAME?: string;
|
||||
/** 调试模式 */
|
||||
DEBUG?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// 全局常量类型定义
|
||||
declare const API_BASE_URL: string;
|
||||
declare const APP_NAME: string;
|
||||
declare const DEBUG: string;
|
||||
|
||||
// 基础类型定义
|
||||
declare global {
|
||||
/** 通用ID类型 */
|
||||
type ID = string | number;
|
||||
|
||||
/** 时间戳类型 */
|
||||
type Timestamp = number;
|
||||
|
||||
/** 可选的字符串或数字 */
|
||||
type StringOrNumber = string | number;
|
||||
|
||||
/** 分页参数基础类型 */
|
||||
interface BasePaginationParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
sort?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
/** 分页响应基础类型 */
|
||||
interface BasePaginationResponse<T = any> {
|
||||
list: T[];
|
||||
count: number;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
totalPages?: number;
|
||||
}
|
||||
|
||||
/** API响应基础类型 */
|
||||
interface BaseApiResponse<T = any> {
|
||||
code: number;
|
||||
message?: string;
|
||||
data?: T;
|
||||
timestamp?: Timestamp;
|
||||
}
|
||||
|
||||
/** 基础实体类型 */
|
||||
interface BaseEntity {
|
||||
id?: ID;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
createBy?: string;
|
||||
updateBy?: string;
|
||||
}
|
||||
|
||||
/** 树形结构基础类型 */
|
||||
interface BaseTreeNode<T = any> {
|
||||
id: ID;
|
||||
parentId?: ID;
|
||||
children?: T[];
|
||||
level?: number;
|
||||
}
|
||||
|
||||
/** 选项类型 */
|
||||
interface Option<T = StringOrNumber> {
|
||||
label: string;
|
||||
value: T;
|
||||
disabled?: boolean;
|
||||
children?: Option<T>[];
|
||||
}
|
||||
|
||||
/** 文件上传类型 */
|
||||
interface UploadFile {
|
||||
uid: string;
|
||||
name: string;
|
||||
status: 'uploading' | 'done' | 'error';
|
||||
url?: string;
|
||||
size?: number;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/** 地址信息类型 */
|
||||
interface AddressInfo {
|
||||
province: string;
|
||||
city: string;
|
||||
district: string;
|
||||
detail: string;
|
||||
postalCode?: string;
|
||||
longitude?: number;
|
||||
latitude?: number;
|
||||
}
|
||||
|
||||
/** 联系信息类型 */
|
||||
interface ContactInfo {
|
||||
name: string;
|
||||
phone: string;
|
||||
email?: string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user