更新1.2.2 详情查看readme文件

This commit is contained in:
小钊 2025-06-23 23:59:18 +08:00
parent b0198b246c
commit e1249f8529
45 changed files with 337 additions and 43 deletions

View File

@ -35,6 +35,7 @@ INSTALLED_APPS = [
'home',
'api',
'comment',
'siteconfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',

View File

@ -4,15 +4,21 @@
Django、simpleui、python3
# 目录结构描述
├── ReadMe.md // 帮助文档
├── home // 文章相关app
├── api // 项目api
├── comment // 评论app
└── Echo-Z // 项目配置等目录
├── api // 项目api
├── comment // 评论app
├── Echo-Z // 项目配置等目录
├── home // 文章相关app
├── db.sqlite3 // 项目数据库
├── manage.py // 项目管理主文件
├── ReadMe.md // 帮助文档
└── requirements.txt // 项目依赖库列表
# 使用说明
运行命令安装依赖
@ -45,3 +51,9 @@ python manage.py runserver 9999
2.文章详情页评论列表显示
3.文章详情页评论发布
4.文章详情页点赞与取消点赞
###### 1.2.2
2025年6月23日
新增
1.友联管理
2.站点设置

Binary file not shown.

View File

@ -4,13 +4,13 @@ from django.shortcuts import render,HttpResponse
from django.http import JsonResponse,HttpResponseNotAllowed,HttpResponseRedirect,JsonResponse
from django.views.decorators.http import require_http_methods
from comment.models import comment
from comment.models import *
from home.models import *
# Create your views here.
@require_http_methods(["POST"])
def add_comment(request, id):
create_comment = comment.objects.create(comment_Content=request.POST.get("comment"),comment_User=request.POST.get("username"), comment_Time=datetime.now(), archives_Id=id, qq=request.POST.get("qqNum"))
create_comment = Comment.objects.create(comment_Content=request.POST.get("comment"),comment_User=request.POST.get("username"), comment_Time=datetime.now(), archives_Id=id, qq=request.POST.get("qqNum"))
create_comment.save()
return HttpResponseRedirect("/archives/"+id)

View File

@ -1,7 +1,7 @@
from django.contrib import admin
from comment.models import comment
from comment.models import Comment
# Register your models here.
@admin.register(comment)
@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
list_display = ["comment_Content","comment_User","comment_Time", "archives_Id"]
list_display = ["comment_content","comment_user","comment_time", "archives_id"]

View File

@ -0,0 +1,17 @@
# Generated by Django 4.2.23 on 2025-06-23 03:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('comment', '0003_comment_qq_alter_comment_archives_id'),
]
operations = [
migrations.AlterModelTable(
name='comment',
table='Comment',
),
]

View File

@ -0,0 +1,33 @@
# Generated by Django 4.2.23 on 2025-06-23 03:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('comment', '0004_alter_comment_table'),
]
operations = [
migrations.RenameField(
model_name='comment',
old_name='archives_Id',
new_name='archives_id',
),
migrations.RenameField(
model_name='comment',
old_name='comment_Content',
new_name='comment_content',
),
migrations.RenameField(
model_name='comment',
old_name='comment_Time',
new_name='comment_time',
),
migrations.RenameField(
model_name='comment',
old_name='comment_User',
new_name='comment_user',
),
]

View File

@ -1,11 +1,11 @@
from django.db import models
# Create your models here.
class comment(models.Model):
comment_Content = models.TextField(verbose_name="评论内容")
comment_User = models.CharField(max_length=100,verbose_name="评论者")
comment_Time = models.DateTimeField(verbose_name="评论时间")
archives_Id = models.IntegerField(default=0, verbose_name="文章id")
class Comment(models.Model):
comment_content = models.TextField(verbose_name="评论内容")
comment_user = models.CharField(max_length=100,verbose_name="评论者")
comment_time = models.DateTimeField(verbose_name="评论时间")
archives_id = models.IntegerField(default=0, verbose_name="文章id")
qq = models.IntegerField(default=1000, verbose_name="评论者qq号")
def __str__(self):
@ -13,4 +13,5 @@ class comment(models.Model):
class Meta:
verbose_name = "评论"
verbose_name_plural = "评论管理"
verbose_name_plural = "评论管理"
db_table = "Comment"

Binary file not shown.

View File

@ -0,0 +1,21 @@
# Generated by Django 4.2.23 on 2025-06-23 03:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0005_articleslike'),
]
operations = [
migrations.AlterModelTable(
name='articles',
table='Articles',
),
migrations.AlterModelTable(
name='articleslike',
table='ArticlesLike',
),
]

View File

@ -16,6 +16,7 @@ class Articles(models.Model):
class Meta:
verbose_name = "文章"
verbose_name_plural = "文章管理"
db_table = "Articles"
def __str__(self):
return self.title
@ -27,6 +28,7 @@ class ArticlesLike(models.Model):
class Meta:
verbose_name = "点赞"
verbose_name_plural = "点赞管理"
db_table = "ArticlesLike"
def __str__(self):
return self.uuid

View File

@ -125,7 +125,7 @@
const active_path = "M736 128c-65.952 0-128.576 25.024-176.384 70.464-4.576 4.32-28.672 28.736-47.328 47.68L464.96 199.04C417.12 153.216 354.272 128 288 128 146.848 128 32 242.848 32 384c0 82.432 41.184 144.288 76.48 182.496l316.896 320.128C450.464 911.68 478.304 928 512 928s61.568-16.32 86.752-41.504l316.736-320 2.208-2.464C955.904 516.384 992 471.392 992 384c0-141.152-114.848-256-256-256z"
const path = document.getElementById('link_svg');
const fpPromise = import('{% static "aaa.js" %}').then(FingerprintJS => FingerprintJS.load());
const fpPromise = import('{% static "FingerprintJS.js" %}').then(FingerprintJS => FingerprintJS.load());
fpPromise.then(fp => fp.get()).then(result => {localStorage.setItem("uuid",result.visitorId)});
document.addEventListener('DOMContentLoaded', function() {

View File

@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block sitename %}
<title>我的个人博客</title>
<title>{{ site_config.title }}</title>
{% endblock %}
<link rel="stylesheet" href="{% static 'bottom.css' %}">
{% block stylesheethref %}
@ -16,7 +16,7 @@
<!-- 头部 -->
<header>
<div class="container header-content">
<div class="logo"><a href="/">我的博客</a></div>
<div class="logo"><a href="/">{{ site_config.title }}</a></div>
<nav class="nav-links">
<a href="#">前端技术</a>
@ -32,8 +32,8 @@
</div>
<div class="profile">
<span>欢迎回来</span>
<img src="http://iph.href.lu/50x50?text=正在开发中" alt="个人头像" class="profile-img">
<span>{{ site_config.site_author_name }}</span>
<img src="http://q1.qlogo.cn/g?b=qq&nk={{ site_config.site_author_qq }}&s=100" alt="个人头像" class="profile-img">
</div>
</div>
</header>
@ -67,27 +67,28 @@
<div class="footer-section">
<h3>友情链接</h3>
<div class="footer-links">
<a href="#">GitHub</a>
<a href="#">Stack Overflow</a>
<a href="#">MDN Web Docs</a>
<a href="#">掘金</a>
<a href="#">知乎</a>
{% for FriendshipLink in FriendshipLinks %}
<a href="{{ FriendshipLink.link }}">{{ FriendshipLink.name }}</a>
{% endfor %}
</div>
</div>
<div class="footer-section">
<h3>联系我们</h3>
<div class="footer-links">
<a href="mailto:example@example.com">email@example.com</a>
<a href="#">GitHub</a>
<a href="#">Twitter</a>
<a href="#">微信公众号</a>
<a href="mailto:{{ site_config.site_author_email }}">{{ site_config.site_author_email }}</a>
{% if github %}
<a href="#">GitHub</a>
{% endif %}
{% if github %}
<a href="#">微信公众号</a>
{% endif %}
</div>
</div>
</div>
<div class="copyright">
<p>© 2023 我的个人博客 版权所有 | 粤ICP备12345678号</p>
<p>© 2025 {{ site_config.title }} 版权所有 | <a href="https://beian.miit.gov.cn/" style="color: #bdc3c7">{{ site_config.icp }}</a></p>
</div>
</div>
</footer>

View File

@ -1,12 +1,34 @@
from django.shortcuts import render, HttpResponse
from home.models import *
from comment.models import comment
from comment.models import *
from siteconfig.models import *
# Create your views here.
def get_site_config():
siteconf = SiteConfig.objects.all()[0]
siteconfig = {
'title': siteconf.site_name,
'site_author_name': siteconf.site_author_name,
'site_author_qq': siteconf.site_author_qq,
"site_author_email": siteconf.site_author_email,
"icp": siteconf.icp,
}
return siteconfig
def get_friendship_links():
friendship_links = []
FriendshipLinks = FriendshipLink.objects.all()
for link in FriendshipLinks:
friendship_links.append({"link": link.friendship_site_link,"name": link.friendship_site_name})
return friendship_links
def index(request):
artchle = Articles.objects.all()
artchles = {"artchles": []}
artchles = {
"artchles": [],
"site_config": get_site_config(),
"FriendshipLinks": get_friendship_links()
}
for i in artchle:
a = {
"id":i.id,
@ -14,9 +36,10 @@ def index(request):
"abstract": i.abstract,
"created": i.created,
"stat": i.stat,
"read": i.read
"read": i.read,
}
artchles["artchles"].append(a)
return render(request, 'index.html', context=artchles)
@ -30,7 +53,7 @@ def archives(request, id):
next_article = Articles.objects.filter(id__gt=id).order_by('id').first()
next_id = next_article.id if next_article else id
next_id_title = next_article.title if next_article else "暂无下一篇"
comments = comment.objects.filter(archives_Id=id).order_by("-comment_Time").all()
comments = Comment.objects.filter(archives_id=id).order_by("-comment_time").all()
a = {
"id": i.id,
"title": i.title,
@ -40,20 +63,23 @@ def archives(request, id):
"read": i.read,
"content": i.content,
"author": i.author,
"site_config": get_site_config(),
"previous":{
"id": previous_id,
"title": previous_id_title,
},"next":{
"id": next_id,
"title": next_id_title,
},"comments": []
},"comments": [],
"FriendshipLinks": get_friendship_links()
}
print(a)
for c in comments:
com = {
"id": c.id,
"comment_Content": c.comment_Content,
"comment_User": c.comment_User,
"comment_Time": c.comment_Time,
"comment_Content": c.comment_content,
"comment_User": c.comment_user,
"comment_Time": c.comment_time,
"qq": c.qq,
}
a["comments"].append(com)

0
siteconfig/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

25
siteconfig/admin.py Normal file
View File

@ -0,0 +1,25 @@
from django.contrib import admin
from django.core.exceptions import ObjectDoesNotExist
from siteconfig.models import *
# Register your models here.
@admin.register(SiteConfig)
class SiteConfigAdmin(admin.ModelAdmin):
list_display = ["site_name","site_author_name","site_author_qq","site_author_email","site_describe","site_keyword","icp"]
def save_model(self, request, obj, form, change):
# 检查是否已存在数据
try:
existing_obj = SiteConfig.objects.get()
# 如果存在,更新现有对象
existing_obj.__dict__.update(obj.__dict__)
existing_obj.save()
# 删除新创建的对象(因为我们已经更新了现有对象)
# obj.delete()
except ObjectDoesNotExist:
# 如果不存在,创建新对象
super().save_model(request, obj, form, change)
@admin.register(FriendshipLink)
class FriendshipLinkAdmin(admin.ModelAdmin):
list_display = ["friendship_site_link","friendship_site_name"]

7
siteconfig/apps.py Normal file
View File

@ -0,0 +1,7 @@
from django.apps import AppConfig
class SiteconfigConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'siteconfig'
verbose_name = '站点设置'

View File

@ -0,0 +1,29 @@
# Generated by Django 4.2.23 on 2025-06-23 03:17
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='SiteConfig',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('site_name', models.CharField(max_length=255, verbose_name='网站名称')),
('site_author_name', models.CharField(max_length=255, verbose_name='站长昵称')),
('site_describe', models.CharField(max_length=255, verbose_name='站点描述')),
('site_keyword', models.CharField(max_length=255, verbose_name='站点关键字')),
],
options={
'verbose_name': '设置',
'verbose_name_plural': '站点设置',
'db_table': 'SiteConfig',
},
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.23 on 2025-06-23 14:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('siteconfig', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='siteconfig',
name='site_author_qq',
field=models.CharField(default=0, max_length=255, verbose_name='站点qq'),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2.23 on 2025-06-23 15:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('siteconfig', '0002_siteconfig_site_author_qq'),
]
operations = [
migrations.AddField(
model_name='siteconfig',
name='site_author_email',
field=models.CharField(default=0, max_length=255, verbose_name='站点长邮箱'),
),
migrations.AlterField(
model_name='siteconfig',
name='site_author_qq',
field=models.CharField(default=0, max_length=255, verbose_name='站长qq'),
),
]

View File

@ -0,0 +1,26 @@
# Generated by Django 4.2.23 on 2025-06-23 15:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('siteconfig', '0003_siteconfig_site_author_email_and_more'),
]
operations = [
migrations.CreateModel(
name='FriendshipLink',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('friendship_site_link', models.CharField(max_length=255, verbose_name='友链地址')),
('friendship_site_name', models.CharField(max_length=255, verbose_name='友链名称')),
],
options={
'verbose_name': '设置',
'verbose_name_plural': '友链管理',
'db_table': 'FriendshipLink',
},
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.23 on 2025-06-23 15:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('siteconfig', '0004_friendshiplink'),
]
operations = [
migrations.AddField(
model_name='siteconfig',
name='icp',
field=models.CharField(default='', max_length=255, verbose_name='ICP备案号'),
),
]

View File

28
siteconfig/models.py Normal file
View File

@ -0,0 +1,28 @@
from django.db import models
# Create your models here.
class SiteConfig(models.Model):
site_name = models.CharField(max_length=255,verbose_name='网站名称')
site_author_name = models.CharField(max_length=255,verbose_name='站长昵称')
site_author_qq = models.CharField(default=0,max_length=255,verbose_name='站长qq')
site_author_email = models.CharField(default=0, max_length=255, verbose_name='站点长邮箱')
site_describe = models.CharField(max_length=255,verbose_name='站点描述')
site_keyword = models.CharField(max_length=255,verbose_name='站点关键字')
icp = models.CharField(default="",max_length=255,verbose_name='ICP备案号')
class Meta:
verbose_name = "设置"
verbose_name_plural = "站点设置"
db_table = "SiteConfig"
def __str__(self):
return "站点设置"
class FriendshipLink(models.Model):
friendship_site_link = models.CharField(max_length=255,verbose_name='友链地址')
friendship_site_name = models.CharField(max_length=255,verbose_name='友链名称')
class Meta:
verbose_name = "设置"
verbose_name_plural = "友链管理"
db_table = "FriendshipLink"

3
siteconfig/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
siteconfig/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.