veadk-python 0.2.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- veadk/__init__.py +37 -0
- veadk/a2a/__init__.py +13 -0
- veadk/a2a/agent_card.py +45 -0
- veadk/a2a/remote_ve_agent.py +390 -0
- veadk/a2a/utils/__init__.py +13 -0
- veadk/a2a/utils/agent_to_a2a.py +170 -0
- veadk/a2a/ve_a2a_server.py +93 -0
- veadk/a2a/ve_agent_executor.py +78 -0
- veadk/a2a/ve_middlewares.py +313 -0
- veadk/a2a/ve_task_store.py +37 -0
- veadk/agent.py +402 -0
- veadk/agent_builder.py +93 -0
- veadk/agents/loop_agent.py +68 -0
- veadk/agents/parallel_agent.py +72 -0
- veadk/agents/sequential_agent.py +64 -0
- veadk/auth/__init__.py +13 -0
- veadk/auth/base_auth.py +22 -0
- veadk/auth/ve_credential_service.py +203 -0
- veadk/auth/veauth/__init__.py +13 -0
- veadk/auth/veauth/apmplus_veauth.py +58 -0
- veadk/auth/veauth/ark_veauth.py +75 -0
- veadk/auth/veauth/base_veauth.py +50 -0
- veadk/auth/veauth/cozeloop_veauth.py +13 -0
- veadk/auth/veauth/opensearch_veauth.py +75 -0
- veadk/auth/veauth/postgresql_veauth.py +75 -0
- veadk/auth/veauth/prompt_pilot_veauth.py +60 -0
- veadk/auth/veauth/speech_veauth.py +54 -0
- veadk/auth/veauth/utils.py +69 -0
- veadk/auth/veauth/vesearch_veauth.py +62 -0
- veadk/auth/veauth/viking_mem0_veauth.py +91 -0
- veadk/cli/__init__.py +13 -0
- veadk/cli/cli.py +58 -0
- veadk/cli/cli_clean.py +87 -0
- veadk/cli/cli_create.py +163 -0
- veadk/cli/cli_deploy.py +233 -0
- veadk/cli/cli_eval.py +215 -0
- veadk/cli/cli_init.py +214 -0
- veadk/cli/cli_kb.py +110 -0
- veadk/cli/cli_pipeline.py +285 -0
- veadk/cli/cli_prompt.py +86 -0
- veadk/cli/cli_update.py +106 -0
- veadk/cli/cli_uploadevalset.py +139 -0
- veadk/cli/cli_web.py +143 -0
- veadk/cloud/__init__.py +13 -0
- veadk/cloud/cloud_agent_engine.py +485 -0
- veadk/cloud/cloud_app.py +475 -0
- veadk/config.py +115 -0
- veadk/configs/__init__.py +13 -0
- veadk/configs/auth_configs.py +133 -0
- veadk/configs/database_configs.py +132 -0
- veadk/configs/model_configs.py +78 -0
- veadk/configs/tool_configs.py +54 -0
- veadk/configs/tracing_configs.py +110 -0
- veadk/consts.py +74 -0
- veadk/evaluation/__init__.py +17 -0
- veadk/evaluation/adk_evaluator/__init__.py +17 -0
- veadk/evaluation/adk_evaluator/adk_evaluator.py +302 -0
- veadk/evaluation/base_evaluator.py +642 -0
- veadk/evaluation/deepeval_evaluator/__init__.py +17 -0
- veadk/evaluation/deepeval_evaluator/deepeval_evaluator.py +339 -0
- veadk/evaluation/eval_set_file_loader.py +48 -0
- veadk/evaluation/eval_set_recorder.py +146 -0
- veadk/evaluation/types.py +65 -0
- veadk/evaluation/utils/prometheus.py +196 -0
- veadk/integrations/__init__.py +13 -0
- veadk/integrations/ve_apig/__init__.py +13 -0
- veadk/integrations/ve_apig/ve_apig.py +349 -0
- veadk/integrations/ve_apig/ve_apig_utils.py +332 -0
- veadk/integrations/ve_code_pipeline/__init__.py +13 -0
- veadk/integrations/ve_code_pipeline/ve_code_pipeline.py +431 -0
- veadk/integrations/ve_cozeloop/__init__.py +13 -0
- veadk/integrations/ve_cozeloop/ve_cozeloop.py +96 -0
- veadk/integrations/ve_cr/__init__.py +13 -0
- veadk/integrations/ve_cr/ve_cr.py +220 -0
- veadk/integrations/ve_faas/__init__.py +13 -0
- veadk/integrations/ve_faas/template/cookiecutter.json +15 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/__init__.py +13 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/clean.py +23 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/config.yaml.example +6 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/deploy.py +106 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/__init__.py +13 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/agent.py +25 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py +202 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/requirements.txt +3 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/run.sh +49 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{ cookiecutter.app_name }}/__init__.py +14 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{ cookiecutter.app_name }}/agent.py +27 -0
- veadk/integrations/ve_faas/ve_faas.py +754 -0
- veadk/integrations/ve_faas/ve_faas_utils.py +408 -0
- veadk/integrations/ve_faas/web_template/cookiecutter.json +20 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/__init__.py +13 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/clean.py +23 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/config.yaml.example +2 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/deploy.py +44 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/Dockerfile +23 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/app.py +123 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/init_db.py +46 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/models.py +36 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/requirements.txt +4 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/run.sh +21 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/css/style.css +368 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/js/admin.js +0 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/dashboard.html +21 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/edit_post.html +24 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/login.html +21 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/posts.html +53 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/base.html +45 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/index.html +29 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/post.html +14 -0
- veadk/integrations/ve_identity/__init__.py +110 -0
- veadk/integrations/ve_identity/auth_config.py +261 -0
- veadk/integrations/ve_identity/auth_mixins.py +650 -0
- veadk/integrations/ve_identity/auth_processor.py +385 -0
- veadk/integrations/ve_identity/function_tool.py +158 -0
- veadk/integrations/ve_identity/identity_client.py +864 -0
- veadk/integrations/ve_identity/mcp_tool.py +181 -0
- veadk/integrations/ve_identity/mcp_toolset.py +431 -0
- veadk/integrations/ve_identity/models.py +228 -0
- veadk/integrations/ve_identity/token_manager.py +188 -0
- veadk/integrations/ve_identity/utils.py +151 -0
- veadk/integrations/ve_prompt_pilot/__init__.py +13 -0
- veadk/integrations/ve_prompt_pilot/ve_prompt_pilot.py +85 -0
- veadk/integrations/ve_tls/__init__.py +13 -0
- veadk/integrations/ve_tls/utils.py +116 -0
- veadk/integrations/ve_tls/ve_tls.py +212 -0
- veadk/integrations/ve_tos/ve_tos.py +710 -0
- veadk/integrations/ve_viking_db_memory/__init__.py +13 -0
- veadk/integrations/ve_viking_db_memory/ve_viking_db_memory.py +308 -0
- veadk/knowledgebase/__init__.py +17 -0
- veadk/knowledgebase/backends/__init__.py +13 -0
- veadk/knowledgebase/backends/base_backend.py +72 -0
- veadk/knowledgebase/backends/in_memory_backend.py +91 -0
- veadk/knowledgebase/backends/opensearch_backend.py +162 -0
- veadk/knowledgebase/backends/redis_backend.py +172 -0
- veadk/knowledgebase/backends/utils.py +92 -0
- veadk/knowledgebase/backends/vikingdb_knowledge_backend.py +608 -0
- veadk/knowledgebase/entry.py +25 -0
- veadk/knowledgebase/knowledgebase.py +307 -0
- veadk/memory/__init__.py +35 -0
- veadk/memory/long_term_memory.py +365 -0
- veadk/memory/long_term_memory_backends/__init__.py +13 -0
- veadk/memory/long_term_memory_backends/base_backend.py +35 -0
- veadk/memory/long_term_memory_backends/in_memory_backend.py +67 -0
- veadk/memory/long_term_memory_backends/mem0_backend.py +155 -0
- veadk/memory/long_term_memory_backends/opensearch_backend.py +124 -0
- veadk/memory/long_term_memory_backends/redis_backend.py +140 -0
- veadk/memory/long_term_memory_backends/vikingdb_memory_backend.py +189 -0
- veadk/memory/short_term_memory.py +252 -0
- veadk/memory/short_term_memory_backends/__init__.py +13 -0
- veadk/memory/short_term_memory_backends/base_backend.py +31 -0
- veadk/memory/short_term_memory_backends/mysql_backend.py +49 -0
- veadk/memory/short_term_memory_backends/postgresql_backend.py +49 -0
- veadk/memory/short_term_memory_backends/sqlite_backend.py +55 -0
- veadk/memory/short_term_memory_processor.py +100 -0
- veadk/processors/__init__.py +26 -0
- veadk/processors/base_run_processor.py +120 -0
- veadk/prompts/__init__.py +13 -0
- veadk/prompts/agent_default_prompt.py +30 -0
- veadk/prompts/prompt_evaluator.py +20 -0
- veadk/prompts/prompt_memory_processor.py +55 -0
- veadk/prompts/prompt_optimization.py +150 -0
- veadk/runner.py +732 -0
- veadk/tools/__init__.py +13 -0
- veadk/tools/builtin_tools/__init__.py +13 -0
- veadk/tools/builtin_tools/agent_authorization.py +94 -0
- veadk/tools/builtin_tools/generate_image.py +23 -0
- veadk/tools/builtin_tools/image_edit.py +300 -0
- veadk/tools/builtin_tools/image_generate.py +446 -0
- veadk/tools/builtin_tools/lark.py +67 -0
- veadk/tools/builtin_tools/las.py +24 -0
- veadk/tools/builtin_tools/link_reader.py +66 -0
- veadk/tools/builtin_tools/llm_shield.py +381 -0
- veadk/tools/builtin_tools/load_knowledgebase.py +97 -0
- veadk/tools/builtin_tools/mcp_router.py +29 -0
- veadk/tools/builtin_tools/run_code.py +113 -0
- veadk/tools/builtin_tools/tts.py +253 -0
- veadk/tools/builtin_tools/vesearch.py +49 -0
- veadk/tools/builtin_tools/video_generate.py +363 -0
- veadk/tools/builtin_tools/web_scraper.py +76 -0
- veadk/tools/builtin_tools/web_search.py +83 -0
- veadk/tools/demo_tools.py +58 -0
- veadk/tools/load_knowledgebase_tool.py +149 -0
- veadk/tools/sandbox/__init__.py +13 -0
- veadk/tools/sandbox/browser_sandbox.py +37 -0
- veadk/tools/sandbox/code_sandbox.py +40 -0
- veadk/tools/sandbox/computer_sandbox.py +34 -0
- veadk/tracing/__init__.py +13 -0
- veadk/tracing/base_tracer.py +58 -0
- veadk/tracing/telemetry/__init__.py +13 -0
- veadk/tracing/telemetry/attributes/attributes.py +29 -0
- veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py +180 -0
- veadk/tracing/telemetry/attributes/extractors/llm_attributes_extractors.py +858 -0
- veadk/tracing/telemetry/attributes/extractors/tool_attributes_extractors.py +152 -0
- veadk/tracing/telemetry/attributes/extractors/types.py +164 -0
- veadk/tracing/telemetry/exporters/__init__.py +13 -0
- veadk/tracing/telemetry/exporters/apmplus_exporter.py +558 -0
- veadk/tracing/telemetry/exporters/base_exporter.py +39 -0
- veadk/tracing/telemetry/exporters/cozeloop_exporter.py +129 -0
- veadk/tracing/telemetry/exporters/inmemory_exporter.py +248 -0
- veadk/tracing/telemetry/exporters/tls_exporter.py +139 -0
- veadk/tracing/telemetry/opentelemetry_tracer.py +320 -0
- veadk/tracing/telemetry/telemetry.py +411 -0
- veadk/types.py +47 -0
- veadk/utils/__init__.py +13 -0
- veadk/utils/audio_manager.py +95 -0
- veadk/utils/auth.py +294 -0
- veadk/utils/logger.py +59 -0
- veadk/utils/mcp_utils.py +44 -0
- veadk/utils/misc.py +184 -0
- veadk/utils/patches.py +101 -0
- veadk/utils/volcengine_sign.py +205 -0
- veadk/version.py +15 -0
- veadk_python-0.2.27.dist-info/METADATA +373 -0
- veadk_python-0.2.27.dist-info/RECORD +218 -0
- veadk_python-0.2.27.dist-info/WHEEL +5 -0
- veadk_python-0.2.27.dist-info/entry_points.txt +2 -0
- veadk_python-0.2.27.dist-info/licenses/LICENSE +201 -0
- veadk_python-0.2.27.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from app import app, db
|
|
16
|
+
from models import User
|
|
17
|
+
from werkzeug.security import generate_password_hash
|
|
18
|
+
from sqlalchemy.exc import OperationalError
|
|
19
|
+
|
|
20
|
+
def init_database():
|
|
21
|
+
with app.app_context():
|
|
22
|
+
try:
|
|
23
|
+
# 创建所有数据库表
|
|
24
|
+
db.metadata.create_all(bind=db.engine, checkfirst=True)
|
|
25
|
+
print("数据库表创建成功")
|
|
26
|
+
except OperationalError as e:
|
|
27
|
+
if "table already exists" in str(e).lower():
|
|
28
|
+
print("数据库表已存在,跳过创建")
|
|
29
|
+
else:
|
|
30
|
+
print(f"创建数据库表时出错: {e}")
|
|
31
|
+
raise
|
|
32
|
+
|
|
33
|
+
# 创建默认管理员账户(如不存在)
|
|
34
|
+
if not User.query.filter_by(username='admin').first():
|
|
35
|
+
admin = User(
|
|
36
|
+
username='admin',
|
|
37
|
+
password=generate_password_hash('admin123')
|
|
38
|
+
)
|
|
39
|
+
db.session.add(admin)
|
|
40
|
+
db.session.commit()
|
|
41
|
+
print("默认管理员账户创建成功")
|
|
42
|
+
else:
|
|
43
|
+
print("默认管理员账户已存在,跳过创建")
|
|
44
|
+
|
|
45
|
+
if __name__ == '__main__':
|
|
46
|
+
init_database()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from flask_sqlalchemy import SQLAlchemy
|
|
16
|
+
from datetime import datetime
|
|
17
|
+
|
|
18
|
+
db = SQLAlchemy()
|
|
19
|
+
|
|
20
|
+
class Post(db.Model):
|
|
21
|
+
id = db.Column(db.Integer, primary_key=True)
|
|
22
|
+
title = db.Column(db.String(200), nullable=False)
|
|
23
|
+
content = db.Column(db.Text, nullable=False)
|
|
24
|
+
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
|
25
|
+
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
26
|
+
|
|
27
|
+
def __repr__(self):
|
|
28
|
+
return f'<Post {self.title}>'
|
|
29
|
+
|
|
30
|
+
class User(db.Model):
|
|
31
|
+
id = db.Column(db.Integer, primary_key=True)
|
|
32
|
+
username = db.Column(db.String(80), unique=True, nullable=False)
|
|
33
|
+
password = db.Column(db.String(200), nullable=False)
|
|
34
|
+
|
|
35
|
+
def __repr__(self):
|
|
36
|
+
return f'<User {self.username}>'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# 兼容源码部署到faas & 镜像部署到faas
|
|
4
|
+
pip install -r requirements.txt
|
|
5
|
+
|
|
6
|
+
HOST="0.0.0.0"
|
|
7
|
+
PORT="${_FAAS_RUNTIME_PORT:-8000}"
|
|
8
|
+
|
|
9
|
+
export SERVER_HOST=$HOST
|
|
10
|
+
export SERVER_PORT=$PORT
|
|
11
|
+
|
|
12
|
+
# 设置环境变量
|
|
13
|
+
export FLASK_APP=app.py
|
|
14
|
+
export FLASK_ENV=production
|
|
15
|
+
|
|
16
|
+
# 初始化数据库
|
|
17
|
+
python init_db.py
|
|
18
|
+
|
|
19
|
+
echo "Starting Web application..."
|
|
20
|
+
# 启动应用,使用生产服务器配置
|
|
21
|
+
exec python -m gunicorn -w 4 -b $SERVER_HOST:$SERVER_PORT app:app
|
veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/css/style.css
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/* 基础样式 */
|
|
2
|
+
* {
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
body {
|
|
9
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
10
|
+
line-height: 1.6;
|
|
11
|
+
color: #333;
|
|
12
|
+
background-color: #f8f9fa;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.container {
|
|
16
|
+
max-width: 1200px;
|
|
17
|
+
margin: 0 auto;
|
|
18
|
+
padding: 0 20px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* 头部 */
|
|
22
|
+
header {
|
|
23
|
+
background-color: #fff;
|
|
24
|
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
|
25
|
+
padding: 1rem 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
header h1 a {
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
color: #2c3e50;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
header nav {
|
|
34
|
+
float: right;
|
|
35
|
+
margin-top: 10px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
header nav a {
|
|
39
|
+
margin-left: 20px;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
color: #3498db;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
header nav a:hover {
|
|
45
|
+
text-decoration: underline;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* 主体内容 */
|
|
49
|
+
main {
|
|
50
|
+
padding: 2rem 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* 消息提示 */
|
|
54
|
+
.flash-messages {
|
|
55
|
+
margin-bottom: 20px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.flash-message {
|
|
59
|
+
padding: 10px;
|
|
60
|
+
background-color: #d4edda;
|
|
61
|
+
border: 1px solid #c3e6cb;
|
|
62
|
+
border-radius: 4px;
|
|
63
|
+
color: #155724;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* 文章列表 */
|
|
67
|
+
.post-preview {
|
|
68
|
+
background: white;
|
|
69
|
+
margin-bottom: 20px;
|
|
70
|
+
padding: 20px;
|
|
71
|
+
border-radius: 5px;
|
|
72
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.post-preview h2 a {
|
|
76
|
+
text-decoration: none;
|
|
77
|
+
color: #2c3e50;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.post-preview h2 a:hover {
|
|
81
|
+
color: #3498db;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.post-meta {
|
|
85
|
+
color: #7f8c8d;
|
|
86
|
+
font-size: 0.9em;
|
|
87
|
+
margin: 10px 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.read-more {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
margin-top: 10px;
|
|
93
|
+
color: #3498db;
|
|
94
|
+
text-decoration: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.read-more:hover {
|
|
98
|
+
text-decoration: underline;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* 文章详情 */
|
|
102
|
+
.post-detail {
|
|
103
|
+
background: white;
|
|
104
|
+
padding: 30px;
|
|
105
|
+
border-radius: 5px;
|
|
106
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.post-detail h1 {
|
|
110
|
+
margin-bottom: 10px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.post-content {
|
|
114
|
+
margin: 20px 0;
|
|
115
|
+
white-space: pre-wrap;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.back-link {
|
|
119
|
+
display: inline-block;
|
|
120
|
+
margin-top: 20px;
|
|
121
|
+
color: #3498db;
|
|
122
|
+
text-decoration: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* 分页 */
|
|
126
|
+
.pagination {
|
|
127
|
+
text-align: center;
|
|
128
|
+
margin: 30px 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.pagination a {
|
|
132
|
+
display: inline-block;
|
|
133
|
+
padding: 8px 16px;
|
|
134
|
+
margin: 0 5px;
|
|
135
|
+
text-decoration: none;
|
|
136
|
+
background-color: #3498db;
|
|
137
|
+
color: white;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.pagination a:hover {
|
|
142
|
+
background-color: #2980b9;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.pagination span {
|
|
146
|
+
display: inline-block;
|
|
147
|
+
padding: 8px 16px;
|
|
148
|
+
margin: 0 5px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* 登录表单 */
|
|
152
|
+
.login-form {
|
|
153
|
+
max-width: 400px;
|
|
154
|
+
margin: 50px auto;
|
|
155
|
+
background: white;
|
|
156
|
+
padding: 30px;
|
|
157
|
+
border-radius: 5px;
|
|
158
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.login-form h2 {
|
|
162
|
+
text-align: center;
|
|
163
|
+
margin-bottom: 20px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.form-group {
|
|
167
|
+
margin-bottom: 20px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.form-group label {
|
|
171
|
+
display: block;
|
|
172
|
+
margin-bottom: 5px;
|
|
173
|
+
font-weight: bold;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.form-group input {
|
|
177
|
+
width: 100%;
|
|
178
|
+
padding: 10px;
|
|
179
|
+
border: 1px solid #ddd;
|
|
180
|
+
border-radius: 4px;
|
|
181
|
+
font-size: 16px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.form-group input:focus {
|
|
185
|
+
border-color: #3498db;
|
|
186
|
+
outline: none;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
button, .btn {
|
|
190
|
+
display: inline-block;
|
|
191
|
+
padding: 10px 20px;
|
|
192
|
+
background-color: #3498db;
|
|
193
|
+
color: white;
|
|
194
|
+
text-decoration: none;
|
|
195
|
+
border: none;
|
|
196
|
+
border-radius: 4px;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
font-size: 16px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
button:hover, .btn:hover {
|
|
202
|
+
background-color: #2980b9;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.hint {
|
|
206
|
+
margin-top: 20px;
|
|
207
|
+
text-align: center;
|
|
208
|
+
color: #7f8c8d;
|
|
209
|
+
font-size: 0.9em;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* 管理面板 */
|
|
213
|
+
.admin-dashboard {
|
|
214
|
+
background: white;
|
|
215
|
+
padding: 30px;
|
|
216
|
+
border-radius: 5px;
|
|
217
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.stats {
|
|
221
|
+
display: flex;
|
|
222
|
+
margin: 30px 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.stat-card {
|
|
226
|
+
flex: 1;
|
|
227
|
+
text-align: center;
|
|
228
|
+
padding: 20px;
|
|
229
|
+
background-color: #f1f8ff;
|
|
230
|
+
border-radius: 5px;
|
|
231
|
+
margin: 0 10px;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.stat-number {
|
|
235
|
+
font-size: 2em;
|
|
236
|
+
font-weight: bold;
|
|
237
|
+
color: #3498db;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.admin-links {
|
|
241
|
+
text-align: center;
|
|
242
|
+
margin-top: 30px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.admin-links .btn {
|
|
246
|
+
margin: 0 10px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* 文章管理 */
|
|
250
|
+
.admin-posts {
|
|
251
|
+
background: white;
|
|
252
|
+
padding: 30px;
|
|
253
|
+
border-radius: 5px;
|
|
254
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.admin-header {
|
|
258
|
+
display: flex;
|
|
259
|
+
justify-content: space-between;
|
|
260
|
+
align-items: center;
|
|
261
|
+
margin-bottom: 20px;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.posts-table {
|
|
265
|
+
width: 100%;
|
|
266
|
+
border-collapse: collapse;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.posts-table th,
|
|
270
|
+
.posts-table td {
|
|
271
|
+
padding: 12px;
|
|
272
|
+
text-align: left;
|
|
273
|
+
border-bottom: 1px solid #ddd;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.posts-table th {
|
|
277
|
+
background-color: #f8f9fa;
|
|
278
|
+
font-weight: bold;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.posts-table td a {
|
|
282
|
+
color: #3498db;
|
|
283
|
+
text-decoration: none;
|
|
284
|
+
margin-right: 10px;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.posts-table td a:hover {
|
|
288
|
+
text-decoration: underline;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.delete-btn {
|
|
292
|
+
background: none;
|
|
293
|
+
border: none;
|
|
294
|
+
color: #e74c3c;
|
|
295
|
+
cursor: pointer;
|
|
296
|
+
padding: 0;
|
|
297
|
+
font-size: 1em;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.delete-btn:hover {
|
|
301
|
+
text-decoration: underline;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* 编辑文章 */
|
|
305
|
+
.edit-post {
|
|
306
|
+
background: white;
|
|
307
|
+
padding: 30px;
|
|
308
|
+
border-radius: 5px;
|
|
309
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.edit-post textarea {
|
|
313
|
+
width: 100%;
|
|
314
|
+
padding: 10px;
|
|
315
|
+
border: 1px solid #ddd;
|
|
316
|
+
border-radius: 4px;
|
|
317
|
+
font-family: inherit;
|
|
318
|
+
font-size: 16px;
|
|
319
|
+
resize: vertical;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.form-actions {
|
|
323
|
+
margin-top: 20px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.btn-cancel {
|
|
327
|
+
background-color: #95a5a6;
|
|
328
|
+
margin-left: 10px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.btn-cancel:hover {
|
|
332
|
+
background-color: #7f8c8d;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* 页脚 */
|
|
336
|
+
footer {
|
|
337
|
+
background-color: #2c3e50;
|
|
338
|
+
color: white;
|
|
339
|
+
text-align: center;
|
|
340
|
+
padding: 20px 0;
|
|
341
|
+
margin-top: 40px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/* 响应式设计 */
|
|
345
|
+
@media (max-width: 768px) {
|
|
346
|
+
header nav {
|
|
347
|
+
float: none;
|
|
348
|
+
text-align: center;
|
|
349
|
+
margin-top: 10px;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.admin-header {
|
|
353
|
+
flex-direction: column;
|
|
354
|
+
align-items: flex-start;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.admin-header .btn {
|
|
358
|
+
margin-top: 10px;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.stats {
|
|
362
|
+
flex-direction: column;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.stat-card {
|
|
366
|
+
margin: 10px 0;
|
|
367
|
+
}
|
|
368
|
+
}
|
veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/js/admin.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}管理面板{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<div class="admin-dashboard">
|
|
7
|
+
<h2>管理面板</h2>
|
|
8
|
+
|
|
9
|
+
<div class="stats">
|
|
10
|
+
<div class="stat-card">
|
|
11
|
+
<h3>文章总数</h3>
|
|
12
|
+
<p class="stat-number">{{ post_count }}</p>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="admin-links">
|
|
17
|
+
<a href="{{ url_for('admin_posts') }}" class="btn">文章管理</a>
|
|
18
|
+
<a href="{{ url_for('admin_edit_post') }}" class="btn">新建文章</a>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
{% endblock %}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}{% if post.id %}编辑文章{% else %}新建文章{% endif %}{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<div class="edit-post">
|
|
7
|
+
<h2>{% if post.id %}编辑文章{% else %}新建文章{% endif %}</h2>
|
|
8
|
+
|
|
9
|
+
<form method="POST">
|
|
10
|
+
<div class="form-group">
|
|
11
|
+
<label for="title">标题:</label>
|
|
12
|
+
<input type="text" id="title" name="title" value="{{ post.title or '' }}" required>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="form-group">
|
|
15
|
+
<label for="content">内容:</label>
|
|
16
|
+
<textarea id="content" name="content" rows="15" required>{{ post.content or '' }}</textarea>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="form-actions">
|
|
19
|
+
<button type="submit">保存</button>
|
|
20
|
+
<a href="{{ url_for('admin_posts') }}" class="btn-cancel">取消</a>
|
|
21
|
+
</div>
|
|
22
|
+
</form>
|
|
23
|
+
</div>
|
|
24
|
+
{% endblock %}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}管理员登录{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<div class="login-form">
|
|
7
|
+
<h2>管理员登录</h2>
|
|
8
|
+
<form method="POST">
|
|
9
|
+
<div class="form-group">
|
|
10
|
+
<label for="username">用户名:</label>
|
|
11
|
+
<input type="text" id="username" name="username" required>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="form-group">
|
|
14
|
+
<label for="password">密码:</label>
|
|
15
|
+
<input type="password" id="password" name="password" required>
|
|
16
|
+
</div>
|
|
17
|
+
<button type="submit">登录</button>
|
|
18
|
+
</form>
|
|
19
|
+
<p class="hint">默认账号: admin / 密码: admin123</p>
|
|
20
|
+
</div>
|
|
21
|
+
{% endblock %}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}文章管理{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<div class="admin-posts">
|
|
7
|
+
<div class="admin-header">
|
|
8
|
+
<h2>文章管理</h2>
|
|
9
|
+
<a href="{{ url_for('admin_edit_post') }}" class="btn">新建文章</a>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<table class="posts-table">
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<th>标题</th>
|
|
16
|
+
<th>发布时间</th>
|
|
17
|
+
<th>操作</th>
|
|
18
|
+
</tr>
|
|
19
|
+
</thead>
|
|
20
|
+
<tbody>
|
|
21
|
+
{% for post in posts.items %}
|
|
22
|
+
<tr>
|
|
23
|
+
<td><a href="{{ url_for('post_detail', post_id=post.id) }}">{{ post.title }}</a></td>
|
|
24
|
+
<td>{{ post.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
|
25
|
+
<td>
|
|
26
|
+
<a href="{{ url_for('admin_edit_post', post_id=post.id) }}">编辑</a>
|
|
27
|
+
<form action="{{ url_for('admin_delete_post', post_id=post.id) }}" method="POST" style="display:inline;">
|
|
28
|
+
<button type="submit" class="delete-btn" onclick="return confirm('确定要删除这篇文章吗?')">删除</button>
|
|
29
|
+
</form>
|
|
30
|
+
</td>
|
|
31
|
+
</tr>
|
|
32
|
+
{% else %}
|
|
33
|
+
<tr>
|
|
34
|
+
<td colspan="3">暂无文章</td>
|
|
35
|
+
</tr>
|
|
36
|
+
{% endfor %}
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
<!-- 分页 -->
|
|
41
|
+
<div class="pagination">
|
|
42
|
+
{% if posts.has_prev %}
|
|
43
|
+
<a href="{{ url_for('admin_posts', page=posts.prev_num) }}">« 上一页</a>
|
|
44
|
+
{% endif %}
|
|
45
|
+
|
|
46
|
+
<span>第 {{ posts.page }} 页,共 {{ posts.pages }} 页</span>
|
|
47
|
+
|
|
48
|
+
{% if posts.has_next %}
|
|
49
|
+
<a href="{{ url_for('admin_posts', page=posts.next_num) }}">下一页 »</a>
|
|
50
|
+
{% endif %}
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
{% endblock %}
|
veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/base.html
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>{% block title %}博客系统{% endblock %}</title>
|
|
7
|
+
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<header>
|
|
11
|
+
<div class="container">
|
|
12
|
+
<h1><a href="{{ url_for('index') }}">我的博客</a></h1>
|
|
13
|
+
<nav>
|
|
14
|
+
<a href="{{ url_for('index') }}">首页</a>
|
|
15
|
+
{% if session.admin_logged_in %}
|
|
16
|
+
<a href="{{ url_for('admin_dashboard') }}">管理后台</a>
|
|
17
|
+
<a href="{{ url_for('admin_logout') }}">退出</a>
|
|
18
|
+
{% else %}
|
|
19
|
+
<a href="{{ url_for('admin_login') }}">登录</a>
|
|
20
|
+
{% endif %}
|
|
21
|
+
</nav>
|
|
22
|
+
</div>
|
|
23
|
+
</header>
|
|
24
|
+
|
|
25
|
+
<main class="container">
|
|
26
|
+
{% with messages = get_flashed_messages() %}
|
|
27
|
+
{% if messages %}
|
|
28
|
+
<div class="flash-messages">
|
|
29
|
+
{% for message in messages %}
|
|
30
|
+
<div class="flash-message">{{ message }}</div>
|
|
31
|
+
{% endfor %}
|
|
32
|
+
</div>
|
|
33
|
+
{% endif %}
|
|
34
|
+
{% endwith %}
|
|
35
|
+
|
|
36
|
+
{% block content %}{% endblock %}
|
|
37
|
+
</main>
|
|
38
|
+
|
|
39
|
+
<footer>
|
|
40
|
+
<div class="container">
|
|
41
|
+
<p>© 2023 我的博客. All rights reserved.</p>
|
|
42
|
+
</div>
|
|
43
|
+
</footer>
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|
veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/index.html
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block content %}
|
|
4
|
+
<div class="posts">
|
|
5
|
+
{% for post in posts.items %}
|
|
6
|
+
<article class="post-preview">
|
|
7
|
+
<h2><a href="{{ url_for('post_detail', post_id=post.id) }}">{{ post.title }}</a></h2>
|
|
8
|
+
<p class="post-meta">发布于 {{ post.created_at.strftime('%Y-%m-%d %H:%M') }}</p>
|
|
9
|
+
<p>{{ post.content[:200] }}{% if post.content|length > 200 %}...{% endif %}</p>
|
|
10
|
+
<a href="{{ url_for('post_detail', post_id=post.id) }}" class="read-more">阅读全文</a>
|
|
11
|
+
</article>
|
|
12
|
+
{% else %}
|
|
13
|
+
<p>暂无文章。</p>
|
|
14
|
+
{% endfor %}
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<!-- 分页 -->
|
|
18
|
+
<div class="pagination">
|
|
19
|
+
{% if posts.has_prev %}
|
|
20
|
+
<a href="{{ url_for('index', page=posts.prev_num) }}">« 上一页</a>
|
|
21
|
+
{% endif %}
|
|
22
|
+
|
|
23
|
+
<span>第 {{ posts.page }} 页,共 {{ posts.pages }} 页</span>
|
|
24
|
+
|
|
25
|
+
{% if posts.has_next %}
|
|
26
|
+
<a href="{{ url_for('index', page=posts.next_num) }}">下一页 »</a>
|
|
27
|
+
{% endif %}
|
|
28
|
+
</div>
|
|
29
|
+
{% endblock %}
|
veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/post.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}{{ post.title }} - 博客系统{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block content %}
|
|
6
|
+
<article class="post-detail">
|
|
7
|
+
<h1>{{ post.title }}</h1>
|
|
8
|
+
<p class="post-meta">发布于 {{ post.created_at.strftime('%Y-%m-%d %H:%M') }}</p>
|
|
9
|
+
<div class="post-content">
|
|
10
|
+
{{ post.content|replace('\n', '<br>')|safe }}
|
|
11
|
+
</div>
|
|
12
|
+
<a href="{{ url_for('index') }}" class="back-link">« 返回首页</a>
|
|
13
|
+
</article>
|
|
14
|
+
{% endblock %}
|