@chuangkit/chuangkit-design
Version:
创客贴开放 API,让你的网站快速具备设计能力
433 lines (406 loc) • 15.9 kB
TypeScript
export interface ReceiveOption {
'data-access': string;
'data-exp': number;
'sign': string;
'signType': string;
'data-ext-ref-user-flag': string;
'data-kinds': string;
'data-template-id'?: number;
'data-design-id'?: string;
'data-kind'?: number;
'data-width'?: number;
'data-height'?: number;
'data-unit'?: string;
'data-zIndex'?: number;
'data-imgkind'?: number;
'upload-img'?: string;
'data-upload-img-width'?: number;
'data-upload-img-top'?: number;
'data-upload-img-left'?: number;
'data-finish-btn-name'?: string;
'data-charged-template-show'?: number;
'data-definition'?: number;
'data-allow-login'?: number;
'data-auto-save'?: number;
'data-extra-add-text-list'?: any;
'data-extra-add-img-list'?: any;
'data-extra-add-svg-frame'?: string;
'data-change'?: any;
'data-close-copyright'?: any;
'data-logo'?: any;
'data-style'?: any;
'data-hideservice'?: any;
'data-auth-name'?: string;
'data-auth-phone-number'?: string | number;
'data-auth-identity'?: any;
'data-extra-header-bg'?: any;
'data-extra-hide-copyright-fonts'?: any;
'data-extra-hide-upload-capacity'?: any;
'data-extra-hide-text-group'?: any;
'data-extra-path'?: any;
'data-extra-hide-bar'?: any;
'data-extra-get-user-design-url'?: any;
'data-extra-template-search-keyword'?: string,
'data-extra-show-history-design'?: string | number,
'data-extra-smart-transform'?: string | number,
}
export interface MapOption {
access_id: string | null;
exp: number | string | null;
sign: string | null;
sign_type: string | null;
ext_ref_user_flag: string | null;
design_id?: string | null;
template_id?: number | string | null;
kind_id?: number | string | null;
kind_width?: number | string | null;
kind_height?: number | string | null;
design_unit?: string | null;
definition?: number | string | null;
change?: string | null;
z_index?: number | string | null;
close_copyright?: any | null;
allow_login?: number | string | null;
auto_save?: number | string | null;
image_logo?: string | null;
img_kind?: number | string | null;
style?: string | null;
title?: string | null;
auth_name?: string | null;
auth_phone_number?: string | number | null;
auth_identity?: any;
upload_img?: string | null;
upload_img_width?: number | string | null;
upload_img_top?: number | string | null;
upload_img_left?: number | string | null;
finish_btn_name?: string | null;
charged_template_show?: number | string | null;
add_img_list?: string | null;
add_text_list?: string | null;
add_svg_frame?: string | null;
hide_service?: string | null;
header_bg?: string | null;
hide_copyright_fonts?: string | null;
hide_upload_capacity?: string | null;
hide_text_group?: string | null;
path?: any;
kinds?: any;
hide_bar?: any;
get_user_design_url?: any;
template_search_kw?: string;
show_history_design?: string | number,
smart_transform?: string | number
}
export interface UrlPms {
access: string | null;
exp: number | string | null;
sign: string | null;
sign_type: string | null;
eruf: string | null;
definition?: number | string | null;
change?: string | null;
zindex?: number | string | null;
auth_name?: string | null;
auth_phone?: string | number | null;
auth_identity?: any;
cc?: string | null;
al?: number | string | null;
as?: number | string | null;
logo?: string | null;
img_k?: number | string | null;
upload_img?: string | null;
img_w?: number | string | null;
img_t?: number | string | null;
img_l?: number | string | null;
fbn?: string | null;
cts?: number | string | null;
hide_service?: string | null;
header_bg?: string | null;
hide_copyright_fonts?: string | null;
hide_upload_capacity?: string | null;
hide_text_group?: string | null;
design_id?: string | null;
k?: number | string | null;
t?: number | string | null;
w?: number | string | null;
h?: number | string | null;
unit?: string | null;
path?: any;
kinds?: any;
hide_bar?: any;
get_user_design_url?: any;
template_search_kw?: string;
show_history_design?: string | number;
smart_transform?: string | number
}
export interface BuildUrlPms {
[propName: string]: any;
}
export interface commonOption {
app_id: string | number,
expire_time: string | number,
sign: string,
user_flag: string | number,
device_type: number,
auth_url?: string,
charge_type?: number,
package_id?: number,
enable_authorize?: number,
taxpayer_name?: string,
taxpayer_phone?: string,
taxpayer_number?: string,
template_id?: number | string,
design_id?: string,
random_id?: string,
coop_material_limit?: number,
coop_font_limit?: number,
charging_template_limit?: number,
payment_url?: string,
kind_id?: number,
ai_kind_id?: string,
width?: number,
height?: number,
unit?: string,
add_img_list?: any,
show_name?: string | number,
file_url?: string,
file_type?: string,
}
export interface pcOption extends commonOption {
z_index?: number,
download_mime?: number,
upload_img_url?: string,
upload_img_width?: number,
upload_img_top?: number,
upload_img_left?: number,
finish_button_name?: string,
download_quality?: number,
allow_login?: number,
auto_save?: number,
show_copyright?: number,
enable_smart_transform?: number,
hide_customer_service?: number,
hide_logo?: number,
logo_url?: string,
hide_upload_capacity?: number,
add_text_list?: any,
add_svg_frame?: string,
template_search_keyword?: string,
show_history_design?: number,
smart_transform?: number,
compress_size?: number,
render?: string,
show_watermark?: string | number,
canvas_width?: string | number,
canvas_height?: string | number,
canvas_unit?: string,
setting_code?: string,
}
export interface mOption extends commonOption {
template_show_kinds?: number,
redirect_url?: string,
in_frame?: boolean,
show_tpl_center?: boolean,
home_url?: string,
back_url?: string,
enter_page?: number,
design_test_ip?: string,
render?: string,
mtc_code?: string,
template_popup?: '0' | '1', // m站模板推荐弹窗,默认1,0:不弹 1:弹
download_more?: '0' | '1', // 指定格式保存,默认0, 0:不展示,1:展示
back_button_url?: string, // 移动端返回按钮,默认为空使用ckt 默认路径
m_design_version?: '0' | '1' | '2', // 选择M站设计页:0:默认,1:老版本,2:新版本
}
export type tFlag = 'template' | 'image' | 'template_center' | 'matting' | 'topic_page' | 'batch_matting' | 'ai_painter' | 'ai_design' | 'calendar_center' | 'quark_m_design' | 'my_space'
export interface IBaseConfig {
flag: tFlag
appId: string; // 三方AppId
timestamp: number; // 时间戳
sign: string; // sign appId + unionId + expire_time
}
export interface IImageConfig extends IBaseConfig {
unionId: string; // 三方用户唯一ID
file: File | string; // 图片
container?: string; // container 要指定的元素容器
hideLogo?: boolean; // 隐藏ckt logo
finishBtn?: string; // 下载按钮文案
designId?: string; // 设计Id
closeType: number; // 页面停留方式 0:关闭 1:停留 默认关闭
request_url: string; // 当前域名
functions?: string | number | Array<string | number>; // (非必传,默认0,0:全部、1:调整 2:裁剪 3:文字 4:水印 5:消除,多个时用逗号分割)
defaultFunction?: string | number; // 默认选中功能(非必传,默认0,0:首模块,1:调整 2:裁剪 3:文字 4:水印 5:消除)
}
export interface IMattingConfig extends IBaseConfig {
unionId: string; // 三方用户唯一ID
file: File | string; // 图片
container?: string; // container 要指定的元素容器
hideLogo?: boolean; // 隐藏ckt logo
finishBtn?: string; // 下载按钮文案
closeType: number; // 页面停留方式 0:关闭 1:停留 默认关闭
request_url: string; // 当前域名
}
export interface AiDesignConfig extends IBaseConfig {
unionId: string; // 三方用户唯一ID
request_url?: string; //
SDKParameterKey?: string; // sdk接口返回key
type?: string; // type:类型(非必传,默认值0,经典版:0,会话版:1)
aiAvatar?: string; // ai的会话头像url地址(非必传,产品提供默认图)
userAvatar?: string; // 用户的会话头像url地址(非必传,产品提供默认图)
showWatermark?: string; // 展示预览水印(非必传,默认0,不展示:0,展示:1)
downloadEntry?: string; // 是否支持下载(非必传,默认值0,展示下载入口:0,隐藏下载入口:1)
decoration?: string; // 头像/背景节日营销装饰(非必传,默认0,展示:0,不展示:1)
container?: string; // 渲染dom节点(非必传,默认弹窗)
settingCode?: string; // 配置代码(非必传,不传则取创客贴默认场景)
aiKindId?: string; // (非必传,支持与settingCode一起传递)
back?: string; // 返回按钮(传递aiKindId时判断是否展示返回按钮,非必传,默认0,展示:0,隐藏:1)
logoUrl?: string; // logo文件地址(非必传)
generateType?: number // 生成类型(非必传,默认值0,立即生成:0,仅回调点击事件:1)
layoutStyle?: string; // 布局风格:0 传统(默认),1 平铺(平铺需配合settingCode)
}
export interface IParams {
kindId?: string; // 场景Id
industryTagId?: string; // 行业Id
colorTagId?: number; // 颜色Id
styleTagId?: number; // 风格Id
sortType?: number; // 1-最新上传(按模板上传时间)2-最多使用(按 12小时内的使用量) 3-热门推荐(按创客贴热门推荐逻辑)
priceType?: number; // 0-免费 1-会员免费 2-全部
inputKeyword?: string; // 搜索关键词
}
export interface ITemplateCenterConfig extends IBaseConfig {
params?: IParams; // 默认筛选项
container: string | HTMLElement; // container 要指定的元素容器
settingCode: string; // 模板中心配置代码
unionId?: string; // 三方用户Id
}
export interface ITopicPageConfig extends IBaseConfig{
container: string | HTMLElement; // container 要指定的元素容器
settingCode: string; // 专题页配置代码
}
export interface AiPainterConfig extends IBaseConfig{
container: string | HTMLElement; // container 要指定的元素容器
unionId: string; // 用户标识
companyFlag: string; // 公司标识
request_url: string; // 当前域名
mParam?: number;
device_type?: number;
aigc_env?: number;
downloadType?: number; // 下载类型(非必传,默认值0,标签页下载:0,仅回调下载地址:1)
generateType?: number; // 生成类型(非必传,默认值0,立即生成:0,仅回调点击事件:1)
generateButtonTips?: string; // 生成按钮提示文案(非必传,示例:消耗1贴贴)
}
export interface QuarkConfig{
appId: string; // 三方AppId
container:string;
userFlag:string;
flagType:number;
waterMarkUrl:string;
designId?:string;
templateId?:string;
kindId?:string;
}
interface InsertImg{
imgUrl:string;
name:string;
}
export interface IBatchMattingConfig extends IBaseConfig{
container: string | HTMLElement; // container 要指定的元素容器
unionId: string; // 用户标识
imgUrls?: InsertImg[]; // 图片url
custom_download?: string; // 推送下载地址还是下载到本地
}
interface ITemplateItem {
templateId: string; // 模板Id
templateName: string; // 模板名称
templateThumbUrl: string; // 模板缩略图
unionId?: string; // 用户Id
price: number; // 0-免费 1-付费
clickTime: number; // 用户点击时间戳
}
export interface IMessage extends MessageEvent {
data: {
mark: string; // 唯一标识
name: string; // 事件名称
result: object; // 内容
};
}
export abstract class ASdk {
abstract sdk_url: string;
abstract loading: boolean;
}
export interface IDesignSdk {
setCallBack: (key: string, fn: (params?: any) => void) => void;
noticeFn: (key: string, params?: object) => void;
createImageDesign: (designId?: string) => void;
setDesignId: (designId: string, isOpen: boolean) => void;
reload: () => void;
setContainer: (dom: HTMLElement) => void;
open: () => void;
}
export interface IDesignInfo {
'cktMessage': boolean; // 判断是否是创客贴 API 的返回
'kind': number; // 10:设计信息
'design-id': string; // 设计ID
'template-id': string; // 模板ID
'have-gif': number; // 是否含有动園元素 (0不含,1含有)
'have-mp4': number; // 是否含有视频元素 (0不含,1含有)
'price': number; // 设计价格(0免费设计,1付费设计)
'price-font': number; // 是否使用付费字体 (0不含,1含有)
'price-meterial': number; // 是香使用付费素材 (0不含,1含有)
'kind-id': number; // 场景1D
'kind-name': string; // 场炅名称
'height': number; // 设计高度
'width': number; // 设计宽度
'unit': string; // 单位 (px, mm. cm)
'page': number; // 设计共有多少页
'is-ppt': number; // 是否是ppt场景
'download-format': string; // 下载格式(如(ppt,401)等等)
}
export interface IOpenDesigner {
type: string;
cktMessage: boolean; // 判断是否是创客贴 API 的返回
kind: number; // 10:额外信息
user_id: number; // 用户id,
app_id: string; // appId
design_id: string; // 设计Id
ckt_template_id: string; // 模板Id
kind_name: string; // 场景名称
thumbnail_url: string; // 缩略图地址
}
export interface CalendarCenterConfig extends IBaseConfig {
container: string | HTMLElement; // container 要指定的元素容器
unionId: string; // 用户标识
companyFlag: string; // 公司标识
request_url: string; // 当前域名
preview?: string;
collect?: string;
edit?: string;
priceTag?: string;
templateTypes?: string;
festivalId?: string | number; // 节日id(默认选中节日,非必传,传递该参数时默认选中对应的节日)
title?: string; // 标题文案(左上角文案,非必传,默认不展示,传递该参数时展示传递的文案)
headHide: string | number; // head展示方式(0:全部,1:仅隐藏title和当前日期,2:隐藏title+当前日期+节日类型筛选)
}
// 定义MySpace配置接口
export interface MySpaceConfig extends IBaseConfig {
unionId: string; // 三方用户唯一ID
userFlag?: string; // 用户标识,优先于unionId
container?: string; // 容器选择器
functions?: string; // 启用的功能模块 0:全部启用 1:我的空间 2:我的收藏
defaultFunction?: string | number; // 默认选中功能模块 1:我的空间 2:我的收藏
spaceTabs?: string; // 我的空间内启用的标签 0:全部启用 1:设计 2:素材 3:回收站
defaultSpaceTab?: string | number; // 默认选中我的空间内功能模块 1:设计 2:素材 3:回收站
collectionTab?: string; // 我的收藏内启用的标签 0:全部 1:模板 2:素材
defaultCollectionTab?: string | number; // 默认选中我的收藏内功能模块 1:模板 2:素材
mobileUpload?: string | number; // 手机上传入口 0:禁用 1:启用
showName?: string | number; // 是否展示资源名称 0:隐藏 1:展示
uploadSvg?: string; // 是否展示SVG上传 0:禁用 1:展示(默认:1)
designButtonName?: string; // 设计按钮文案
materialButtonName?: string; // 素材按钮文案
favTemplateButtonName?: string; // 模板按钮文案
favMaterialButtonName?: string; // 模板按钮文案
type?: number; // 类型参数
generateType?: number; // 生成类型
zIndex?: number; // 弹窗z-index值
}
export type TEmptyVoidFunction = (args?: any) => void