修改登录和基础功能样式,目前已经支持钉钉登录和自定义登录注册
This commit is contained in:
@@ -9,22 +9,26 @@
|
||||
{% for demand in demands %}
|
||||
<div class="question-item">
|
||||
<div class="question-header">
|
||||
<span class="branch">{{ get_branch_name(demand.branch) }}</span>
|
||||
<span class="time">{{ demand.created_at.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
<h3 class="demand-title">{{ demand.title }} <span class="branch">{{ get_branch_name(demand.branch) }}</span></h3>
|
||||
<span class="status {% if demand.is_public %}public{% else %}private{% endif %}">
|
||||
{% if demand.is_public %}公开{% else %}私有{% endif %}
|
||||
</span>
|
||||
<span class="user">提交者: {{ demand.user.username }}</span>
|
||||
</div>
|
||||
<h3 class="demand-title">{{ demand.title }}</h3>
|
||||
<span class="time">提交者: {{ demand.user.username }} 提交时间: {{ demand.created_at.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
<p class="content">{{ demand.content }}</p>
|
||||
<div class="question-footer">
|
||||
<span class="contact">联系方式: {{ demand.contact }}</span>
|
||||
{% if demand.answer %}
|
||||
<div class="answer">
|
||||
<strong>回答:</strong>
|
||||
<p>{{ demand.answer }}</p>
|
||||
<span class="answer-time">回答时间: {{ demand.answered_at.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
<div class="answer-toggle" onclick="toggleAnswer(this)">
|
||||
<span class="toggle-icon">▶</span>
|
||||
<span class="toggle-text">查看回答</span>
|
||||
</div>
|
||||
<div class="answer-content" style="display: none;">
|
||||
<div class="answer">
|
||||
<strong>回答:</strong>
|
||||
<p>{{ demand.answer }}</p>
|
||||
<span class="answer-time">回答时间: {{ demand.answered_at.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<span class="status waiting">待回答</span>
|
||||
@@ -42,7 +46,41 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if pagination.pages > 1 %}
|
||||
<div class="pagination">
|
||||
{% if pagination.has_prev %}
|
||||
<a href="{{ url_for('admin_demands', page=pagination.prev_num) }}" class="btn btn-page">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="page-info">
|
||||
共 {{ pagination.total }} 条,第 {{ pagination.page }} / {{ pagination.pages }} 页
|
||||
</span>
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="{{ url_for('admin_demands', page=pagination.next_num) }}" class="btn btn-page">下一页</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p class="empty">暂无需求</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
<script>
|
||||
function toggleAnswer(element) {
|
||||
var content = element.nextElementSibling;
|
||||
var icon = element.querySelector('.toggle-icon');
|
||||
var text = element.querySelector('.toggle-text');
|
||||
|
||||
if (content.style.display === 'none') {
|
||||
content.style.display = 'block';
|
||||
icon.textContent = '▼';
|
||||
text.textContent = '收起回答';
|
||||
} else {
|
||||
content.style.display = 'none';
|
||||
icon.textContent = '▶';
|
||||
text.textContent = '查看回答';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -23,20 +23,48 @@
|
||||
<li><a href="{{ url_for('admin_demands') }}">管理后台</a></li>
|
||||
{% endif %}
|
||||
<li class="user-name">{{ current_user.dingtalk_name or current_user.username }}</li>
|
||||
<li><a href="{{ url_for('logout') }}">退出</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ url_for('login') }}">登录</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<main class="container">
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
<div id="toast-container" class="toast-container"></div>
|
||||
<script>
|
||||
const toastIcons = {
|
||||
success: '✓',
|
||||
warning: '⚠',
|
||||
error: '✕',
|
||||
info: 'ℹ'
|
||||
};
|
||||
|
||||
function showToast(message, type = 'info') {
|
||||
const container = document.getElementById('toast-container');
|
||||
const toast = document.createElement('div');
|
||||
toast.className = `toast toast-${type}`;
|
||||
toast.innerHTML = `<span class="toast-icon">${toastIcons[type]}</span>${message}`;
|
||||
container.appendChild(toast);
|
||||
setTimeout(() => toast.classList.add('show'), 10);
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('show');
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 显示 Flask flash messages
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="flash">{{ message }}</div>
|
||||
{% for category, message in messages %}
|
||||
showToast('{{ message }}', '{{ category }}');
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block content %}{% endblock %}
|
||||
</script>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="container">
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
{{ form.branch(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ form.contact.label.text }} *</label>
|
||||
{{ form.contact(class="form-control") }}
|
||||
<label>{{ form.contact.label.text }}</label>
|
||||
{{ form.contact(class="form-control") }}
|
||||
</div>
|
||||
{{ form.is_public() }} <label for="is_public">{{ form.is_public.label.text }}</label>
|
||||
<div class="form-group">
|
||||
{{ form.submit(class="btn btn-primary") }}
|
||||
<a href="{{ url_for('index') }}" class="btn btn-cancel">取消</a>
|
||||
|
||||
@@ -27,6 +27,22 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if pagination.pages > 1 %}
|
||||
<div class="pagination">
|
||||
{% if pagination.has_prev %}
|
||||
<a href="{{ url_for('index', page=pagination.prev_num) }}" class="btn btn-page">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="page-info">
|
||||
共 {{ pagination.total }} 条,第 {{ pagination.page }} / {{ pagination.pages }} 页
|
||||
</span>
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="{{ url_for('index', page=pagination.next_num) }}" class="btn btn-page">下一页</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p class="empty">暂无公开需求</p>
|
||||
{% endif %}
|
||||
@@ -48,4 +64,4 @@ function toggleAnswer(element) {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
32
templates/login.html
Normal file
32
templates/login.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}登录 - 人事共享服务中心"码"上办{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="login-container">
|
||||
<h2>登录</h2>
|
||||
<form method="POST" action="{{ url_for('login') }}">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="form-group">
|
||||
{{ form.username.label }}
|
||||
{{ form.username(class="form-control") }}
|
||||
{% if form.username.errors %}
|
||||
<div class="error">{{ form.username.errors[0] }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.password.label }}
|
||||
{{ form.password(class="form-control") }}
|
||||
{% if form.password.errors %}
|
||||
<div class="error">{{ form.password.errors[0] }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.submit(class="btn btn-primary") }}
|
||||
</div>
|
||||
</form>
|
||||
<p class="login-link">
|
||||
还没有账号?<a href="{{ url_for('register') }}">立即注册</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -36,6 +36,22 @@
|
||||
<p class="empty">暂无需求</p>
|
||||
{% endif %}
|
||||
|
||||
{% if pagination.pages > 1 %}
|
||||
<div class="pagination">
|
||||
{% if pagination.has_prev %}
|
||||
<a href="{{ url_for('my_demands', page=pagination.prev_num) }}" class="btn btn-page">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="page-info">
|
||||
共 {{ pagination.total }} 条,第 {{ pagination.page }} / {{ pagination.pages }} 页
|
||||
</span>
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="{{ url_for('my_demands', page=pagination.next_num) }}" class="btn btn-page">下一页</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
function toggleAnswer(element) {
|
||||
var content = element.nextElementSibling;
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
{% block content %}
|
||||
<div class="login-required">
|
||||
<div class="login-icon">🔒</div>
|
||||
<h2>请先通过钉钉登录</h2>
|
||||
<p>本系统需要通过钉钉账号登录才能使用</p>
|
||||
<h2>请先登录</h2>
|
||||
<p>本系统需要登录才能使用</p>
|
||||
<div class="login-options">
|
||||
<a href="{{ url_for('login') }}" class="btn btn-primary">账号密码登录</a>
|
||||
<a href="{{ url_for('register') }}" class="btn btn-secondary">注册账号</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
39
templates/register.html
Normal file
39
templates/register.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}注册 - 人事共享服务中心"码"上办{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="login-container">
|
||||
<h2>注册账号</h2>
|
||||
<form method="POST" action="{{ url_for('register') }}">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="form-group">
|
||||
{{ form.username.label }}
|
||||
{{ form.username(class="form-control") }}
|
||||
{% if form.username.errors %}
|
||||
<div class="error">{{ form.username.errors[0] }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.password.label }}
|
||||
{{ form.password(class="form-control") }}
|
||||
{% if form.password.errors %}
|
||||
<div class="error">{{ form.password.errors[0] }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.confirm_password.label }}
|
||||
{{ form.confirm_password(class="form-control") }}
|
||||
{% if form.confirm_password.errors %}
|
||||
<div class="error">{{ form.confirm_password.errors[0] }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.submit(class="btn btn-primary") }}
|
||||
</div>
|
||||
</form>
|
||||
<p class="login-link">
|
||||
已有账号?<a href="{{ url_for('login') }}">立即登录</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user