知乎修改功能栏

This commit is contained in:
fzk
2025-02-25 09:14:06 +08:00
parent 354c2b2d0e
commit 02fc3bfecc
6 changed files with 70 additions and 19 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ export default function Chatgpt() {
return (
<>
{isModalOpen && (
{isModalOpen && content && (
<QRCodeModal
onClose={handleCancelModal}
onConfirm={handleConfirmModal}
+1 -1
View File
@@ -90,7 +90,7 @@ export default function Deepseek() {
return (
<>
{isModalOpen && (
{isModalOpen && content && (
<QRCodeModal
onClose={handleCancelModal}
onConfirm={handleConfirmModal}
+1 -1
View File
@@ -92,7 +92,7 @@ export default function Kimi() {
return (
<>
{isModalOpen && (
{isModalOpen && content && (
<QRCodeModal
onClose={handleCancelModal}
onConfirm={handleConfirmModal}
+2 -1
View File
@@ -9,7 +9,7 @@ export const config: PlasmoCSConfig = {
}
export default function Markdown() {
const [post] = useStorage({
const [post, setPost] = useStorage({
key: "md-post",
instance: new Storage({
area: "local"
@@ -27,6 +27,7 @@ export default function Markdown() {
title: _post.title || "文章1"
})
window.localStorage.setItem("MD__posts", JSON.stringify(posts))
setPost("")
location.reload()
}
}
+64 -14
View File
@@ -2,20 +2,19 @@ import type {
PlasmoCSConfig,
PlasmoCSUIProps,
PlasmoGetOverlayAnchor,
PlasmoGetShadowHostId,
PlasmoGetStyle
PlasmoGetShadowHostId
} from "plasmo"
import { useEffect, useRef, type FC } from "react"
import qrcodeUrl from "raw:~/public/wx/gzh.jpg"
import React, { useEffect, useRef, useState, type FC } from "react"
import { v4 as uuidv4 } from "uuid"
import { useMessage } from "@plasmohq/messaging/hook"
import { useStorage } from "@plasmohq/storage/hook"
import TagBtnStyle from "~component/tagBtn/style"
import Tags from "~component/ui/tags"
import { addCss, saveHtml, saveMarkdown } from "~tools"
import useCssCodeHook from "~utils/cssCodeHook"
import { useEditMarkdown } from "~utils/editMarkdownHook"
import makerQRPost from "~utils/makerQRPost"
import { useParseMarkdown } from "~utils/parseMarkdownHook"
import { Print } from "~utils/print"
import Turndown from "~utils/turndown"
@@ -33,9 +32,37 @@ const HOST_ID = "codebox-zhihu"
export const getShadowHostId: PlasmoGetShadowHostId = () => HOST_ID
export const getOverlayAnchor: PlasmoGetOverlayAnchor = async () =>
document.querySelector("article.Post-Main .Post-Title")
document.querySelector("article.Post-Main")
export const getStyle: PlasmoGetStyle = () => TagBtnStyle()
const style = {
box: {
position: "fixed" as const,
border: "1px solid #D9DADC",
left: "25px",
top: "85px",
width: "140px",
padding: "16px",
cursor: "pointer"
},
close: {
position: "absolute" as const,
top: "-5px",
right: "0px",
background: "none",
border: "none",
fontSize: "1.5rem",
cursor: "pointer",
padding: "0.5rem"
},
img: {
width: "100%"
},
item: {
color: "#000000",
fontSize: "1rem",
marginBottom: "3px"
}
}
const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => {
const [parseContent, setParseContent] = useParseMarkdown()
@@ -47,6 +74,7 @@ const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => {
const [history, setHistory] = useStorage<any[]>("codebox-history")
const [closeLog] = useStorage("config-closeLog", true)
const [content, setContent] = useEditMarkdown()
const [isShow, setIsShow] = useState(true)
useEffect(() => {
closeLog ||
@@ -224,13 +252,35 @@ const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => {
setParseContent(dom)
}
return showTag ? (
<Tags
onEdit={editMarkdown}
onDownload={downloadMarkdown}
onPrint={downloadPdf}
onParse={parseMarkdown}
/>
function onClose() {
setIsShow(false)
}
return showTag && isShow ? (
<div id="ws_cmbm" className="ws_cmbmc" style={style.box}>
<button style={style.close} onClick={onClose} aria-label="Close">
×
</button>
<img src={qrcodeUrl} alt="qrcodeUrl" style={style.img} />
<div style={style.item}>
<a onClick={editMarkdown}>编辑markdown</a>
</div>
<div style={style.item}>
<a onClick={downloadMarkdown}>下载markdown</a>
</div>
<div style={style.item}>
<a onClick={downloadPdf}>下载PDF</a>
</div>
<div style={style.item}>
<a onClick={parseMarkdown}>解析markdown</a>
</div>
<div style={style.item}>
<a onClick={() => makerQRPost()}>生成海报</a>
</div>
<a style={style.item} href="https://www.code-box.fun" target="_blank">
帮助
</a>
</div>
) : (
<></>
)
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "code-box",
"displayName": "__MSG_extensionName__",
"version": "1.2.0",
"version": "1.2.1",
"description": "__MSG_extensionDescription__",
"author": "027xiguapi. <458813868@qq.com>",
"scripts": {