From 241dedcbed8a3be4db86b6f0515b3e71e7f74805 Mon Sep 17 00:00:00 2001 From: Yeban8090 Date: Sun, 13 Apr 2025 16:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=BB=84=E7=BB=87css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- esbuild.config.mjs | 33 +++++++-- src/styles/index.css | 2 + styles.css => src/styles/view/layout.css | 92 ------------------------ src/styles/view/preview.css | 22 ++++++ 5 files changed, 52 insertions(+), 99 deletions(-) create mode 100644 src/styles/index.css rename styles.css => src/styles/view/layout.css (83%) create mode 100644 src/styles/view/preview.css diff --git a/.gitignore b/.gitignore index 9e914df..4ce0cf8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ node_modules/ dist/ main.js data.json - +style.css # 操作系统文件 .DS_Store Thumbs.db diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 3d0123f..8713ab6 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -11,7 +11,7 @@ if you want to view the source, please visit the github repository of this plugi const prod = process.argv[2] === "production"; -const context = await esbuild.context({ +const config = { banner: { js: banner, }, @@ -20,19 +20,40 @@ const context = await esbuild.context({ external: [ "obsidian", "electron", + "@codemirror/autocomplete", ...builtins ], format: "cjs", - target: "es2016", + target: "es2018", logLevel: "info", sourcemap: prod ? false : "inline", treeShaking: true, outfile: "main.js", -}); +}; + +// 修改 CSS 配置部分 +const cssConfig = { + entryPoints: ['src/styles/index.css'], + bundle: true, + outfile: 'styles.css', // 直接输出到项目根目录 + allowOverwrite: true +}; if (prod) { - await context.rebuild(); - process.exit(0); + await Promise.all([ + esbuild.build(config), + esbuild.build(cssConfig) + ]).catch(() => process.exit(1)); } else { - await context.watch(); + const [jsContext, cssContext] = await Promise.all([ + esbuild.context(config), + esbuild.context(cssConfig) + ]); + + await Promise.all([ + jsContext.watch(), + cssContext.watch() + ]); + + console.log("⚡ 正在监听 JavaScript 和 CSS 变更..."); } \ No newline at end of file diff --git a/src/styles/index.css b/src/styles/index.css new file mode 100644 index 0000000..945e218 --- /dev/null +++ b/src/styles/index.css @@ -0,0 +1,2 @@ +@import url('./view/layout.css'); +@import url('./view/preview.css'); \ No newline at end of file diff --git a/styles.css b/src/styles/view/layout.css similarity index 83% rename from styles.css rename to src/styles/view/layout.css index 6443a40..869e76a 100644 --- a/styles.css +++ b/src/styles/view/layout.css @@ -231,28 +231,6 @@ display: block; } -/* ===== 预览区域 ===== */ -.mp-preview-area { - padding: 10px 20px 20px 20px; - margin: 10px; - height: calc(100% - 180px); - overflow-y: auto; - background: #fcfcfc; - flex: 1; - border-radius: 12px; - box-shadow: 0 2px 12px rgba(0, 0, 0, 0.02); - border: 1px solid rgba(82, 144, 220, 0.08); -} - -.mp-empty-message { - display: flex; - justify-content: center; - align-items: center; - height: 100%; - color: var(--text-muted); - font-size: 16px; -} - /* ===== 关于作者弹窗 ===== */ .mp-donate-overlay { position: fixed; @@ -433,74 +411,4 @@ width: 100%; height: 100%; object-fit: contain; -} - -/* ===== Markdown 内容样式 ===== */ -.mp-content-section { - min-width: 500px; - /* 链接样式 */ - a { - color: var(--text-accent); - text-decoration: none; - } - - /* 表格样式 */ - table { - border-collapse: collapse; - margin: 1em 0; - width: 100%; - } - - th, td { - border: 1px solid var(--background-modifier-border); - padding: 8px; - } - - /* 分割线样式 */ - hr { - border: none; - border-top: 1px solid var(--background-modifier-border); - margin: 20px 0; - } - - /* 删除线样式 */ - del { - text-decoration: line-through; - } - - /* 任务列表样式 */ - .task-list-item { - list-style: none; - } - - .task-list-item input[type="checkbox"] { - margin-right: 6px; - } - - /* 脚注样式 */ - .footnote-ref, - .footnote-backref { - color: var(--text-accent); - text-decoration: none; - } - - /* 代码块样式 */ - pre { - padding-top: 32px; - } - - /* 图片样式 */ - img { - max-width: 100%; - height: auto; - display: block; - margin: 1em auto; - } - - /* 引用块样式 */ - blockquote p { - margin: 0; - padding: 0; - line-height: inherit; - } } \ No newline at end of file diff --git a/src/styles/view/preview.css b/src/styles/view/preview.css new file mode 100644 index 0000000..4e65d74 --- /dev/null +++ b/src/styles/view/preview.css @@ -0,0 +1,22 @@ +/* ===== 预览区域 ===== */ +.mp-preview-area { + padding: 10px 20px 20px 20px; + margin: 10px; + height: calc(100% - 180px); + overflow-y: auto; + background: #fcfcfc; + flex: 1; + border-radius: 12px; + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.02); + border: 1px solid rgba(82, 144, 220, 0.08); +} + +.mp-empty-message { + display: flex; + justify-content: center; + align-items: center; + height: 100%; + color: var(--text-muted); + font-size: 16px; +} +