重新组织css

This commit is contained in:
Yeban8090 2025-04-13 16:13:29 +08:00
parent e0ec425ffb
commit 241dedcbed
5 changed files with 52 additions and 99 deletions

2
.gitignore vendored
View file

@ -5,7 +5,7 @@ node_modules/
dist/
main.js
data.json
style.css
# 操作系统文件
.DS_Store
Thumbs.db

View file

@ -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 变更...");
}

2
src/styles/index.css Normal file
View file

@ -0,0 +1,2 @@
@import url('./view/layout.css');
@import url('./view/preview.css');

View file

@ -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;
}
}

View file

@ -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;
}