1.0.15 • Published 1 year ago

@dead_fish/api v1.0.15

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago
npm install @dead_fish/api
接口名称 (方法名)说明参数参数说明
address/secure_address获取地址 (http/https)
shortLink/secure_shortLink创建短链 (http/https){url: string, month?: number}url: 需要转换的长链, month: 短链有效期(max: 24)
ip/secure_ip获取 IP (http/https)
sendEmail/secure_sendEmail发送邮件(http/https){email: string[], subject: string, title?: string, content?: string[]}email: 收件人邮箱数组, subject: 邮件主题, title: 内容主题, content: 内容列表数组
poster/secure_poster生成海报 (http/https)PosterBodyPosterBody: 包含海报信息的对象

海报报文信息

{
	data?: [
		url?: string // 图片地址
		x?: number // (图片|文字) x 坐标
		y?: number // (图片|文字) y 坐标
		width?: number // 图片 宽度
		height?: number // 图片 高度
		radius?: number // 图片 圆角
		rotate?: number // 图片 旋转角度
		referer?: string // 图片防盗链地址 如果此图片的防盗链和其他的不同,可以单独设置

		text?: string // 文字内容
		font?: string // 文字字体 (⚠️注意: 无法设置指定的字体,目前不支持设置字体,抱歉)
		color?: string // 文字颜色
		textAlign?: 'left' | 'center' | 'right' | 'start' | 'end' // 文字对齐方式
		textBaseline?: 'top' | 'middle' | 'bottom' | 'alphabetic' | 'hanging' // 文字基线
		lineGap?: number // 文字行间距
		maxWidth?: number // 文字最大宽度
		maxLine?: number // 文字最大行数 超出会出现 ... 省略号
	],
	canvas?: {
		width?: number // 画布宽度
		height?: number // 画布高度
		background?: string // 画布背景色
	},
	referer?: string // 防盗链地址(可选) 如果图片设置了防盗链并且所有图片 的防盗链相同,可以设置此属性
}

// 请求返回的数据是图片的 base64 编码

发送邮箱 案例:

import uApi from '@dead_fish/api'

const body = {
	email: ['example@gmail.com', 'example@sina.cn'],
	subject: '重置验证',
	title: "<p style='text-align: center;'>重置密码验证码</p>",
	content: [
		"<p style='font-weight: 400;'>点击下方链接前往重置密码页面.</p>",
		"<a href='https://www.baidu.com'>重置密码</a>",
		"<span>验证码: <strong style='font-weight: 600;'>787321</strong></span>",
		'有效时长: 5分钟',
		"<p style='font-size: 14px; font-style: italic;'>如果你没有发起重置密码的操作,可以忽律这封邮件.</p>",
	],
}

uApi.sendEmail(body)
	.then((res) => {})
	.catch((error) => {})

生成海报 案例:

import uApi from '@dead_fish/api'

const body = {
	data: [
		{
			url: 'https://ik.imagekit.io/zhousuyang/prod/rox/bg13.jpg',
			x: 0,
			y: 0,
			width: 750,
			height: 750,
			rotate: 0,
		},
		{
			url: 'https://ik.imagekit.io/zhousuyang/prod/rox/my-miniprogram.jpg',
			x: 325,
			y: 325,
			width: 100,
			height: 100,
			radius: 50,
		},
		{
			url: 'https://ik.imagekit.io/zhousuyang/prod/rox/checkbox-active-icon.png',
			x: 100,
			y: 800,
			width: 60,
			height: 60,
			radius: 0,
		},
		{
			text: '春天一起去露营',
			x: 172,
			y: 794,
			font: '48px',
			color: 'green',
			rotate: 0,
		},
		{
			text: '我是个话题我是个话题我是个话题我是个话题 我是个话题我是个话题我是个话题我是个话题是个话题我是个话题我是个话题我是我是个话题我是个话题我是个话题我是个话题 我是个话题我是个话题我是个话题我是个话题是个话题我是个话题我是个话题我是我是个话题我是个话题我是个话题我是个话题 我是个话题我是个话题我是个话题我是个话题是个话题我是个话题我是个话题我是',
			x: 100,
			y: 960,
			font: '24px',
			maxWidth: 550,
			lineGap: 10,
			maxLine: 2,
		},
		{
			text: '我是个话题我是个话题我是个话题我是个话题 我是个话题我是个话题我是个话题我是个话题是个话题我是个话题我是个话题我是我是个话题我是个话题我是个话题我是个话题',
			x: 100,
			y: 1060,
			font: '24px',
			maxWidth: 550,
			lineGap: 10,
		},
		{
			url: 'https://ik.imagekit.io/zhousuyang/prod/rox/my-miniprogram.jpg',
			x: 325,
			y: 1260,
			width: 100,
			height: 100,
			radius: 50,
		},
		{
			text: '长按图片识别二维码阅读全部话题内容',
			x: 250,
			y: 1380,
			maxWidth: 250,
			font: '14px',
			color: '#ccc',
		},
	],
	canvas: {
		width: 750,
		height: 1460,
		background: '#ffffff',
	},
}

uApi.poster(body)
	.then((res) => {
		console.log(res.data)
	})
	.catch((error) => {})

ES

import uApi from '@dead_fish/api'

uApi.address().then((res) => {})

CommonJS

const uApi = require('@dead_fish/api')

uApi.address().then((res) => {})

Browser

<script src="./node_modules/@dead_fish/api/dist/bundle.umd.js"></script>
<script>
	const apis = window.pAips.uApi
	apis.address().then((res) => {})
</script>
1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago