From 78b72c4e0be0aadaf271e4b2aaa7be215d5a8b2a Mon Sep 17 00:00:00 2001
From: fzk <458813868@qq.com>
Date: Fri, 19 Jul 2024 09:43:53 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E5=85=A5=E8=87=AA=E5=AE=9A=E4=B9=89?=
=?UTF-8?q?=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 12 +++++++++++-
component/content.tsx | 19 +++++++++++++++++++
component/custom.tsx | 34 ++++++++++++++++++++++++++++++++++
contents/custom.tsx | 22 ++++++++++++++++++++++
contents/jb51.tsx | 8 ++------
index.css | 35 +++++++++++++++++++++++++++++------
options.tsx | 16 +++-------------
package.json | 6 +++---
popup.tsx | 16 +++-------------
tools.ts | 12 ++++++++++--
10 files changed, 136 insertions(+), 44 deletions(-)
create mode 100644 component/content.tsx
create mode 100644 component/custom.tsx
create mode 100644 contents/custom.tsx
diff --git a/README.md b/README.md
index 2106922..cd6888e 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,13 @@ https://github.com/027xiguapi/code-box

-### 安装方式二:源码安装
+### 安装方式二:安装包
+
+1. 下载地址: https://github.com/027xiguapi/code-box/releases
+2. 谷歌浏览器,从右上角菜单->更多工具->扩展程序可以进入插件管理页面,也可以直接在地址栏输入 chrome://extensions 访问
+3. 勾选开发者模式,即可以文件夹的形式直接加载插件
+
+### 安装方式三:源码安装
1. clone源码
```sh
@@ -41,6 +47,10 @@ https://github.com/027xiguapi/code-box

+### 自定义
+
+1. 插入自定义样式(css代码)
+
### CSDN
1. 打开任意一个`CSDN`博客即可开始复制代码
diff --git a/component/content.tsx b/component/content.tsx
new file mode 100644
index 0000000..19bf788
--- /dev/null
+++ b/component/content.tsx
@@ -0,0 +1,19 @@
+import Cnblogs from "./cnblogs"
+import Csdn from "./csdn"
+import Custom from "./custom"
+import Jb51 from "./jb51"
+import Jianshu from "./jianshu"
+import Zhihu from "./zhihu"
+
+export default function Content() {
+ return (
+ <>
+
+
+
+
+
+
+ >
+ )
+}
diff --git a/component/custom.tsx b/component/custom.tsx
new file mode 100644
index 0000000..2f19df4
--- /dev/null
+++ b/component/custom.tsx
@@ -0,0 +1,34 @@
+import { useStorage } from "@plasmohq/storage/hook"
+
+export default function Custom() {
+ const [runCss, setRunCss] = useStorage("custom-runCss", (v) =>
+ v === undefined ? false : v
+ )
+ const [cssCode, setCssCode] = useStorage("custom-cssCode", (v) =>
+ v === undefined ? "" : v
+ )
+
+ return (
+
+ )
+}
diff --git a/contents/custom.tsx b/contents/custom.tsx
new file mode 100644
index 0000000..7ee9c75
--- /dev/null
+++ b/contents/custom.tsx
@@ -0,0 +1,22 @@
+import { useEffect } from "react"
+
+import { useStorage } from "@plasmohq/storage/hook"
+
+import { addCss } from "~tools"
+
+export default function Custom() {
+ const [runCss] = useStorage("custom-runCss")
+ const [cssCode] = useStorage("custom-cssCode")
+
+ useEffect(() => {
+ runCss && runCssFunc()
+ }, [runCss])
+
+ /* 插入自定义css代码 */
+ function runCssFunc() {
+ console.log("插入自定义css代码", cssCode)
+ addCss(cssCode)
+ }
+
+ return
+}
diff --git a/contents/jb51.tsx b/contents/jb51.tsx
index fcd5336..206f5b5 100644
--- a/contents/jb51.tsx
+++ b/contents/jb51.tsx
@@ -18,14 +18,10 @@ export default function jb51() {
const [copyCode] = useStorage("jb51-copyCode")
useEffect(() => {
- console.log("jb51 closeAds", closeAds)
+ console.log("jb51 status", { closeAds, copyCode })
closeAds && closeAdsFunc()
- }, [closeAds])
-
- useEffect(() => {
- console.log("jb51 copyCode", copyCode)
copyCode && copyCodeFunc()
- }, [copyCode])
+ }, [closeAds, copyCode])
/* 未登录复制代码 */
function copyCodeCssFunc() {
diff --git a/index.css b/index.css
index b90f1ea..029a2df 100644
--- a/index.css
+++ b/index.css
@@ -1,5 +1,20 @@
+* {
+ margin: 0;
+ padding: 0;
+}
+
+.hide {
+ display: none !important;
+}
+
+.show {
+ display: block !important;
+}
+
.App {
- width: 160px;
+ width: 190px;
+ margin: 0 auto;
+ padding: 5px 8px;
}
.App-header .title {
@@ -18,6 +33,10 @@
font-size: 14px;
}
+.App-body fieldset {
+ padding: 5px 8px;
+}
+
.App-body fieldset .item {
display: flex;
justify-content: space-between;
@@ -26,12 +45,16 @@
font-size: 12px;
}
+.App-body fieldset .item textarea {
+ padding: 5px;
+}
+
/*开关*/
-.codebox-offscreen{
+.codebox-offscreen {
display: none;
}
-.codebox-switch{
+.codebox-switch {
position: relative;
display: inline-block;
width: 40px;
@@ -41,7 +64,7 @@
transition: all 0.3s;
}
-.codebox-switch::after{
+.codebox-switch::after {
content: "";
position: absolute;
width: 18px;
@@ -53,10 +76,10 @@
transition: all 0.3s;
}
-input[type="checkbox"]:checked+.codebox-switch::after{
+input[type="checkbox"]:checked + .codebox-switch::after {
transform: translateX(20px);
}
-input[type="checkbox"]:checked+.codebox-switch{
+input[type="checkbox"]:checked + .codebox-switch {
background-color: #7983ff;
}
\ No newline at end of file
diff --git a/options.tsx b/options.tsx
index c0d0ab2..fe05664 100644
--- a/options.tsx
+++ b/options.tsx
@@ -1,12 +1,8 @@
-import Cnblogs from "./component/cnblogs"
-import Csdn from "./component/csdn"
-import Jb51 from "./component/jb51"
-import Jianshu from "./component/jianshu"
-import Zhihu from "./component/zhihu"
+import Content from "./component/content"
import "./index.css"
-function IndexOptions() {
+export default function IndexOptions() {
return (