主体部分好了

This commit is contained in:
跨越晨昏 2024-09-28 19:20:01 +08:00
parent f59a0f67b6
commit 6a5e7d7f00
7 changed files with 23 additions and 39 deletions

View File

@ -4,7 +4,3 @@ from django.apps import AppConfig
class ArticleConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'article'
def ready(self):
from . import signals # 导入signals模块以注册信号处理器

View File

@ -32,9 +32,9 @@ class ArticleInfo(models.Model):
article_tag = models.ManyToManyField(ArticleTag, blank=True, verbose_name='文章标签')
def save(self, *args, **kwargs):
# 可以在这里直接更新rendered字段,但使用信号更灵活
self.rendered = CrossDown.main(self.content)
super().save(*args, **kwargs)
# 可以在这里直接更新rendered字段
self.rendered = CrossDown.main(self.content) # 渲染md
super().save(*args, **kwargs) # 保存
def __str__(self):
return self.title

View File

@ -1,15 +0,0 @@
from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import ArticleInfo
import CrossDown
@receiver(post_save, sender=ArticleInfo)
def article_signal_handler(sender, instance, created, **kwargs):
if created:
# 这里执行你希望在文章创建后自动执行的函数
# 例如:
print("文章已创建,执行特定函数...")
"""if instance.content:
instance.rendered = instance.content
instance.save(update_fields=['rendered'])"""

View File

@ -38,13 +38,14 @@ a:hover { text-decoration: none; color: #000; }
}
.r_box {
/* 中间主体内容样式这里不需要特别指定宽度因为Grid已经分配了空间 */
}
.rt_box {
/* 右侧内容样式 */
}
main { overflow: hidden; width: 68%; float: right; display: block; }
.main {
overflow: hidden;
width: 68%;
margin: 0 auto; /* 添加左右自动外边距以实现水平居中 */
display: block; /* 已经是默认值,但保持清晰 */
}
.container { width: 1000px; margin: auto }
nav { width: 1000px; margin: auto }
.logo { float: left; font-size: 22px }

View File

@ -12,18 +12,20 @@
.tuijian li { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; margin-bottom: 5px; background: url(../images/li.png) left center no-repeat; padding-left: 20px }
.links a { display: block; float: left; margin: 0 10px 5px 0 }
.guanzhu img { width: 100% }
.tools a { display: block; float: left; margin: 0 10px 5px 0 }
.l_box .search { border: 1px solid #000; background: #000; border-radius: 0 5px 5px 0; position: relative; }
.search input.input_submit { border: 0; background: 0; color: #fff; outline: none; position: absolute; top: 10px; right: 8% }
.search input.input_text { border: 0; line-height: 36px; height: 36px; width: 72%; padding-left: 10px; outline: none }
.r_box li { background: rgba(255,255,255,0.8); padding: 15px; overflow: hidden; color: #797b7c; margin-bottom: 20px }
.r_box li h3 { font-size: 16px; line-height: 25px; text-shadow: #FFF 1px 1px 1px }
.r_box li h3 a { color: #222 }
.r_box li h3 a:hover { color: #000; text-decoration: underline }
.r_box li img { float: right; clear: right; width: 100%;height:100%; -webkit-transition: all 0.5s; -moz-transition: all 0.5s; transition: all 0.5s; }
.r_box li i { width: 150px; display: block; max-height: 100px; overflow: hidden; float: right; margin-left: 20px }
.r_box li p { margin: 20px 0 0 0; line-height: 22px; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 2; }
.r_box li:hover img { transform: scale(1.05) }
.r_box li:hover h3 a { color: #19585d; }
.rt_box .search { border: 1px solid #000; background: #000; border-radius: 0 5px 5px 0; position: relative; }
.main li { background: rgba(255,255,255,0.8); padding: 15px; overflow: hidden; color: #797b7c; margin-bottom: 20px }
.main li h3 { font-size: 16px; line-height: 25px; text-shadow: #FFF 1px 1px 1px }
.main li h3 a { color: #222 }
.main li h3 a:hover { color: #000; text-decoration: underline }
.main li img { float: right; clear: right; width: 100%;height:100%; -webkit-transition: all 0.5s; -moz-transition: all 0.5s; transition: all 0.5s; }
.main li i { width: 150px; display: block; max-height: 100px; overflow: hidden; float: right; margin-left: 20px }
.main li p { margin: 20px 0 0 0; line-height: 22px; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 2; }
.main li:hover img { transform: scale(1.05) }
.main li:hover h3 a { color: #19585d; }
.pagelist { text-align: center; color: #666; width: 100%; clear: both; margin: 20px 0; padding-top: 20px }
.pagelist a { color: #666; margin: 0 2px 5px 2px; display: inline-block; border: 1px solid #fff; padding: 5px 10px; background: #FFF }
.pagelist a:hover { color: #19585d; }

View File

@ -1,4 +1,4 @@
@charset "gb2312";
@charset "UTF-8";
@media screen and (min-width: 1024px) and (max-width: 1199px) {
header { width: 96%; margin: auto }
}

View File

@ -71,10 +71,10 @@
</ul>
</div>
</div>
<div class="m_box">
<div class="main">
{% block content %}{% endblock %}
</div>
<div class="r_box">
<div class="rt_box">
<div class="tools">
<h2>小工具</h2>
<ul>