### Start Development Mode Source: https://github.com/sunbooshi/note-to-mp/blob/main/AGENTS.md Starts the development server with file watching enabled for rapid development. ```bash npm run dev ``` -------------------------------- ### Get Authorization Key Information Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Fetches information about the provided authorization key, including VIP status and expiration date. The expiration date is returned in ISO format. ```typescript async function wxKeyInfo(authkey: string): Promise ``` ```typescript const res = await wxKeyInfo(authKey); if (res.status === 200) { console.log(res.json.vip, res.json.expireat); } ``` -------------------------------- ### Batch Get Material from Weixin Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Retrieves a list of materials from the Weixin material library. Supports filtering by type and pagination with offset and count parameters. Returns the total item count and the list of items. ```typescript async function wxBatchGetMaterial(token: string, type: string, offset?: number, count?: number): Promise ``` ```typescript const res = await wxBatchGetMaterial(token, 'image', 0, 10); console.log(res.item[0]?.media_id); ``` -------------------------------- ### Get Weixin Access Token Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Retrieves the Weixin access token using an authorization key, app ID, and secret. Ensure the secret is encrypted before passing. ```typescript async function wxGetToken(authkey: string, appid: string, secret: string): Promise ``` ```typescript const res = await wxGetToken(authKey, appid, secret); if (res.status === 200) { console.log(res.json.token); } ``` -------------------------------- ### Build Production Version Source: https://github.com/sunbooshi/note-to-mp/blob/main/AGENTS.md Compiles the plugin into a production-ready build. ```bash npm run build ``` -------------------------------- ### Download Assets Source: https://github.com/sunbooshi/note-to-mp/blob/main/AGENTS.md Downloads necessary assets such as themes and code highlighting definitions. ```bash npm run download ``` -------------------------------- ### Highlight Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 代码高亮样式对象,包含样式名称、资源 URL 和 CSS 内容。 ```typescript interface Highlight { name: string; // 高亮样式名称 url: string; // 高亮样式 URL css: string; // CSS 内容 } ``` -------------------------------- ### wxBatchGetMaterial Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Retrieves a list of materials from the WeChat media library. Supports filtering by type and pagination with offset and count. ```APIDOC ## POST /cgi-bin/material/batchget_material ### Description Retrieves a list of materials from the WeChat media library. ### Method POST ### Endpoint /cgi-bin/material/batchget_material?access_token={token} ### Parameters #### Path Parameters None #### Query Parameters - **token** (string) - Required - WeChat access token. #### Request Body - **type** (string) - Required - Material type (e.g., 'image'). - **offset** (number) - Optional - Pagination offset. Defaults to 0. - **count** (number) - Optional - Number of items per page. Defaults to 10. ### Request Example ```typescript const res = await wxBatchGetMaterial(token, 'image', 0, 10); console.log(res.item[0]?.media_id); ``` ### Response #### Success Response (200) - **item_count** (number) - Total number of materials. - **item** (array) - List of material objects, each potentially containing `media_id`. #### Response Example { "item_count": 100, "item": [ { "media_id": "MATERIAL_MEDIA_ID_1", "url": "MATERIAL_URL_1" }, { "media_id": "MATERIAL_MEDIA_ID_2", "url": "MATERIAL_URL_2" } ] } ``` -------------------------------- ### wxKeyInfo Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Retrieves information about the authorization key, including VIP status and expiration time. It takes the user authorization key as a path parameter. ```APIDOC ## GET /v1/wx/info/{authkey} ### Description Retrieves information about the authorization key, including VIP status and expiration time. ### Method GET ### Endpoint /v1/wx/info/{authkey} ### Parameters #### Path Parameters - **authkey** (string) - Required - User authorization key. #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **json.vip** (boolean) - Indicates if the user is a VIP. - **json.expireat** (string) - The VIP expiration time in ISO format. #### Response Example { "vip": true, "expireat": "2024-12-31T23:59:59Z" } ``` -------------------------------- ### wxWidget Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Invokes the WeChat widget API with provided parameters. It requires a user authorization key and a JSON string of parameters. ```APIDOC ## POST /math/widget ### Description Invokes the WeChat widget API. ### Method POST ### Endpoint /math/widget ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **params** (string) - Required - JSON formatted parameter string. ### Response #### Success Response (200) - (string) - Widget content on success. #### Response Example "Widget content here" ``` -------------------------------- ### Theme Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 主题对象,包含主题的名称、CSS 类名、描述、作者以及完整的 CSS 内容。 ```typescript interface Theme { name: string; // 主题名称 className: string; // CSS 类名 desc: string; // 主题描述 author: string; // 主题作者 css: string; // CSS 内容 } ``` -------------------------------- ### Upload Image to Weixin Server Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Uploads an image to the Weixin server. Specify type 'image' to upload to the material library, otherwise it uploads to a temporary server. Returns the image URL and media ID. ```typescript async function wxUploadImage(data: Blob, filename: string, token: string, type?: string): Promise<{url: string, media_id: string, errcode: number, errmsg: string}> ``` -------------------------------- ### wxAddDraftImages Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Creates a WeChat draft article that includes images. Requires a WeChat access token and `DraftImages` data object. ```APIDOC ## POST /cgi-bin/draft/add (with images) ### Description Creates a WeChat draft article that includes images. ### Method POST ### Endpoint /cgi-bin/draft/add?access_token={token} ### Parameters #### Path Parameters None #### Query Parameters - **token** (string) - Required - WeChat access token. #### Request Body - **data** (DraftImages) - Required - Data object containing image and article information. ### Response #### Success Response (200) - **json.media_id** (string) - The media ID of the created draft article. #### Response Example { "media_id": "DRAFT_WITH_IMAGES_MEDIA_ID" } ``` -------------------------------- ### Import Weixin API Functions Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Imports all necessary functions and types from the weixin-api module for use in your project. ```typescript import { wxGetToken, wxEncrypt, wxKeyInfo, wxWidget, wxUploadImage, wxAddDraft, wxAddDrafts, wxAddDraftImages, wxBatchGetMaterial, getUploadImageURL, putImageToOSS, uploadImageToOSS, getMetadata, requestAnnouncement, requestLatestVersion, DraftArticle, DraftImageMediaId, DraftImages, Announcement, VersionInfo } from 'src/weixin-api' ``` -------------------------------- ### wxUploadImage Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Uploads an image to WeChat servers. It supports uploading to the media library or as a temporary file based on the `type` parameter. Requires image data, filename, and access token. ```APIDOC ## POST /cgi-bin/media/uploadimg or /cgi-bin/material/add_material ### Description Uploads an image to WeChat servers. Can upload to the media library if `type` is 'image', otherwise uploads as a temporary file. ### Method POST ### Endpoint - For temporary upload: `/cgi-bin/media/uploadimg?access_token={token}` - For media library upload: `/cgi-bin/material/add_material?access_token={token}&type=image` ### Parameters #### Path Parameters None #### Query Parameters - **token** (string) - Required - WeChat access token. - **type** (string) - Optional - 'image' to upload to the media library. #### Request Body - **data** (Blob) - Required - Image binary data. - **filename** (string) - Required - Image filename. ### Response #### Success Response (200) - **url** (string) - URL of the uploaded image (for display). - **media_id** (string) - Media ID of the uploaded image (for draft posts). - **errcode** (number) - Error code. - **errmsg** (string) - Error message. #### Response Example { "url": "IMAGE_URL", "media_id": "MEDIA_ID", "errcode": 0, "errmsg": "ok" } ``` -------------------------------- ### ExtraSettings Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 扩展配置对象,主要用于配置图片边框设置。 ```typescript interface ExtraSettings { imageFrame: ImageFrameSettings | null; } ``` -------------------------------- ### wxAddDrafts Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Creates multiple draft articles in WeChat. Accepts a WeChat access token and an array of `DraftArticle` objects. ```APIDOC ## POST /cgi-bin/draft/add (for multiple articles) ### Description Creates multiple draft articles in WeChat. ### Method POST ### Endpoint /cgi-bin/draft/add?access_token={token} ### Parameters #### Path Parameters None #### Query Parameters - **token** (string) - Required - WeChat access token. #### Request Body - **data** (DraftArticle[]) - Required - Array of article data objects. ### Response #### Success Response (200) - **json.media_id** (string) - The media ID of the last created draft article. #### Response Example { "media_id": "LAST_DRAFT_MEDIA_ID" } ``` -------------------------------- ### DraftImages Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 包含图文的微信草稿文章结构。定义了文章类型、标题、内容、评论设置以及图片信息。 ```typescript interface DraftImages { article_type: string; title: string; content: string; need_open_comment: number; only_fans_can_comment: number; image_info: DraftImageInfo; } ``` -------------------------------- ### ImageFrameSettings Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 配置图片边框和背景效果。支持纯色或渐变背景,并可配置边距、圆角、边框样式和阴影。 ```typescript interface ImageFrameSettings { backgroundMode: string; // 'solid' 或 'gradient' gradient: string; // 渐变值 solidColor: string; // 纯色值 direction: string; // 渐变方向 padding: number; // 内边距 backgroundRadius: number; // 背景圆角 borderStyle: string; // 边框样式 borderRadius: number; // 边框圆角 showShadow: boolean; // 是否显示阴影 watermark: WatermarkSettings; // 水印配置 } ``` -------------------------------- ### Add Draft Article with Images to Weixin Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Creates a new draft article in the Weixin draft box that includes images. Requires a Weixin access token and specific data structure for image-inclusive articles. ```typescript async function wxAddDraftImages(token: string, data: DraftImages): Promise ``` -------------------------------- ### Add Multiple Draft Articles to Weixin Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Creates multiple draft articles in the Weixin draft box simultaneously. Requires a Weixin access token and an array of article data objects. ```typescript async function wxAddDrafts(token: string, data: DraftArticle[]): Promise ``` -------------------------------- ### DraftArticle Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 微信公众号草稿文章数据结构。包含标题、作者、摘要、封面、内容、素材 ID 等字段。 ```typescript interface DraftArticle { title: string; author?: string; digest?: string; cover?: string; content: string; content_source_url?: string; thumb_media_id: string; need_open_comment?: number; only_fans_can_comment?: number; pic_crop_235_1?: string; pic_crop_1_1?: string; appid?: string; theme?: string; highlight?: string; css?: string; disable_image_background?: boolean; } ``` -------------------------------- ### wxAddDraft Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Creates a new draft article in WeChat. Accepts a WeChat access token and `DraftArticle` object containing title, author, digest, content, and thumb media ID. ```APIDOC ## POST /cgi-bin/draft/add ### Description Creates a new draft article in WeChat. ### Method POST ### Endpoint /cgi-bin/draft/add?access_token={token} ### Parameters #### Path Parameters None #### Query Parameters - **token** (string) - Required - WeChat access token. #### Request Body - **data** (DraftArticle) - Required - Article data object with `title`, `author`, `digest`, `content`, `thumb_media_id`. ### Request Example ```typescript const article: DraftArticle = { title: 'Article Title', author: 'Author Name', digest: 'Article Summary', content: '

Article Content

', thumb_media_id: 'COVER_MEDIA_ID', }; const res = await wxAddDraft(token, article); ``` ### Response #### Success Response (200) - **json.media_id** (string) - The media ID of the created draft article. #### Response Example { "media_id": "DRAFT_MEDIA_ID" } ``` -------------------------------- ### Add Single Draft Article to Weixin Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Creates a new draft article in the Weixin draft box. Requires a Weixin access token and the article data, including title, author, digest, content, and thumb media ID. ```typescript async function wxAddDraft(token: string, data: DraftArticle): Promise ``` ```typescript const article: DraftArticle = { title: '文章标题', author: '作者名', digest: '文章摘要', content: '

文章内容

', thumb_media_id: '封面素材 ID', }; const res = await wxAddDraft(token, article); ``` -------------------------------- ### WatermarkSettings Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 用于配置图片水印效果。包含文本、字体、大小、颜色、位置和透明度等属性。 ```typescript interface WatermarkSettings { text: string; // 水印文本 font: string; // 字体 size: number; // 字体大小 color: string; // 颜色 position: string; // 位置 opacity: number; // 透明度 } ``` -------------------------------- ### DraftImageInfo Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 图文消息中的所有图片信息,包含一个图片素材 ID 列表。 ```typescript interface DraftImageInfo { image_list: DraftImageMediaId[]; } ``` -------------------------------- ### wxEncrypt Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Encrypts WeChat Official Account secrets. It accepts a user authorization key and an array of WeChat account details (name, appid, secret) and returns a response where each appid is mapped to its encrypted secret. ```APIDOC ## POST /v1/wx/encrypt ### Description Encrypts WeChat Official Account secrets. ### Method POST ### Endpoint /v1/wx/encrypt ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **wechat** (any[]) - Required - Array of WeChat accounts, each with `name`, `appid`, and `secret`. ### Response #### Success Response (200) - **json[appid]** (string) - The encrypted secret for the given appid. #### Response Example { "APPID1": "ENCRYPTED_SECRET1", "APPID2": "ENCRYPTED_SECRET2" } ``` -------------------------------- ### wxGetToken Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Retrieves the WeChat access token required for API authentication. It takes user authorization key, appid, and secret as parameters and returns a RequestUrlResponse containing the token or an error message. ```APIDOC ## POST /v1/wx/token ### Description Retrieves the WeChat access token. ### Method POST ### Endpoint /v1/wx/token ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript const res = await wxGetToken(authKey, appid, secret); if (res.status === 200) { console.log(res.json.token); } ``` ### Response #### Success Response (200) - **json.token** (string) - The access token string. - **json.message** (string) - Error message if any. #### Response Example { "token": "ACCESS_TOKEN_STRING" } ``` -------------------------------- ### Call Weixin Widget API Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Invokes the Weixin widget API with provided parameters. The function returns the widget content on success or an error message on failure. ```typescript async function wxWidget(authkey: string, params: string): Promise ``` -------------------------------- ### Encrypt Weixin Official Account Secret Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/api-reference/weixin-api.md Encrypts the secrets for multiple Weixin Official Accounts using an authorization key. The response provides the encrypted secret for each app ID. ```typescript async function wxEncrypt(authkey: string, wechat: any[]): Promise ``` -------------------------------- ### DraftImageMediaId Interface Source: https://github.com/sunbooshi/note-to-mp/blob/main/_autodocs/types.md 图文消息中的图片素材 ID 对象。 ```typescript interface DraftImageMediaId { image_media_id: string; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.