From 4aa63b141ff40e0c953779fcb424e608100f0817 Mon Sep 17 00:00:00 2001 From: Yeban8090 Date: Thu, 17 Apr 2025 16:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A4=E8=AF=81=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E9=A2=9C=E8=89=B2=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- manifest.json | 2 +- package-lock.json | 4 +-- package.json | 2 +- src/settings/CreateThemeModal.ts | 42 ++++++++++++++++++++++++++------ 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 53022f9..d33166a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Note to RED 一键将 Obsidian 笔记转换为小红书图片格式的插件。 -![downloads](https://img.shields.io/badge/downloads-1K-brightgreen) ![version](https://img.shields.io/badge/version-1.0.5-blue) ![license](https://img.shields.io/badge/license-MIT-green) [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-支持作者-yellow)](https://ko-fi.com/bruceyeban) +![downloads](https://img.shields.io/badge/downloads-1K-brightgreen) ![version](https://img.shields.io/badge/version-1.0.6-blue) ![license](https://img.shields.io/badge/license-MIT-green) [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-支持作者-yellow)](https://ko-fi.com/bruceyeban) ## 功能特点 - 📝 使用二级标题分割内容,每个标题自动生成一张配图 diff --git a/manifest.json b/manifest.json index fb0ed2e..6c72472 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "note-to-red", "name": "Note to RED", - "version": "1.0.5", + "version": "1.0.6", "minAppVersion": "0.15.0", "description": "Convert Markdown notes to RED (Xiaohongshu) style images", "author": "Yeban", diff --git a/package-lock.json b/package-lock.json index 1e73f96..a498397 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "note-to-red", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "note-to-red", - "version": "1.0.5", + "version": "1.0.6", "license": "MIT", "dependencies": { "dom-to-image": "^2.6.0", diff --git a/package.json b/package.json index 231ca35..2e0b2e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "note-to-red", - "version": "1.0.5", + "version": "1.0.6", "description": "一键将 Obsidian 笔记转换为小红书图片格式", "main": "main.js", "scripts": { diff --git a/src/settings/CreateThemeModal.ts b/src/settings/CreateThemeModal.ts index 8d6b0db..7bc3a81 100644 --- a/src/settings/CreateThemeModal.ts +++ b/src/settings/CreateThemeModal.ts @@ -550,22 +550,48 @@ export class CreateThemeModal extends Modal { const currentColor = styles.userName.match(/color:\s*(#[a-fA-F0-9]+)/)?.[1]; color.setValue(currentColor) .onChange(value => { - // 更新所有颜色相关的样式 ['userName', 'userId', 'postTime'].forEach(key => { styles[key] = styles[key].replace(/color:\s*#[a-fA-F0-9]+/, `color: ${value}`); }); - - // 更新验证图标 - styles.verifiedIcon = styles.verifiedIcon - .replace(/background:\s*linear-gradient\([^)]+\)/, `background: linear-gradient(135deg, ${value}, ${value})`) - .replace(/border:\s*1px solid\s*#[a-fA-F0-9]+80/, `border: 1px solid ${value}80`); - - // 更新头像容器 styles.avatar.container = styles.avatar.container .replace(/box-shadow:\s*0\s*4px\s*16px\s*[^;]+/, `box-shadow: 0 4px 16px ${value}1a`) .replace(/border:\s*1px solid\s*#[a-fA-F0-9]+80/, `border: 1px solid ${value}80`); }); }); + + new Setting(headerSection) + .setName('认证图标颜色') + .setDesc('设置认证(已验证)图标的主色') + .addColorPicker(color => { + // 兼容 background: linear-gradient(...) 和 background-color: ... + let currentColor = '#b87333'; + const bgMatch = styles.verifiedIcon.match(/background:\s*linear-gradient\([^,]+,\s*(#[a-fA-F0-9]+)/); + if (bgMatch) { + currentColor = bgMatch[1]; + } else { + const colorMatch = styles.verifiedIcon.match(/background-color:\s*(#[a-fA-F0-9]+)/); + if (colorMatch) { + currentColor = colorMatch[1]; + } + } + color.setValue(currentColor) + .onChange(value => { + // 先处理 linear-gradient + if (styles.verifiedIcon.includes('linear-gradient')) { + styles.verifiedIcon = styles.verifiedIcon + .replace(/background:\s*linear-gradient\([^)]+\)/, `background: linear-gradient(135deg, ${value}, ${value})`); + } + // 再处理 background-color + if (styles.verifiedIcon.includes('background-color')) { + styles.verifiedIcon = styles.verifiedIcon + .replace(/background-color:\s*#[a-fA-F0-9]+/, `background-color: ${value}`); + } + // 统一处理 border 和 box-shadow + styles.verifiedIcon = styles.verifiedIcon + .replace(/border:\s*1px solid\s*#[a-fA-F0-9]+80/, `border: 1px solid ${value}80`) + .replace(/box-shadow:\s*0 2px 8px [^;]+;/, `box-shadow: 0 2px 8px ${value}1a;`); + }); + }); } private addTitleSettings(container: HTMLElement, styles: any) {