From 3eb331a6d72332921ebe29e5d8199b4a90da022f Mon Sep 17 00:00:00 2001 From: bruce Date: Wed, 9 Sep 2026 11:59:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E6=8E=A5=E5=85=A5=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E5=9F=BA=E7=BA=BF=E9=A1=B5=E9=9D=A2=E4=B8=8E=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JobRadar/settings/base.py | 31 ++++++++++++++++++++++--- JobRadar/urls.py | 4 +++- static/css/app.css | 1 + templates/.gitkeep | 1 + templates/accounts/profile.html | 1 + templates/agent_runtime/run_detail.html | 1 + templates/agent_runtime/run_list.html | 1 + templates/base.html | 5 ++++ templates/registration/login.html | 1 + 9 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 static/css/app.css create mode 100644 templates/.gitkeep create mode 100644 templates/accounts/profile.html create mode 100644 templates/agent_runtime/run_detail.html create mode 100644 templates/agent_runtime/run_list.html create mode 100644 templates/base.html create mode 100644 templates/registration/login.html diff --git a/JobRadar/settings/base.py b/JobRadar/settings/base.py index 000b49b..8b230b3 100644 --- a/JobRadar/settings/base.py +++ b/JobRadar/settings/base.py @@ -49,10 +49,14 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "common", + "accounts", + "agent_runtime", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", + "common.middleware.RequestContextMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.locale.LocaleMiddleware", "django.middleware.common.CommonMiddleware", @@ -96,12 +100,33 @@ USE_TZ = True STATIC_URL = "static/" STATIC_ROOT = BASE_DIR / "staticfiles" +STATICFILES_DIRS = [BASE_DIR / "static"] MEDIA_URL = "media/" MEDIA_ROOT = BASE_DIR / "media" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" -LOGIN_URL = "login" -LOGIN_REDIRECT_URL = "/" -LOGOUT_REDIRECT_URL = "login" +LOGIN_URL = "accounts:login" +LOGIN_REDIRECT_URL = "agent_runtime:run-list" +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"}, +} diff --git a/JobRadar/urls.py b/JobRadar/urls.py index 521d153..20e9e85 100644 --- a/JobRadar/urls.py +++ b/JobRadar/urls.py @@ -15,8 +15,10 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), + path("accounts/", include("accounts.urls")), + path("runs/", include("agent_runtime.urls")), ] diff --git a/static/css/app.css b/static/css/app.css new file mode 100644 index 0000000..a84010f --- /dev/null +++ b/static/css/app.css @@ -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}} diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000..9e94857 --- /dev/null +++ b/templates/.gitkeep @@ -0,0 +1 @@ +# 保留全局 Django 模板目录,具体模板将随业务页面逐步增加。 diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html new file mode 100644 index 0000000..235da38 --- /dev/null +++ b/templates/accounts/profile.html @@ -0,0 +1 @@ +{% extends "base.html" %}{% block title %}个人资料 · JobRadar{% endblock %}{% block content %}

个人资料

用户名:{{ user.username }}

{% csrf_token %}{{ form.as_p }}
{% endblock %} diff --git a/templates/agent_runtime/run_detail.html b/templates/agent_runtime/run_detail.html new file mode 100644 index 0000000..d020834 --- /dev/null +++ b/templates/agent_runtime/run_detail.html @@ -0,0 +1 @@ +{% extends "base.html" %}{% block title %}{{ run.title }} · JobRadar{% endblock %}{% block content %}

{{ run.title }}

状态:{{ run.get_status_display }}

运行事件

    {% for event in run.events.all %}
  1. {{ event.summary }}
  2. {% empty %}
  3. 暂无事件
  4. {% endfor %}

工具调用

{% for call in run.tool_calls.all %}

{{ call.tool_name }}:{{ call.get_status_display }}

{% empty %}

暂无工具调用

{% endfor %}{% endblock %} diff --git a/templates/agent_runtime/run_list.html b/templates/agent_runtime/run_list.html new file mode 100644 index 0000000..f576ece --- /dev/null +++ b/templates/agent_runtime/run_list.html @@ -0,0 +1 @@ +{% extends "base.html" %}{% block title %}运行记录 · JobRadar{% endblock %}{% block content %}

运行记录

{% for run in page %}

{{ run.title }}

状态:{{ run.get_status_display }};创建于

{% empty %}

当前没有运行记录。第一阶段尚未开放真实 Agent 任务。

{% endfor %}{% if page.has_previous %}上一页{% endif %}{% if page.has_next %}下一页{% endif %}{% endblock %} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..b62b711 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,5 @@ + + +{% block title %}JobRadar{% endblock %} +
JobRadar · 职途雷达{% if user.is_authenticated %}{% endif %}
{% for message in messages %}

{{ message }}

{% endfor %}{% block content %}{% endblock %}
+ diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 0000000..fc0eff6 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1 @@ +{% extends "base.html" %}{% block title %}登录 · JobRadar{% endblock %}{% block content %}

登录

{% csrf_token %}{{ form.as_p }}{% if next %}{% endif %}
{% endblock %}