perf: dark theme

This commit is contained in:
Junyan Qin
2025-08-30 17:19:16 +08:00
parent 2194b2975c
commit e701ceeeba

View File

@@ -84,18 +84,23 @@ export default function PluginDetailDialog({
className="w-16 h-16 rounded-xl border bg-gray-50 object-cover flex-shrink-0"
/>
<div className="flex-1 min-w-0">
<h1 className="text-2xl font-bold text-gray-900 mb-2">
<h1 className="text-2xl font-bold text-gray-900 mb-2 dark:text-white">
{extractI18nObject(plugin!.label) || plugin!.name}
</h1>
<div className="flex items-center gap-2 text-sm text-gray-600 mb-3">
<div className="flex items-center gap-2 text-sm text-gray-600 mb-3 dark:text-gray-400">
<Users className="w-4 h-4" />
<span>
{plugin!.author} / {plugin!.name}
</span>
</div>
<div className="flex flex-wrap items-center gap-2">
<Badge variant="outline">v{plugin!.latest_version}</Badge>
<Badge variant="outline" className="flex items-center gap-1">
<Badge variant="outline" className="dark:bg-gray-800 dark:text-white">
v{plugin!.latest_version}
</Badge>
<Badge
variant="outline"
className="flex items-center gap-1 dark:bg-gray-800 dark:text-white"
>
<Download className="w-4 h-4" />
{plugin!.install_count.toLocaleString()} {t('market.downloads')}
</Badge>
@@ -105,7 +110,7 @@ export default function PluginDetailDialog({
e.stopPropagation();
window.open(plugin!.repository, '_blank');
}}
className="flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 hover:bg-gray-200 rounded-md transition-colors"
className="flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 hover:bg-gray-200 rounded-md transition-colors dark:bg-gray-800 dark:text-white dark:hover:bg-gray-700 cursor-pointer"
>
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="currentColor">
<path d="M12.001 2C6.47598 2 2.00098 6.475 2.00098 12C2.00098 16.425 4.86348 20.1625 8.83848 21.4875C9.33848 21.575 9.52598 21.275 9.52598 21.0125C9.52598 20.775 9.51348 19.9875 9.51348 19.15C7.00098 19.6125 6.35098 18.5375 6.15098 17.975C6.03848 17.6875 5.55098 16.8 5.12598 16.5625C4.77598 16.375 4.27598 15.9125 5.11348 15.9C5.90098 15.8875 6.46348 16.625 6.65098 16.925C7.55098 18.4375 8.98848 18.0125 9.56348 17.75C9.65098 17.1 9.91348 16.6625 10.201 16.4125C7.97598 16.1625 5.65098 15.3 5.65098 11.475C5.65098 10.3875 6.03848 9.4875 6.67598 8.7875C6.57598 8.5375 6.22598 7.5125 6.77598 6.1375C6.77598 6.1375 7.61348 5.875 9.52598 7.1625C10.326 6.9375 11.176 6.825 12.026 6.825C12.876 6.825 13.726 6.9375 14.526 7.1625C16.4385 5.8625 17.276 6.1375 17.276 6.1375C17.826 7.5125 17.476 8.5375 17.376 8.7875C18.0135 9.4875 18.401 10.375 18.401 11.475C18.401 15.3125 16.0635 16.1625 13.8385 16.4125C14.201 16.725 14.5135 17.325 14.5135 18.2625C14.5135 19.6 14.501 20.675 14.501 21.0125C14.501 21.275 14.6885 21.5875 15.1885 21.4875C19.259 20.1133 21.9999 16.2963 22.001 12C22.001 6.475 17.526 2 12.001 2Z" />
@@ -120,7 +125,7 @@ export default function PluginDetailDialog({
const PluginDescription = () => (
<div className="mb-6">
<p className="text-gray-700 leading-relaxed text-base">
<p className="text-gray-700 leading-relaxed text-base dark:text-gray-400">
{extractI18nObject(plugin!.description) || t('market.noDescription')}
</p>
</div>
@@ -139,38 +144,55 @@ export default function PluginDetailDialog({
);
const ReadmeContent = () => (
<div className="prose prose-sm max-w-none text-gray-800">
<div className="prose prose-sm max-w-none text-gray-800 dark:text-gray-400">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
// 表格组件
table: ({ ...props }) => (
<div className="my-6 w-full overflow-x-auto border border-gray-200 rounded-lg">
<table className="w-full border-collapse bg-white" {...props} />
<div className="my-6 w-full overflow-x-auto rounded-lg">
<table
className="w-full border-collapse bg-white dark:bg-gray-800"
{...props}
/>
</div>
),
thead: ({ ...props }) => <thead className="bg-gray-50" {...props} />,
thead: ({ ...props }) => (
<thead
className="bg-gray-50 dark:bg-gray-900 dark:text-gray-400"
{...props}
/>
),
tbody: ({ ...props }) => (
<tbody className="divide-y divide-gray-200" {...props} />
<tbody
className="divide-y divide-gray-200 dark:divide-gray-700 dark:text-gray-400"
{...props}
/>
),
th: ({ ...props }) => (
<th
className="px-4 py-3 text-left text-sm font-semibold text-gray-900 border-r border-gray-200 last:border-r-0"
className="px-4 py-3 text-left text-sm font-semibold text-gray-900 border-r border-gray-200 last:border-r-0 dark:border-gray-700 dark:text-gray-400"
{...props}
/>
),
td: ({ ...props }) => (
<td
className="px-4 py-3 text-sm text-gray-700 border-r border-gray-200 last:border-r-0"
className="px-4 py-3 text-sm text-gray-700 border-r border-gray-200 last:border-r-0 dark:border-gray-700 dark:text-gray-400"
{...props}
/>
),
tr: ({ ...props }) => (
<tr className="hover:bg-gray-50 transition-colors" {...props} />
<tr
className="hover:bg-gray-50 transition-colors dark:hover:bg-gray-800 dark:text-gray-400"
{...props}
/>
),
// 删除线支持
del: ({ ...props }) => (
<del className="text-gray-500 line-through" {...props} />
<del
className="text-gray-500 line-through dark:text-gray-400"
{...props}
/>
),
// Todo 列表支持
input: ({ type, checked, ...props }) => {
@@ -180,23 +202,35 @@ export default function PluginDetailDialog({
type="checkbox"
checked={checked}
disabled
className="mr-2 rounded border-gray-300 text-blue-600 focus:ring-blue-500 cursor-default"
className="mr-2 rounded border-gray-300 text-blue-600 focus:ring-blue-500 cursor-default dark:border-gray-700"
{...props}
/>
);
}
return <input type={type} {...props} />;
},
ul: ({ ...props }) => <ul className="list-disc ml-5" {...props} />,
ol: ({ ...props }) => <ol className="list-decimal ml-5" {...props} />,
ul: ({ ...props }) => (
<ul className="list-disc ml-5 dark:text-gray-400" {...props} />
),
ol: ({ ...props }) => (
<ol className="list-decimal ml-5 dark:text-gray-400" {...props} />
),
li: ({ ...props }) => <li className="mb-1" {...props} />,
h1: ({ ...props }) => (
<h1 className="text-3xl font-bold my-2" {...props} />
<h1
className="text-3xl font-bold my-2 dark:text-gray-400"
{...props}
/>
),
h2: ({ ...props }) => (
<h2 className="text-2xl font-semibold mb-2 mt-4" {...props} />
<h2
className="text-2xl font-semibold mb-2 mt-4 dark:text-gray-400"
{...props}
/>
),
p: ({ ...props }) => (
<p className="leading-relaxed dark:text-gray-400" {...props} />
),
p: ({ ...props }) => <p className="leading-relaxed" {...props} />,
code: ({ className, children, ...props }) => {
const match = /language-(\w+)/.exec(className || '');
const isCodeBlock = match ? true : false;
@@ -205,7 +239,7 @@ export default function PluginDetailDialog({
if (isCodeBlock) {
return (
<code
className="bg-gray-100 text-gray-800 px-1.5 py-0.5 rounded text-sm font-mono"
className="bg-gray-100 text-gray-800 px-1.5 py-0.5 rounded text-sm font-mono dark:bg-gray-800 dark:text-gray-400"
{...props}
>
{children}
@@ -216,7 +250,7 @@ export default function PluginDetailDialog({
// 内联代码样式 - 淡灰色底
return (
<code
className="bg-gray-100 text-gray-800 px-1.5 py-0.5 rounded text-sm font-mono inline-block"
className="bg-gray-100 text-gray-800 px-1.5 py-0.5 rounded text-sm font-mono inline-block dark:bg-gray-800 dark:text-gray-400"
{...props}
>
{children}
@@ -225,7 +259,7 @@ export default function PluginDetailDialog({
},
pre: ({ ...props }) => (
<pre
className="bg-gray-100 text-gray-800 rounded-lg my-4 border border-gray-200 shadow-sm max-h-[500px] relative"
className="bg-gray-100 text-gray-800 rounded-lg my-4 shadow-sm max-h-[500px] relative dark:bg-gray-800 dark:text-gray-400"
style={{
// 内边距确保内容不被滚动条覆盖
padding: '16px',
@@ -253,12 +287,12 @@ export default function PluginDetailDialog({
{isLoading ? (
<div className="flex items-center justify-center py-12 h-full">
<Loader2 className="h-8 w-8 animate-spin" />
<span className="ml-2">{t('cloud.loading')}</span>
<span className="ml-2">{t('market.loading')}</span>
</div>
) : plugin ? (
<div className="flex flex-col h-full overflow-hidden">
{/* 插件信息区域 */}
<div className="flex-shrink-0 bg-white border-b m-4 pt-2">
<div className="flex-shrink-0 bg-white border-b m-4 pt-2 dark:bg-black">
<div className="flex gap-6 p-2 px-4">
<div className="flex-1">
<PluginHeader />
@@ -272,12 +306,12 @@ export default function PluginDetailDialog({
{/* README 区域 */}
<div className="flex-1 overflow-hidden px-8">
<div className="h-full bg-white overflow-y-auto pb-2">
<div className="h-full bg-white overflow-y-auto pb-2 dark:bg-black">
{isLoadingReadme ? (
<div className="flex items-center justify-center py-12">
<Loader2 className="h-8 w-8 animate-spin" />
<span className="ml-3 text-gray-600">
{t('cloud.loading')}
{t('market.loading')}
</span>
</div>
) : (