Compare commits
5 Commits
ff7a375705
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e1968a5e5 | |||
| b25d13d041 | |||
| d53fadf2d6 | |||
| a4c1a92cc8 | |||
| 8f9bca5dfa |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -176,3 +176,6 @@ cython_debug/
|
||||
|
||||
|
||||
media/
|
||||
staticfiles/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
@@ -65,15 +65,23 @@ class CrawledContentAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ['created_at', 'preview_content', 'media_files_display']
|
||||
ordering = ['-created_at']
|
||||
|
||||
class Media:
|
||||
css = {
|
||||
'all': ('admin/css/custom_admin.css',)
|
||||
}
|
||||
|
||||
def title_display(self, obj):
|
||||
"""显示完整的标题,但在列表中限制宽度"""
|
||||
if len(obj.title) > 100:
|
||||
return format_html(
|
||||
'<span title="{}">{}</span>',
|
||||
'<div style="min-width: 300px; white-space: normal; word-wrap: break-word;" title="{}">{}</div>',
|
||||
obj.title,
|
||||
obj.title[:20] + '...'
|
||||
obj.title[:100] + '...'
|
||||
)
|
||||
return format_html(
|
||||
'<div style="min-width: 300px; white-space: normal; word-wrap: break-word;">{}</div>',
|
||||
obj.title
|
||||
)
|
||||
return obj.title
|
||||
title_display.short_description = '标题'
|
||||
title_display.admin_order_field = 'title'
|
||||
|
||||
|
||||
108
crawler/static/admin/css/custom_admin.css
Normal file
108
crawler/static/admin/css/custom_admin.css
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
自定义管理后台样式
|
||||
*/
|
||||
|
||||
/* 增加标题列的宽度 */
|
||||
.field-title_display {
|
||||
width: 350px !important;
|
||||
max-width: 350px !important;
|
||||
min-width: 350px !important;
|
||||
}
|
||||
|
||||
/* 确保表格可以水平滚动 */
|
||||
.results {
|
||||
overflow-x: auto !important;
|
||||
}
|
||||
|
||||
/* 为标题单元格设置最小宽度 */
|
||||
.results table tbody td.field-title_display,
|
||||
.results table thead th.field-title_display {
|
||||
min-width: 350px !important;
|
||||
width: 350px !important;
|
||||
max-width: 350px !important;
|
||||
white-space: normal !important;
|
||||
word-wrap: break-word !important;
|
||||
word-break: break-word !important;
|
||||
vertical-align: top !important;
|
||||
}
|
||||
|
||||
/* 为表头设置固定位置 */
|
||||
.results table thead {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
/* 强制表格列宽度 */
|
||||
.results table {
|
||||
table-layout: fixed !important;
|
||||
width: auto !important;
|
||||
min-width: 100% !important;
|
||||
}
|
||||
|
||||
/* 特殊处理复选框列(第一列) */
|
||||
.change-list .results table tbody td:nth-child(1),
|
||||
.change-list .results table thead th:nth-child(1) {
|
||||
width: 40px !important;
|
||||
min-width: 40px !important;
|
||||
max-width: 40px !important;
|
||||
}
|
||||
|
||||
/* 特殊处理标题列(第二列) */
|
||||
.change-list .results table tbody td:nth-child(2),
|
||||
.change-list .results table thead th:nth-child(2) {
|
||||
width: 350px !important;
|
||||
min-width: 350px !important;
|
||||
max-width: 350px !important;
|
||||
}
|
||||
|
||||
/* 设置其他列的宽度 */
|
||||
.change-list .results table tbody td:nth-child(3),
|
||||
.change-list .results table thead th:nth-child(3) {
|
||||
width: 120px !important;
|
||||
min-width: 120px !important;
|
||||
}
|
||||
|
||||
.change-list .results table tbody td:nth-child(4),
|
||||
.change-list .results table thead th:nth-child(4) {
|
||||
width: 120px !important;
|
||||
min-width: 120px !important;
|
||||
}
|
||||
|
||||
.change-list .results table tbody td:nth-child(5),
|
||||
.change-list .results table thead th:nth-child(5) {
|
||||
width: 150px !important;
|
||||
min-width: 150px !important;
|
||||
}
|
||||
|
||||
.change-list .results table tbody td:nth-child(6),
|
||||
.change-list .results table thead th:nth-child(6) {
|
||||
width: 80px !important;
|
||||
min-width: 80px !important;
|
||||
}
|
||||
|
||||
.change-list .results table tbody td:nth-child(7),
|
||||
.change-list .results table thead th:nth-child(7) {
|
||||
width: 120px !important;
|
||||
min-width: 120px !important;
|
||||
}
|
||||
|
||||
.change-list .results table tbody td:nth-child(8),
|
||||
.change-list .results table thead th:nth-child(8) {
|
||||
width: 100px !important;
|
||||
min-width: 100px !important;
|
||||
}
|
||||
|
||||
.change-list .results table tbody td:nth-child(9),
|
||||
.change-list .results table thead th:nth-child(9) {
|
||||
width: 120px !important;
|
||||
min-width: 120px !important;
|
||||
}
|
||||
|
||||
/* 确保单元格内容不会溢出 */
|
||||
.results table tbody td,
|
||||
.results table thead th {
|
||||
white-space: normal !important;
|
||||
word-wrap: break-word !important;
|
||||
padding: 8px !important;
|
||||
vertical-align: top !important;
|
||||
}
|
||||
@@ -117,6 +117,10 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / "crawler" / "static",
|
||||
]
|
||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||
|
||||
# Media files (用户上传的文件)
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
Reference in New Issue
Block a user