feat(web): 接入工程基线页面与全局配置
This commit is contained in:
@@ -49,10 +49,14 @@ INSTALLED_APPS = [
|
|||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
|
"common",
|
||||||
|
"accounts",
|
||||||
|
"agent_runtime",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
|
"common.middleware.RequestContextMiddleware",
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
"django.middleware.locale.LocaleMiddleware",
|
"django.middleware.locale.LocaleMiddleware",
|
||||||
"django.middleware.common.CommonMiddleware",
|
"django.middleware.common.CommonMiddleware",
|
||||||
@@ -96,12 +100,33 @@ USE_TZ = True
|
|||||||
|
|
||||||
STATIC_URL = "static/"
|
STATIC_URL = "static/"
|
||||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||||
|
STATICFILES_DIRS = [BASE_DIR / "static"]
|
||||||
MEDIA_URL = "media/"
|
MEDIA_URL = "media/"
|
||||||
MEDIA_ROOT = BASE_DIR / "media"
|
MEDIA_ROOT = BASE_DIR / "media"
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
|
|
||||||
LOGIN_URL = "login"
|
LOGIN_URL = "accounts:login"
|
||||||
LOGIN_REDIRECT_URL = "/"
|
LOGIN_REDIRECT_URL = "agent_runtime:run-list"
|
||||||
LOGOUT_REDIRECT_URL = "login"
|
LOGOUT_REDIRECT_URL = "accounts:login"
|
||||||
|
|
||||||
|
# 日志只输出可关联的结构化键值,不记录请求正文、Cookie 或认证头。
|
||||||
|
LOGGING = {
|
||||||
|
"version": 1,
|
||||||
|
"disable_existing_loggers": False,
|
||||||
|
"formatters": {
|
||||||
|
"structured": {
|
||||||
|
"format": "time={asctime} level={levelname} logger={name} request_id={request_id} message={message}",
|
||||||
|
"style": "{",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filters": {"request_context": {"()": "common.logging.RequestContextFilter"}},
|
||||||
|
"handlers": {
|
||||||
|
"console": {
|
||||||
|
"class": "logging.StreamHandler",
|
||||||
|
"formatter": "structured",
|
||||||
|
"filters": ["request_context"],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {"handlers": ["console"], "level": "INFO"},
|
||||||
|
}
|
||||||
|
|||||||
+3
-1
@@ -15,8 +15,10 @@ Including another URLconf
|
|||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path("accounts/", include("accounts.urls")),
|
||||||
|
path("runs/", include("agent_runtime.urls")),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
:root{font-family:system-ui,sans-serif;color:#172033;background:#f5f7fb}body{margin:0}header,main{max-width:960px;margin:auto;padding:1rem}header{display:flex;justify-content:space-between;background:#fff}nav{display:flex;gap:1rem;align-items:center}nav form{display:inline}a{color:#1959b8}button{padding:.55rem .9rem}main{background:#fff;margin-top:1rem;border-radius:.5rem}.skip{position:absolute;left:-9999px}.skip:focus{left:1rem;top:1rem}.message{padding:.75rem;background:#e6f4ea}input,select{padding:.5rem;max-width:100%}@media(max-width:600px){header{display:block}nav{margin-top:1rem;flex-wrap:wrap}}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# 保留全局 Django 模板目录,具体模板将随业务页面逐步增加。
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{% extends "base.html" %}{% block title %}个人资料 · JobRadar{% endblock %}{% block content %}<h1>个人资料</h1><p>用户名:{{ user.username }}</p><form method="post">{% csrf_token %}{{ form.as_p }}<button type="submit">保存</button></form>{% endblock %}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{% extends "base.html" %}{% block title %}{{ run.title }} · JobRadar{% endblock %}{% block content %}<h1>{{ run.title }}</h1><p>状态:{{ run.get_status_display }}</p><h2>运行事件</h2><ol>{% for event in run.events.all %}<li><time>{{ event.occurred_at }}</time> {{ event.summary }}</li>{% empty %}<li>暂无事件</li>{% endfor %}</ol><h2>工具调用</h2>{% for call in run.tool_calls.all %}<p>{{ call.tool_name }}:{{ call.get_status_display }}</p>{% empty %}<p>暂无工具调用</p>{% endfor %}{% endblock %}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{% extends "base.html" %}{% block title %}运行记录 · JobRadar{% endblock %}{% block content %}<h1>运行记录</h1>{% for run in page %}<article><h2><a href="{% url 'agent_runtime:run-detail' run.id %}">{{ run.title }}</a></h2><p>状态:{{ run.get_status_display }};创建于 <time>{{ run.created_at }}</time></p></article>{% empty %}<p>当前没有运行记录。第一阶段尚未开放真实 Agent 任务。</p>{% endfor %}{% if page.has_previous %}<a href="?page={{ page.previous_page_number }}">上一页</a>{% endif %}{% if page.has_next %}<a href="?page={{ page.next_page_number }}">下一页</a>{% endif %}{% endblock %}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{% block title %}JobRadar{% endblock %}</title><link rel="stylesheet" href="/static/css/app.css"></head>
|
||||||
|
<body><a class="skip" href="#main">跳到主要内容</a><header><strong>JobRadar · 职途雷达</strong>{% if user.is_authenticated %}<nav><a href="{% url 'agent_runtime:run-list' %}">运行记录</a><a href="{% url 'accounts:profile' %}">个人资料</a><form method="post" action="{% url 'accounts:logout' %}">{% csrf_token %}<button>退出</button></form></nav>{% endif %}</header><main id="main">{% for message in messages %}<p class="message">{{ message }}</p>{% endfor %}{% block content %}{% endblock %}</main></body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{% extends "base.html" %}{% block title %}登录 · JobRadar{% endblock %}{% block content %}<h1>登录</h1><form method="post">{% csrf_token %}{{ form.as_p }}{% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %}<button type="submit">登录</button></form>{% endblock %}
|
||||||
Reference in New Issue
Block a user