Skip to content

Let's use AI to Earn!

md2 card

bulaienaofutuojsonzhang82cdf1d2cfd7
diff --git a/src/app/[lng]/material/ai-generate/ai-generate.module.scss b/src/app/[lng]/material/ai-generate/ai-generate.module.scss
index 124f16e8..277f81be 100644
--- a/src/app/[lng]/material/ai-generate/ai-generate.module.scss
+++ b/src/app/[lng]/material/ai-generate/ai-generate.module.scss
@@ -319,6 +319,19 @@
gap: 16px;
}
+// 调整复选框标签为小字、同一行对齐
+.options label {
+ font-size: 12px;
+ color: #666;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ white-space: nowrap;
+}
+.options label input[type="checkbox"] {
+ margin: 0;
+}
+
.polling {
margin-top: 16px;
text-align: center;
@@ -357,99 +370,36 @@
}
.imageCard { position: relative; width: 100%; border-radius: 8px; overflow: hidden; }
-.imageCard img { width: 100%; height: 100%; object-fit: cover; display: block; }
+.imageCard img { width: 100%; height: 100%; max-height: 100vh; object-fit: cover; display: block; }
.imageActions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
// 模板选择网格
.templateGrid {
display: flex;
- gap: 12px;
- overflow-x: auto;
+ flex-wrap: wrap;
+ gap: 8px;
padding: 4px 0;
- scrollbar-width: thin;
- scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
-
- &::-webkit-scrollbar {
- height: 6px;
- }
-
- &::-webkit-scrollbar-track {
- background: transparent;
- }
-
- &::-webkit-scrollbar-thumb {
- background: rgba(0, 0, 0, 0.2);
- border-radius: 3px;
- }
-
- &::-webkit-scrollbar-thumb:hover {
- background: rgba(0, 0, 0, 0.3);
- }
}
.templateCard {
- border: 2px solid rgba(0, 0, 0, 0.08);
- border-radius: 10px;
- overflow: hidden;
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ border: 1px solid rgba(0, 0, 0, 0.08);
+ border-radius: 8px;
background: #fff;
cursor: pointer;
- transition: all 0.2s ease;
- box-shadow: 0 2px 8px rgba(0,0,0,0.06);
- flex-shrink: 0;
- width: 160px;
-
- &:hover {
- transform: translateY(-2px);
- box-shadow: 0 6px 20px rgba(0,0,0,0.12);
- }
-}
-
-.templateCardActive {
- border-color: var(--theColor5) !important;
- box-shadow: 0 0 0 3px rgba(166, 106, 228, 0.2), 0 4px 12px rgba(166, 106, 228, 0.15) !important;
- transform: translateY(-1px);
- position: relative;
-
- &::after {
- content: '';
- position: absolute;
- top: -2px;
- left: -2px;
- right: -2px;
- bottom: -2px;
- border: 2px solid var(--theColor5);
-
- pointer-events: none;
- animation: pulse 2s infinite;
- }
+ transition: all 0.15s ease;
+ padding: 6px 10px;
}
-.templateThumb {
- position: relative;
- width: 100%;
- /* 维持 800x500 比例 = 5:3 */
- padding-top: 62.5%;
- background: #f6f7f9;
+.templateCard:hover { border-color: var(--theColor5); box-shadow: 0 2px 10px rgba(166,106,228,.12); }
+.templateCardActive { background: rgba(166,106,228,.12); border-color: var(--theColor5); }
- img {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
-}
+.templateThumb { width: 22px; height: 22px; border-radius: 4px; overflow: hidden; background: #f6f7f9; display: flex; align-items: center; justify-content: center; }
+.templateThumb img { width: 100%; height: 100%; object-fit: cover; }
-.templateLabel {
- padding: 10px 12px;
- font-size: 13px;
- color: #444;
- text-align: left;
- font-weight: 500;
- background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
- border-top: 1px solid rgba(0, 0, 0, 0.05);
-}
+.templateLabel { font-size: 12px; color: #444; font-weight: 500; }
@keyframes fadeIn {
from {
diff --git a/src/app/[lng]/material/ai-generate/page.tsx b/src/app/[lng]/material/ai-generate/page.tsx
index c3ac6b1a..0970adcf 100644
--- a/src/app/[lng]/material/ai-generate/page.tsx
+++ b/src/app/[lng]/material/ai-generate/page.tsx
@@ -506,73 +506,95 @@ export default function AIGeneratePage() {
)}
{activeImageTab === 'textToFireflyCard' && (
- <div className={styles.section}>
- <div className={styles.form}>
- <Input placeholder={t("aiGenerate.titlePlaceholder")} value={title} onChange={(e)=>setTitle(e.target.value)} prefix={<FileTextOutlined />} />
- <TextArea placeholder={t("aiGenerate.contentPlaceholder")} value={content} onChange={(e)=>setContent(e.target.value)} rows={4} />
- <div className={styles.templateGrid}>
- {templateList.map((item)=> (
- <div key={item.key} className={`${styles.templateCard} ${temp===item.key?styles.templateCardActive:""}`} onClick={()=>setTemp(item.key)}>
- <div className={styles.templateThumb}><img src={`${TEMPLATE_BASE}/${item.key}.png`} alt={`${t('aiGenerate.template')} ${item.name}`} /></div>
- <div className={styles.templateLabel}>{item.name}</div>
+ <div className={styles.section}>
+ <div className={styles.twoColumn}>
+ <div className={styles.leftPanel}>
+ <div className={styles.blockTitle}>{t('aiGenerate.fireflyCard')}</div>
+ <Input placeholder={t("aiGenerate.titlePlaceholder")} value={title} onChange={(e)=>setTitle(e.target.value)} prefix={<FileTextOutlined />} />
+ <TextArea placeholder={t("aiGenerate.contentPlaceholder")} value={content} onChange={(e)=>setContent(e.target.value)} rows={4} />
+ <div className={styles.templateGrid}>
+ {templateList.map((item)=> (
+ <div key={item.key} className={`${styles.templateCard} ${temp===item.key?styles.templateCardActive:""}`} onClick={()=>setTemp(item.key)}>
+ <div className={styles.templateThumb}><img src={`${TEMPLATE_BASE}/${item.key}.png`} alt={`${t('aiGenerate.template')} ${item.name}`} /></div>
+ <div className={styles.templateLabel}>{item.name}</div>
+ </div>
+ ))}
+ </div>
+ <Button type="primary" onClick={handleTextToFireflyCard} loading={loadingFirefly} disabled={!content||!title} icon={<FireOutlined />}>{t("aiGenerate.generate")}</Button>
+ </div>
+ <div className={styles.rightPanel}>
+ {fireflyResult && (
+ <div className={styles.result}>
+ <div className={styles.imageCard}>
+ <img src={getOssUrl(fireflyResult)} alt={t('aiGenerate.fireflyCard')} />
+ <div className={styles.imageActions}>
+ <Button size="small" icon={<DownloadOutlined />} onClick={()=>handleDownloadUrl(fireflyResult)} />
+ <Button size="small" type="primary" icon={<UploadOutlined />} onClick={()=>handleUploadToMediaGroup('img', fireflyResult)} />
+ </div>
+ </div>
+ </div>
+ )}
</div>
- ))}
- </div>
- <Button type="primary" onClick={handleTextToFireflyCard} loading={loadingFirefly} disabled={!content||!title} icon={<FireOutlined />}>{t("aiGenerate.generate")}</Button>
- </div>
- {fireflyResult && (
- <div className={styles.result}>
- <div style={{ display:'flex', flexDirection:'column', gap:10 }}>
- <img src={getOssUrl(fireflyResult)} alt={t('aiGenerate.fireflyCard')} style={{ maxWidth:'100%', borderRadius:8 }} />
- <Button type="primary" onClick={()=>handleUploadToMediaGroup('img')} icon={<UploadOutlined />} style={{ padding:'1px' }}>{t("aiGenerate.uploadToMediaGroup")}</Button>
</div>
</div>
)}
- </div>
- )}
{activeImageTab === 'md2card' && (
- <div className={styles.section}>
- <div className={styles.form}>
- <TextArea placeholder={t("aiGenerate.markdownPlaceholder")} value={markdownContent} onChange={(e)=>setMarkdownContent(e.target.value)} rows={8} />
- <div className={styles.dimensions}>
- <Select value={themeMode} onChange={setThemeMode} style={{ width: "100%" }}>
- <Option value="light">{t("aiGenerate.lightMode")}</Option>
- <Option value="dark">{t("aiGenerate.darkMode")}</Option>
- </Select>
- </div>
- <div className={styles.templateGrid}>
- {md2CardTemplates.map((theme)=> (
- <div key={theme.id} className={`${styles.templateCard} ${selectedTheme===theme.id?styles.templateCardActive:""}`} onClick={()=>setSelectedTheme(theme.id)}>
- <div className={styles.templateThumb}><img src={theme.preview} alt={isEnglishLang ? theme.nameEn : theme.nameCn} /></div>
- <div className={styles.templateLabel}>{isEnglishLang ? theme.nameEn : theme.nameCn}</div>
+ <div className={styles.section}>
+ <div className={styles.twoColumn}>
+ <div className={styles.leftPanel}>
+ <div className={styles.blockTitle}>{t('aiGenerate.markdownToCard')}</div>
+ <TextArea style={{ height: 100 }} placeholder={t("aiGenerate.markdownPlaceholder")} value={markdownContent} onChange={(e)=>setMarkdownContent(e.target.value)} rows={8} />
+ <div className={styles.dimensions}>
+ <Select value={themeMode} onChange={setThemeMode} style={{ width: "100%" }}>
+ <Option value="light">{t("aiGenerate.lightMode")}</Option>
+ <Option value="dark">{t("aiGenerate.darkMode")}</Option>
+ </Select>
+ </div>
+ <div className={styles.templateGrid}>
+ {md2CardTemplates.map((theme)=> (
+ <div key={theme.id} className={`${styles.templateCard} ${selectedTheme===theme.id?styles.templateCardActive:""}`} onClick={()=>setSelectedTheme(theme.id)}>
+ <div className={styles.templateThumb}><img src={theme.preview} alt={isEnglishLang ? theme.nameEn : theme.nameCn} /></div>
+ <div className={styles.templateLabel}>{isEnglishLang ? theme.nameEn : theme.nameCn}</div>
+ </div>
+ ))}
+ </div>
+ <div className={styles.options}>
+ <Input placeholder={t("aiGenerate.cardWidthPlaceholder")} type="number" value={cardWidth} onChange={(e)=>setCardWidth(Number(e.target.value))} style={{ width: "100%" }} />
+ <Input placeholder={t("aiGenerate.cardHeightPlaceholder")} type="number" value={cardHeight} onChange={(e)=>setCardHeight(Number(e.target.value))} style={{ width: "100%" }} />
+ </div>
+ <div className={styles.options}>
+ <Select value={splitMode} onChange={setSplitMode} style={{ width: "100%" }}>
+ <Option value="noSplit">{t("aiGenerate.noSplit")}</Option>
+ <Option value="split">{t("aiGenerate.split")}</Option>
+ </Select>
+ <div style={{ display:"flex", gap:8, alignItems:"center" }}>
+ <label><input type="checkbox" checked={mdxMode} onChange={(e)=>setMdxMode(e.target.checked)} /> {t("aiGenerate.mdxMode")}</label>
+ <label><input type="checkbox" checked={overHiddenMode} onChange={(e)=>setOverHiddenMode(e.target.checked)} /> {t("aiGenerate.overHiddenMode")}</label>
</div>
- ))}
- </div>
- <div className={styles.options}>
- <Input placeholder={t("aiGenerate.cardWidthPlaceholder")} type="number" value={cardWidth} onChange={(e)=>setCardWidth(Number(e.target.value))} style={{ width: "100%" }} />
- <Input placeholder={t("aiGenerate.cardHeightPlaceholder")} type="number" value={cardHeight} onChange={(e)=>setCardHeight(Number(e.target.value))} style={{ width: "100%" }} />
- </div>
- <div className={styles.options}>
- <Select value={splitMode} onChange={setSplitMode} style={{ width: "100%" }}>
- <Option value="noSplit">{t("aiGenerate.noSplit")}</Option>
- <Option value="split">{t("aiGenerate.split")}</Option>
- </Select>
- <div style={{ display:"flex", gap:8, alignItems:"center" }}>
- <label><input type="checkbox" checked={mdxMode} onChange={(e)=>setMdxMode(e.target.checked)} /> {t("aiGenerate.mdxMode")}</label>
- <label><input type="checkbox" checked={overHiddenMode} onChange={(e)=>setOverHiddenMode(e.target.checked)} /> {t("aiGenerate.overHiddenMode")}</label>
</div>
+ <Button type="primary" onClick={handleMd2CardGeneration} loading={loadingMd2Card} disabled={!markdownContent} icon={<FileTextOutlined />}>{t("aiGenerate.generateCard")}</Button>
</div>
- <Button type="primary" onClick={handleMd2CardGeneration} loading={loadingMd2Card} disabled={!markdownContent} icon={<FileTextOutlined />}>{t("aiGenerate.generateCard")}</Button>
- </div>
- {md2CardResult && (
- <div className={styles.result}>
- <div style={{ display:'flex', flexDirection:'column', gap:10 }}>
- <img src={getOssUrl(md2CardResult)} alt={t('aiGenerate.markdownCard')} style={{ maxWidth:'100%', borderRadius:8 }} />
- <Button type="primary" onClick={()=>handleUploadToMediaGroup('img')} icon={<UploadOutlined />} style={{ padding:'1px' }}>{t("aiGenerate.uploadToMediaGroup")}</Button>
+ <div className={styles.rightPanel}>
+ <div className={styles.result}>
+ <div className={styles.imageCard}>
+ {md2CardResult ? (
+ <img src={getOssUrl(md2CardResult)} alt={t('aiGenerate.markdownCard')} />
+ ) : (
+ (() => { const theme = md2CardTemplates.find((t)=>t.id===selectedTheme); return (
+ <img src={theme?.preview} alt={isEnglishLang ? theme?.nameEn : theme?.nameCn} />
+ ); })()
+ )}
+ {md2CardResult && (
+ <div className={styles.imageActions}>
+ <Button size="small" icon={<DownloadOutlined />} onClick={()=>handleDownloadUrl(md2CardResult)} />
+ <Button size="small" type="primary" icon={<UploadOutlined />} onClick={()=>handleUploadToMediaGroup('img', md2CardResult)} />
+ </div>
+ )}
+ </div>
</div>
+ </div>
</div>
- )}
</div>
)}
</>