test
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
from config import Config
|
||||
import os
|
||||
from flask_cors import CORS
|
||||
|
||||
# 初始化扩展
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
|
||||
def create_app(config_class=Config):
|
||||
app = Flask(__name__,
|
||||
template_folder='templates',
|
||||
static_folder='../static')
|
||||
|
||||
app.config.from_object(config_class)
|
||||
|
||||
# 启用跨域支持
|
||||
CORS(app)
|
||||
|
||||
# 初始化扩展
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
|
||||
# 注册蓝图
|
||||
from flask_prompt_master.routes import main_bp
|
||||
app.register_blueprint(main_bp)
|
||||
|
||||
return app
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,239 +0,0 @@
|
||||
from flask import Flask, jsonify, request
|
||||
from flask_cors import CORS
|
||||
from datetime import datetime
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app) # 允许跨域请求
|
||||
|
||||
# 模拟数据库中的模板数据
|
||||
MOCK_TEMPLATES = [
|
||||
{
|
||||
"id": "1",
|
||||
"name": "后端开发工程师",
|
||||
"description": "专业的后端开发工程师模板",
|
||||
"category": "软件开发",
|
||||
"industry": "互联网",
|
||||
"profession": "开发工程师",
|
||||
"sub_category": "后端开发",
|
||||
"system_prompt": "你是一位专业的后端开发工程师..."
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "前端开发工程师",
|
||||
"description": "专业的前端开发工程师模板",
|
||||
"category": "软件开发",
|
||||
"industry": "互联网",
|
||||
"profession": "开发工程师",
|
||||
"sub_category": "前端开发",
|
||||
"system_prompt": "你是一位专业的前端开发工程师..."
|
||||
}
|
||||
]
|
||||
|
||||
# 身份验证装饰器
|
||||
def require_auth(f):
|
||||
from functools import wraps
|
||||
@wraps(f)
|
||||
def decorated(*args, **kwargs):
|
||||
auth_header = request.headers.get('Authorization')
|
||||
if not auth_header or not auth_header.startswith('Bearer '):
|
||||
return jsonify({'error': 'No authorization token provided'}), 401
|
||||
# 这里简单验证token,实际应该更严格
|
||||
token = auth_header.split(' ')[1]
|
||||
if token != 'test_token_123':
|
||||
return jsonify({'error': 'Invalid token'}), 401
|
||||
return f(*args, **kwargs)
|
||||
return decorated
|
||||
|
||||
# 获取模板列表接口
|
||||
@app.route('/api/v1/templates', methods=['GET'])
|
||||
@require_auth
|
||||
def get_templates():
|
||||
# 获取查询参数
|
||||
page = int(request.args.get('page', 1))
|
||||
size = int(request.args.get('size', 10))
|
||||
category = request.args.get('category')
|
||||
industry = request.args.get('industry')
|
||||
profession = request.args.get('profession')
|
||||
|
||||
# 过滤模板
|
||||
filtered_templates = MOCK_TEMPLATES
|
||||
if category:
|
||||
filtered_templates = [t for t in filtered_templates if t['category'] == category]
|
||||
if industry:
|
||||
filtered_templates = [t for t in filtered_templates if t['industry'] == industry]
|
||||
if profession:
|
||||
filtered_templates = [t for t in filtered_templates if t['profession'] == profession]
|
||||
|
||||
# 计算分页
|
||||
start = (page - 1) * size
|
||||
end = start + size
|
||||
paginated_templates = filtered_templates[start:end]
|
||||
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': {
|
||||
'total': len(filtered_templates),
|
||||
'pages': (len(filtered_templates) + size - 1) // size,
|
||||
'current_page': page,
|
||||
'templates': paginated_templates
|
||||
}
|
||||
})
|
||||
|
||||
# 获取单个模板接口
|
||||
@app.route('/api/v1/templates/<template_id>', methods=['GET'])
|
||||
@require_auth
|
||||
def get_template(template_id):
|
||||
template = next((t for t in MOCK_TEMPLATES if t['id'] == template_id), None)
|
||||
if not template:
|
||||
return jsonify({'error': 'Template not found'}), 404
|
||||
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': template
|
||||
})
|
||||
|
||||
# 创建模板接口
|
||||
@app.route('/api/v1/templates', methods=['POST'])
|
||||
@require_auth
|
||||
def create_template():
|
||||
data = request.get_json()
|
||||
|
||||
# 验证必要字段
|
||||
required_fields = ['name', 'description', 'category', 'industry', 'profession']
|
||||
for field in required_fields:
|
||||
if field not in data:
|
||||
return jsonify({'error': f'Missing required field: {field}'}), 400
|
||||
|
||||
# 创建新模板
|
||||
new_template = {
|
||||
'id': str(len(MOCK_TEMPLATES) + 1),
|
||||
**data,
|
||||
'created_at': datetime.now().isoformat()
|
||||
}
|
||||
MOCK_TEMPLATES.append(new_template)
|
||||
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': {
|
||||
'id': new_template['id'],
|
||||
'message': 'Template created successfully'
|
||||
}
|
||||
})
|
||||
|
||||
# 更新模板接口
|
||||
@app.route('/api/v1/templates/<template_id>', methods=['PUT'])
|
||||
@require_auth
|
||||
def update_template(template_id):
|
||||
template = next((t for t in MOCK_TEMPLATES if t['id'] == template_id), None)
|
||||
if not template:
|
||||
return jsonify({'error': 'Template not found'}), 404
|
||||
|
||||
data = request.get_json()
|
||||
template.update(data)
|
||||
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': {
|
||||
'message': 'Template updated successfully'
|
||||
}
|
||||
})
|
||||
|
||||
# 删除模板接口
|
||||
@app.route('/api/v1/templates/<template_id>', methods=['DELETE'])
|
||||
@require_auth
|
||||
def delete_template(template_id):
|
||||
template_index = next((i for i, t in enumerate(MOCK_TEMPLATES) if t['id'] == template_id), None)
|
||||
if template_index is None:
|
||||
return jsonify({'error': 'Template not found'}), 404
|
||||
|
||||
MOCK_TEMPLATES.pop(template_index)
|
||||
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': {
|
||||
'message': 'Template deleted successfully'
|
||||
}
|
||||
})
|
||||
|
||||
# 模糊搜索提示词模板接口
|
||||
@app.route('/api/v1/templates/search', methods=['GET'])
|
||||
@require_auth
|
||||
def search_templates():
|
||||
"""模糊搜索提示词模板"""
|
||||
# 获取搜索参数
|
||||
keyword = request.args.get('keyword', '').strip()
|
||||
page = int(request.args.get('page', 1))
|
||||
size = int(request.args.get('size', 10))
|
||||
|
||||
# 如果没有关键词,返回空结果
|
||||
if not keyword:
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': {
|
||||
'total': 0,
|
||||
'pages': 0,
|
||||
'current_page': page,
|
||||
'templates': []
|
||||
}
|
||||
})
|
||||
|
||||
# 执行模糊搜索
|
||||
# 搜索范围:名称、描述、分类、行业、职业、子分类、系统提示词
|
||||
search_results = []
|
||||
for template in MOCK_TEMPLATES:
|
||||
# 在各个字段中搜索关键词
|
||||
if any(keyword.lower() in str(value).lower() for value in [
|
||||
template.get('name', ''),
|
||||
template.get('description', ''),
|
||||
template.get('category', ''),
|
||||
template.get('industry', ''),
|
||||
template.get('profession', ''),
|
||||
template.get('sub_category', ''),
|
||||
template.get('system_prompt', '')
|
||||
]):
|
||||
# 添加匹配度信息
|
||||
match_score = sum(
|
||||
str(value).lower().count(keyword.lower())
|
||||
for value in [
|
||||
template.get('name', ''),
|
||||
template.get('description', ''),
|
||||
template.get('category', ''),
|
||||
template.get('industry', ''),
|
||||
template.get('profession', ''),
|
||||
template.get('sub_category', ''),
|
||||
template.get('system_prompt', '')
|
||||
]
|
||||
)
|
||||
search_results.append({
|
||||
**template,
|
||||
'_match_score': match_score
|
||||
})
|
||||
|
||||
# 按匹配度排序
|
||||
search_results.sort(key=lambda x: x['_match_score'], reverse=True)
|
||||
|
||||
# 移除匹配度信息
|
||||
search_results = [{k: v for k, v in t.items() if k != '_match_score'}
|
||||
for t in search_results]
|
||||
|
||||
# 计算分页
|
||||
total = len(search_results)
|
||||
total_pages = (total + size - 1) // size
|
||||
start = (page - 1) * size
|
||||
end = start + size
|
||||
paginated_results = search_results[start:end]
|
||||
|
||||
# 返回结果
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'data': {
|
||||
'total': total,
|
||||
'pages': total_pages,
|
||||
'current_page': page,
|
||||
'keyword': keyword,
|
||||
'templates': paginated_results
|
||||
}
|
||||
})
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=5000)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import TextAreaField, SubmitField, IntegerField
|
||||
from wtforms.validators import DataRequired, Length, NumberRange
|
||||
|
||||
class PromptForm(FlaskForm):
|
||||
input_text = TextAreaField('输入文本', validators=[DataRequired(), Length(min=1, max=1000)])
|
||||
submit = SubmitField('生成提示词')
|
||||
|
||||
class FeedbackForm(FlaskForm):
|
||||
rating = IntegerField('评分', validators=[DataRequired(), NumberRange(min=1, max=5)])
|
||||
comment = TextAreaField('评论')
|
||||
submit = SubmitField('提交反馈')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,89 +0,0 @@
|
||||
from flask_prompt_master import db
|
||||
from datetime import datetime
|
||||
|
||||
class User(db.Model):
|
||||
__tablename__ = 'user'
|
||||
|
||||
uid = db.Column(db.Integer, primary_key=True)
|
||||
nickname = db.Column(db.String(100), nullable=False)
|
||||
mobile = db.Column(db.String(20), nullable=True)
|
||||
email = db.Column(db.String(100), nullable=True)
|
||||
sex = db.Column(db.Integer, nullable=False, default=0)
|
||||
avatar = db.Column(db.String(64), nullable=True)
|
||||
login_name = db.Column(db.String(20), nullable=False, unique=True)
|
||||
login_pwd = db.Column(db.String(32), nullable=False)
|
||||
login_salt = db.Column(db.String(32), nullable=False)
|
||||
status = db.Column(db.Integer, nullable=False, default=1)
|
||||
openid = db.Column(db.String(64), unique=True)
|
||||
session_key = db.Column(db.String(64))
|
||||
unionid = db.Column(db.String(64), unique=True)
|
||||
wx_nickname = db.Column(db.String(100))
|
||||
wx_avatar = db.Column(db.String(255))
|
||||
updated_time = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_time = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
prompts = db.relationship('Prompt', backref='author', lazy='dynamic')
|
||||
feedbacks = db.relationship('Feedback', backref='author', lazy='dynamic')
|
||||
|
||||
class WxUser(db.Model):
|
||||
"""微信小程序用户表"""
|
||||
__tablename__ = 'wx_user'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
openid = db.Column(db.String(64), unique=True, nullable=False)
|
||||
session_key = db.Column(db.String(64))
|
||||
unionid = db.Column(db.String(64), unique=True)
|
||||
nickname = db.Column(db.String(100))
|
||||
avatar_url = db.Column(db.String(255))
|
||||
gender = db.Column(db.Integer, default=0) # 0:未知, 1:男, 2:女
|
||||
country = db.Column(db.String(50))
|
||||
province = db.Column(db.String(50))
|
||||
city = db.Column(db.String(50))
|
||||
language = db.Column(db.String(20))
|
||||
phone = db.Column(db.String(20))
|
||||
is_active = db.Column(db.Boolean, default=True)
|
||||
last_login = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
# 关联到提示词和反馈
|
||||
prompts = db.relationship('Prompt', backref='wx_user', lazy='dynamic',
|
||||
foreign_keys='Prompt.wx_user_id')
|
||||
feedbacks = db.relationship('Feedback', backref='wx_user', lazy='dynamic',
|
||||
foreign_keys='Feedback.wx_user_id')
|
||||
|
||||
class Prompt(db.Model):
|
||||
__tablename__ = 'prompt'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
input_text = db.Column(db.Text, nullable=False)
|
||||
generated_text = db.Column(db.Text, nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.uid')) # 修改为可空
|
||||
wx_user_id = db.Column(db.Integer, db.ForeignKey('wx_user.id')) # 添加微信用户ID
|
||||
feedbacks = db.relationship('Feedback', backref='prompt', lazy='dynamic')
|
||||
|
||||
class Feedback(db.Model):
|
||||
__tablename__ = 'feedback'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
rating = db.Column(db.Integer, nullable=False)
|
||||
comment = db.Column(db.Text)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.uid')) # 修改为可空
|
||||
wx_user_id = db.Column(db.Integer, db.ForeignKey('wx_user.id')) # 添加微信用户ID
|
||||
prompt_id = db.Column(db.Integer, db.ForeignKey('prompt.id'), nullable=False)
|
||||
|
||||
class PromptTemplate(db.Model):
|
||||
__tablename__ = 'prompt_template'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(100), nullable=False)
|
||||
description = db.Column(db.Text)
|
||||
category = db.Column(db.String(50))
|
||||
industry = db.Column(db.String(50))
|
||||
profession = db.Column(db.String(50))
|
||||
sub_category = db.Column(db.String(50))
|
||||
system_prompt = db.Column(db.Text, nullable=False)
|
||||
is_default = db.Column(db.Boolean, default=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
@@ -1,36 +0,0 @@
|
||||
from flask import Blueprint, render_template, request
|
||||
from flask_prompt_master.templates.prompts import TEMPLATE_CATEGORIES
|
||||
from flask_prompt_master.models import PromptTemplate
|
||||
|
||||
bp = Blueprint('prompts', __name__)
|
||||
|
||||
ITEMS_PER_PAGE = 9 # 每页显示的模板数量
|
||||
|
||||
@bp.route('/prompts')
|
||||
def list():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
category = request.args.get('category', '全部')
|
||||
|
||||
# 获取模板数据
|
||||
query = PromptTemplate.query
|
||||
|
||||
if category != '全部':
|
||||
query = query.filter_by(category=category)
|
||||
|
||||
# 分页
|
||||
pagination = query.paginate(
|
||||
page=page,
|
||||
per_page=ITEMS_PER_PAGE,
|
||||
error_out=False
|
||||
)
|
||||
|
||||
templates = pagination.items
|
||||
|
||||
return render_template('prompt_list.html',
|
||||
templates=templates,
|
||||
categories=TEMPLATE_CATEGORIES,
|
||||
current_category=category,
|
||||
page=page,
|
||||
has_next=pagination.has_next,
|
||||
total_pages=pagination.pages
|
||||
)
|
||||
@@ -1,18 +0,0 @@
|
||||
.prompt-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 20px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.prompt-card {
|
||||
width: calc((100% - 64px) / 5);
|
||||
min-width: 180px;
|
||||
margin: 0;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
from .prompts import templates
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,165 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>提示词大师 - {% block title %}{% endblock %}</title>
|
||||
<!-- 添加 Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<style>
|
||||
/* 全局样式 */
|
||||
:root {
|
||||
--primary-color: #2196f3;
|
||||
--primary-dark: #1976d2;
|
||||
--secondary-color: #6c757d;
|
||||
--success-color: #28a745;
|
||||
--background-color: #f8f9fa;
|
||||
--border-color: #e0e0e0;
|
||||
--text-color: #2c3e50;
|
||||
--text-light: #666;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
|
||||
line-height: 1.5;
|
||||
color: var(--text-color);
|
||||
background-color: var(--background-color);
|
||||
}
|
||||
|
||||
/* 导航栏样式 */
|
||||
header {
|
||||
background: white;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
nav {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-brand {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.nav-brand i {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
/* 主要内容区域 */
|
||||
main {
|
||||
min-height: calc(100vh - 120px);
|
||||
}
|
||||
|
||||
/* 闪现消息样式 */
|
||||
.flash-messages {
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.flash-message {
|
||||
background: white;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
margin-bottom: 0.5rem;
|
||||
animation: slideIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 页脚样式 */
|
||||
footer {
|
||||
background: white;
|
||||
padding: 2rem 1rem;
|
||||
text-align: center;
|
||||
color: var(--text-light);
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
nav {
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<a href="{{ url_for('main.index') }}" class="nav-brand">
|
||||
<i class="fas fa-magic"></i>
|
||||
提示词大师
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<div class="flash-messages">
|
||||
{% for message in messages %}
|
||||
<div class="flash-message">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>© 2025 提示词大师 - 让AI更好地理解您的需求</p>
|
||||
</footer>
|
||||
|
||||
{% block extra_js %}{% endblock %}
|
||||
<script>
|
||||
// 自动隐藏闪现消息
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const messages = document.querySelectorAll('.flash-message');
|
||||
messages.forEach(message => {
|
||||
setTimeout(() => {
|
||||
message.style.opacity = '0';
|
||||
message.style.transform = 'translateX(100%)';
|
||||
setTimeout(() => message.remove(), 300);
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,250 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-4">
|
||||
<div class="row">
|
||||
<div class="col-md-8 offset-md-2">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>专家提示词生成器</h2>
|
||||
<a href="{{ url_for('main.index') }}" class="btn btn-outline-primary">
|
||||
<i class="fas fa-arrow-left"></i> 返回基础模式
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form id="expertPromptForm">
|
||||
<div class="mb-3">
|
||||
<label for="input_text" class="form-label">请描述您的需求</label>
|
||||
<textarea class="form-control" id="input_text" name="input_text" rows="4" required></textarea>
|
||||
<div class="form-text">详细描述您的需求,系统将进行专业分析并生成高质量提示词</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" id="generateBtn">
|
||||
<i class="fas fa-magic"></i> 生成专家提示词
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="loadingIndicator" class="text-center mt-4 d-none">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="visually-hidden">生成中...</span>
|
||||
</div>
|
||||
<p class="mt-2">正在分析需求并生成专业提示词...</p>
|
||||
</div>
|
||||
|
||||
<div id="resultCard" class="card mt-4 d-none">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title mb-4">生成结果</h5>
|
||||
|
||||
<div class="mb-4">
|
||||
<h6 class="mb-3">需求分析</h6>
|
||||
<div id="intentAnalysis" class="border rounded p-3 bg-light">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p><strong>核心意图:</strong><span id="coreIntent"></span></p>
|
||||
<p><strong>专业领域:</strong><span id="domain"></span></p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>预期输出:</strong><span id="expectedOutput"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<p><strong>关键需求:</strong></p>
|
||||
<ul id="keyRequirements" class="mb-0"></ul>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<p><strong>约束条件:</strong></p>
|
||||
<ul id="constraints" class="mb-0"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h6 class="mb-3">生成的专家提示词</h6>
|
||||
<div id="generatedPrompt" class="border rounded p-3"></div>
|
||||
<div class="mt-3">
|
||||
<button class="btn btn-sm btn-primary copy-btn" data-target="generatedPrompt">
|
||||
<i class="fas fa-copy"></i> 复制提示词
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.getElementById('expertPromptForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const input_text = document.getElementById('input_text').value;
|
||||
const loadingIndicator = document.getElementById('loadingIndicator');
|
||||
const resultCard = document.getElementById('resultCard');
|
||||
const generateBtn = document.getElementById('generateBtn');
|
||||
|
||||
// 显示加载指示器
|
||||
loadingIndicator.classList.remove('d-none');
|
||||
generateBtn.disabled = true;
|
||||
resultCard.classList.add('d-none');
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/wx/generate/expert', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
input_text: input_text,
|
||||
uid: '12345' // 这里应该使用实际的用户ID
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.code === 200) {
|
||||
// 更新意图分析结果
|
||||
document.getElementById('coreIntent').textContent = data.data.intent_analysis.core_intent;
|
||||
document.getElementById('domain').textContent = data.data.intent_analysis.domain;
|
||||
document.getElementById('expectedOutput').textContent = data.data.intent_analysis.expected_output;
|
||||
|
||||
// 更新关键需求列表
|
||||
const keyRequirementsList = document.getElementById('keyRequirements');
|
||||
keyRequirementsList.innerHTML = data.data.intent_analysis.key_requirements
|
||||
.map(req => `<li>${req}</li>`).join('');
|
||||
|
||||
// 更新约束条件列表
|
||||
const constraintsList = document.getElementById('constraints');
|
||||
constraintsList.innerHTML = data.data.intent_analysis.constraints
|
||||
.map(constraint => `<li>${constraint}</li>`).join('');
|
||||
|
||||
// 更新生成的提示词
|
||||
document.getElementById('generatedPrompt').textContent = data.data.generated_prompt;
|
||||
|
||||
// 显示结果卡片
|
||||
resultCard.classList.remove('d-none');
|
||||
} else {
|
||||
alert('生成失败:' + data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
alert('请求失败,请稍后重试');
|
||||
} finally {
|
||||
// 隐藏加载指示器并启用按钮
|
||||
loadingIndicator.classList.add('d-none');
|
||||
generateBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
// 改进的复制功能实现
|
||||
function copyToClipboard(text) {
|
||||
// 创建临时文本区域
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
|
||||
try {
|
||||
// 选择文本
|
||||
textArea.select();
|
||||
textArea.setSelectionRange(0, 99999); // 对于移动设备
|
||||
|
||||
// 尝试使用新的 API
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
// 对于现代浏览器
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
showCopySuccess();
|
||||
}).catch(err => {
|
||||
console.error('复制失败:', err);
|
||||
// 回退到传统方法
|
||||
document.execCommand('copy');
|
||||
showCopySuccess();
|
||||
});
|
||||
} else {
|
||||
// 对于不支持 Clipboard API 的浏览器
|
||||
const successful = document.execCommand('copy');
|
||||
if (successful) {
|
||||
showCopySuccess();
|
||||
} else {
|
||||
console.error('复制失败');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('复制出错:', err);
|
||||
} finally {
|
||||
// 清理临时元素
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示复制成功的反馈
|
||||
function showCopySuccess() {
|
||||
const copyBtn = document.querySelector('.copy-btn');
|
||||
const originalHtml = copyBtn.innerHTML;
|
||||
copyBtn.innerHTML = '<i class="fas fa-check"></i> 已复制';
|
||||
copyBtn.classList.add('copied');
|
||||
|
||||
setTimeout(() => {
|
||||
copyBtn.innerHTML = originalHtml;
|
||||
copyBtn.classList.remove('copied');
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// 绑定复制按钮点击事件
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const copyBtn = document.querySelector('.copy-btn');
|
||||
copyBtn.addEventListener('click', function() {
|
||||
const targetId = this.dataset.target;
|
||||
const text = document.getElementById(targetId).textContent;
|
||||
copyToClipboard(text);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 添加复制按钮样式 */
|
||||
.copy-btn {
|
||||
padding: 8px 16px;
|
||||
background-color: #4a90e2;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.copy-btn:hover {
|
||||
background-color: #357abd;
|
||||
}
|
||||
|
||||
.copy-btn.copied {
|
||||
background-color: #45a049;
|
||||
}
|
||||
|
||||
.copy-btn i {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
/* 生成的提示词样式 */
|
||||
#generatedPrompt {
|
||||
background-color: #f8f9fa;
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
white-space: pre-wrap;
|
||||
font-family: monospace;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* 加载指示器样式 */
|
||||
#loadingIndicator {
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
.spinner-border {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}首页{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="hero">
|
||||
<h1>欢迎使用提示词大师</h1>
|
||||
<p>智能生成高质量提示词,提升您的工作效率</p>
|
||||
<a href="{{ url_for('main.generate_prompt') }}" class="cta-button">开始生成</a>
|
||||
</section>
|
||||
|
||||
<section class="features">
|
||||
<div class="feature">
|
||||
<h2>智能生成</h2>
|
||||
<p>基于先进的大模型技术,快速生成精准提示词</p>
|
||||
</div>
|
||||
<div class="feature">
|
||||
<h2>用户友好</h2>
|
||||
<p>简洁直观的界面设计,轻松上手</p>
|
||||
</div>
|
||||
<div class="feature">
|
||||
<h2>持续优化</h2>
|
||||
<p>通过用户反馈不断改进提示词质量</p>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -1,105 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}生成结果{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="prompt-container">
|
||||
<h1>生成结果</h1>
|
||||
|
||||
<div class="prompt-card">
|
||||
<div class="prompt-section">
|
||||
<h2>原始文本</h2>
|
||||
<div class="text-content">{{ prompt.input_text }}</div>
|
||||
</div>
|
||||
|
||||
<div class="prompt-section">
|
||||
<h2>生成的提示词</h2>
|
||||
<div class="text-content">{{ prompt.generated_text }}</div>
|
||||
<button class="btn btn-copy" onclick="copyText('{{ prompt.generated_text }}')">复制</button>
|
||||
</div>
|
||||
|
||||
<div class="prompt-actions">
|
||||
<a href="{{ url_for('main.index') }}" class="btn btn-primary">继续生成</a>
|
||||
<a href="{{ url_for('main.submit_feedback', prompt_id=prompt.id) }}" class="btn btn-secondary">提供反馈</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.prompt-container {
|
||||
max-width: 800px;
|
||||
margin: 2rem auto;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.prompt-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.prompt-section {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.prompt-section h2 {
|
||||
color: #333;
|
||||
font-size: 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.text-content {
|
||||
background: #f8f9fa;
|
||||
padding: 1rem;
|
||||
border-radius: 4px;
|
||||
white-space: pre-wrap;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.prompt-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 0.75rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #2196f3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-copy {
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function copyText(text) {
|
||||
navigator.clipboard.writeText(text).then(function() {
|
||||
alert('已复制到剪贴板');
|
||||
}).catch(function(err) {
|
||||
console.error('复制失败:', err);
|
||||
alert('复制失败,请手动复制');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,366 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<!-- 页面标题区域 -->
|
||||
<div class="page-header">
|
||||
<h1>提示词模板库</h1>
|
||||
<p class="subtitle">选择适合您需求的专业模板</p>
|
||||
</div>
|
||||
|
||||
<!-- 分类导航 -->
|
||||
<div class="category-nav">
|
||||
<div class="category-item {% if current_category == '全部' %}active{% endif %}">
|
||||
<i class="fas fa-th-large"></i>
|
||||
<a href="{{ url_for('prompts.list', category='全部') }}">全部模板</a>
|
||||
</div>
|
||||
{% for category, info in categories.items() %}
|
||||
<div class="category-item {% if current_category == category %}active{% endif %}">
|
||||
<i class="{{ info.icon }}"></i>
|
||||
<a href="{{ url_for('prompts.list', category=category) }}">
|
||||
{{ category }}
|
||||
<span class="template-count">{{ info.templates|length }}</span>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- 搜索和筛选区域 -->
|
||||
<div class="filter-section">
|
||||
<div class="search-box">
|
||||
<i class="fas fa-search"></i>
|
||||
<input type="text" placeholder="搜索模板..." id="templateSearch">
|
||||
</div>
|
||||
<div class="view-toggle">
|
||||
<button class="view-btn active" data-view="grid">
|
||||
<i class="fas fa-th-large"></i>
|
||||
</button>
|
||||
<button class="view-btn" data-view="list">
|
||||
<i class="fas fa-list"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 模板列表 -->
|
||||
<div class="template-grid" id="templateContainer">
|
||||
{% for template in templates %}
|
||||
<div class="template-card" data-category="{{ template.category }}">
|
||||
<div class="card-header">
|
||||
<i class="{{ categories[template.category].icon if template.category in categories }}"></i>
|
||||
<h3>{{ template.name }}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="description">{{ template.description }}</p>
|
||||
<div class="tags">
|
||||
<span class="tag industry">
|
||||
<i class="fas fa-building"></i>
|
||||
{{ template.industry }}
|
||||
</span>
|
||||
<span class="tag profession">
|
||||
<i class="fas fa-user-tie"></i>
|
||||
{{ template.profession }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button class="btn-preview" onclick="previewTemplate('{{ template.id }}')">
|
||||
<i class="fas fa-eye"></i> 预览
|
||||
</button>
|
||||
<button class="btn-use" onclick="useTemplate('{{ template.id }}')">
|
||||
<i class="fas fa-plus"></i> 使用模板
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- 分页控件 -->
|
||||
<div class="pagination">
|
||||
{% if page > 1 %}
|
||||
<a href="{{ url_for('prompts.list', page=page-1, category=current_category) }}" class="page-btn">
|
||||
<i class="fas fa-chevron-left"></i> 上一页
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="page-numbers">
|
||||
{% for p in range(1, total_pages + 1) %}
|
||||
<a href="{{ url_for('prompts.list', page=p, category=current_category) }}"
|
||||
class="page-number {% if p == page %}active{% endif %}">
|
||||
{{ p }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if has_next %}
|
||||
<a href="{{ url_for('prompts.list', page=page+1, category=current_category) }}" class="page-btn">
|
||||
下一页 <i class="fas fa-chevron-right"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 模板预览模态框 -->
|
||||
<div class="modal" id="previewModal">
|
||||
<div class="modal-content">
|
||||
<span class="close">×</span>
|
||||
<div class="modal-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #2563eb;
|
||||
--secondary-color: #3b82f6;
|
||||
--background-color: #f8fafc;
|
||||
--text-color: #1e293b;
|
||||
--border-color: #e2e8f0;
|
||||
--hover-color: #dbeafe;
|
||||
--shadow-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
text-align: center;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
font-size: 2.5rem;
|
||||
color: var(--text-color);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: #64748b;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.category-nav {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
overflow-x: auto;
|
||||
padding: 1rem;
|
||||
scrollbar-width: thin;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
padding: 0.75rem 1.25rem;
|
||||
border-radius: 999px;
|
||||
background: white;
|
||||
box-shadow: 0 1px 3px var(--shadow-color);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.category-item:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 6px var(--shadow-color);
|
||||
}
|
||||
|
||||
.category-item.active {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.template-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
gap: 2rem;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.template-card {
|
||||
border-radius: 12px;
|
||||
background: white;
|
||||
box-shadow: 0 2px 4px var(--shadow-color);
|
||||
transition: all 0.3s ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.template-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 16px var(--shadow-color);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
padding: 1.25rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.card-header i {
|
||||
font-size: 1.5rem;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: #64748b;
|
||||
margin-bottom: 1rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.tag {
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.875rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.tag.industry {
|
||||
background: #dbeafe;
|
||||
color: #1e40af;
|
||||
}
|
||||
|
||||
.tag.profession {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
padding: 1.25rem;
|
||||
border-top: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.btn-preview, .btn-use {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.btn-preview {
|
||||
background: #f1f5f9;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.btn-use {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-preview:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.btn-use:hover {
|
||||
background: var(--secondary-color);
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.template-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.category-nav {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* 动画效果 */
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.template-card {
|
||||
animation: fadeIn 0.5s ease-out;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 搜索功能
|
||||
const searchInput = document.getElementById('templateSearch');
|
||||
const templateContainer = document.getElementById('templateContainer');
|
||||
const templateCards = templateContainer.getElementsByClassName('template-card');
|
||||
|
||||
searchInput.addEventListener('input', function(e) {
|
||||
const searchTerm = e.target.value.toLowerCase();
|
||||
|
||||
Array.from(templateCards).forEach(card => {
|
||||
const title = card.querySelector('h3').textContent.toLowerCase();
|
||||
const description = card.querySelector('.description').textContent.toLowerCase();
|
||||
|
||||
if (title.includes(searchTerm) || description.includes(searchTerm)) {
|
||||
card.style.display = '';
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 视图切换
|
||||
const viewButtons = document.querySelectorAll('.view-btn');
|
||||
viewButtons.forEach(btn => {
|
||||
btn.addEventListener('click', function() {
|
||||
viewButtons.forEach(b => b.classList.remove('active'));
|
||||
this.classList.add('active');
|
||||
|
||||
const viewType = this.dataset.view;
|
||||
templateContainer.className = `template-${viewType}`;
|
||||
});
|
||||
});
|
||||
|
||||
// 模板预览
|
||||
const modal = document.getElementById('previewModal');
|
||||
const closeBtn = modal.querySelector('.close');
|
||||
|
||||
window.previewTemplate = function(templateId) {
|
||||
modal.style.display = 'block';
|
||||
// 这里添加获取模板预览数据的逻辑
|
||||
}
|
||||
|
||||
closeBtn.onclick = function() {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
|
||||
window.onclick = function(event) {
|
||||
if (event.target == modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user