diff --git a/SinkDark/article/apps.py b/SinkDark/article/apps.py index cb9626d..2bc48aa 100644 --- a/SinkDark/article/apps.py +++ b/SinkDark/article/apps.py @@ -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模块以注册信号处理器 - diff --git a/SinkDark/article/models.py b/SinkDark/article/models.py index db8d511..b18762c 100644 --- a/SinkDark/article/models.py +++ b/SinkDark/article/models.py @@ -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 diff --git a/SinkDark/article/signals.py b/SinkDark/article/signals.py index 409495f..e69de29 100644 --- a/SinkDark/article/signals.py +++ b/SinkDark/article/signals.py @@ -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'])""" diff --git a/SinkDark/publicStatic/css/base.css b/SinkDark/publicStatic/css/base.css index ac5e153..a53649d 100644 --- a/SinkDark/publicStatic/css/base.css +++ b/SinkDark/publicStatic/css/base.css @@ -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 } diff --git a/SinkDark/publicStatic/css/index.css b/SinkDark/publicStatic/css/index.css index e02cdd1..16f3856 100644 --- a/SinkDark/publicStatic/css/index.css +++ b/SinkDark/publicStatic/css/index.css @@ -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; } diff --git a/SinkDark/publicStatic/css/m.css b/SinkDark/publicStatic/css/m.css index 84b1195..e396680 100644 --- a/SinkDark/publicStatic/css/m.css +++ b/SinkDark/publicStatic/css/m.css @@ -1,4 +1,4 @@ -@charset "gb2312"; +@charset "UTF-8"; @media screen and (min-width: 1024px) and (max-width: 1199px) { header { width: 96%; margin: auto } } diff --git a/SinkDark/templates/base.html b/SinkDark/templates/base.html index 53cb41b..7cfc454 100644 --- a/SinkDark/templates/base.html +++ b/SinkDark/templates/base.html @@ -71,10 +71,10 @@ -