当前位置:首页>python>Python 零基础100天—Day52 模板进阶

Python 零基础100天—Day52 模板进阶

  • 2026-07-04 00:11:33
Python 零基础100天—Day52 模板进阶

🐍 Python Day52:模板进阶 — 让页面更优雅

🕐 预计用时:2-3 小时 | 🎯 目标:掌握模板继承、宏、自定义过滤器和静态文件管理


📖 今日目录

  1. 为什么需要模板进阶?
  2. 模板继承
  3. 块(Block)详解
  4. 宏(Macro)
  5. 自定义过滤器
  6. 内置过滤器大全
  7. 静态文件
  8. 模板包含(include)
  9. 全局变量与上下文处理器
  10. 今日练习
  11. 今日小结

1. 为什么需要模板进阶?

昨天我们写了第一个模板,但有个明显的问题——每个页面都写了完整的 HTML 结构:

<!-- home.html -->
<html><head><title>首页</title></head>
<body><nav>...导航栏...</nav> 页面内容 </body></html>

<!-- about.html -->
<html><head><title>关于</title></head>
<body><nav>...导航栏...</nav> 页面内容 </body></html>

<!-- contact.html -->
<html><head><title>联系</title></head>
<body><nav>...导航栏...</nav> 页面内容 </body></html>

想象你有 100 个页面,老板说"把导航栏的 Logo 换一下"——你要改 100 个文件!这简直是维护噩梦。

💡 模板继承 = 印章 + 填空题

你刻一个"印章"(base.html),上面有网站的通用结构:HTML骨架、导航栏、页脚。每个子页面只需要"填空"——在指定位置填入自己的独特内容。


2. 模板继承

🏗️ Step 1:创建基础模板

<!-- templates/base.html -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{% block title %}我的网站{% endblock %}</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <!-- 导航栏(所有页面共享) -->
    <nav>
        <a href="/">首页</a>
        <a href="/about">关于</a>
        <a href="/contact">联系</a>
    </nav>

    <!-- 主内容区(每个页面不同) -->
    <main>
        {% block content %}{% endblock %}
    </main>

    <!-- 页脚(所有页面共享) -->
    <footer>
        <p>&copy; 2026 我的网站</p>
    </footer>
</body>
</html>

📝 Step 2:子模板继承基础模板

<!-- templates/home.html -->
{% extends "base.html" %}

{% block title %}首页 - 我的网站{% endblock %}

{% block content %}
    <h1>🏠 欢迎来到首页</h1>
    <p>这是首页内容,只写独特部分就行!</p>
{% endblock %}
<!-- templates/about.html -->
{% extends "base.html" %}

{% block title %}关于我们{% endblock %}

{% block content %}
    <h1>📖 关于我们</h1>
    <p>我们是一个热爱 Python 的团队。</p>
{% endblock %}

看到神奇之处了吗?子模板只需要写"填空题"的部分,导航栏、页脚、HTML骨架全部来自 base.html。

🔗 多层继承

继承可以多层叠加,就像家族族谱:

base.html           ← 爷爷(HTML骨架 + 导航 + 页脚)
  └── base_user.html ← 爸爸(继承爷爷 + 用户中心侧边栏)
       └── profile.html  ← 孙子(继承爸爸 + 个人资料内容)
       └── settings.html ← 孙子(继承爸爸 + 设置内容)
<!-- templates/base_user.html -->
{% extends "base.html" %}

{% block content %}
<div class="user-layout">
    <aside>
        <a href="/profile">个人资料</a>
        <a href="/settings">设置</a>
    </aside>
    <div class="user-main">
        {% block user_content %}{% endblock %}
    </div>
</div>
{% endblock %}
<!-- templates/profile.html -->
{% extends "base_user.html" %}

{% block user_content %}
    <h2>个人资料</h2>
    <p>用户名:{{ user.name }}</p>
{% endblock %}

3. 块(Block)详解

🧱 Block 的三种用法

{# 1. 基础定义(空块,子模板填充) #}
{% block content %}{% endblock %}

{# 2. 带默认内容(子模板可选择覆盖或使用默认) #}
{% block sidebar %}
    <p>这是默认侧边栏内容</p>
{% endblock %}

{# 3. 使用 super() 保留父模板内容并追加 #}
{% block content %}
    {{ super() }}  {# 保留父模板的 content 块 #}
    <p>这是追加的内容</p>
{% endblock %}

💡 super() 就像"追加"而非"覆盖":

• 不用 super() → 覆盖父模板的块内容
• 用 super() → 保留父模板的块内容 + 追加新内容

🚫 不能做的事

{# ❌ 不能在同一个模板中定义两次同名 block #}
{% block title %}首页{% endblock %}
{% block title %}关于{% endblock %}  {# 错误! #}

{# ❌ 不能在 if/for 内定义 block #}
{% if user %}
    {% block content %}...{% endblock %}  {# 错误! #}
{% endif %}

4. 宏(Macro)

🎭 什么是宏?

宏 = 模板里的函数。 如果你有一段 HTML 代码需要重复使用(比如按钮、表单字段、卡片),把它定义为宏,然后像函数一样调用。

{# 定义宏:就像定义一个函数 #}
{% macro input(name, label, type='text', placeholder='') %}
    <div class="form-group">
        <label for="{{ name }}">{{ label }}</label>
        <input type="{{ type }}" 
               name="{{ name }}" 
               id="{{ name }}" 
               placeholder="{{ placeholder }}">
    </div>
{% endmacro %}

{# 使用宏:就像调用函数 #}
<form>
    {{ input('username', '用户名', placeholder='请输入用户名') }}
    {{ input('password', '密码', type='password') }}
    {{ input('email', '邮箱', type='email') }}
</form>

📦 宏的复用:文件导入

宏定义放在模板里不够优雅,可以单独放在一个文件中,然后导入:

<!-- templates/macros/forms.html -->
{% macro input(name, label, type='text') %}
    <div class="form-group">
        <label>{{ label }}</label>
        <input type="{{ type }}" name="{{ name }}">
    </div>
{% endmacro %}

{% macro textarea(name, label, rows=5) %}
    <div class="form-group">
        <label>{{ label }}</label>
        <textarea name="{{ name }}" rows="{{ rows }}"></textarea>
    </div>
{% endmacro %}

{% macro submit(text='提交') %}
    <button type="submit" class="btn">{{ text }}</button>
{% endmacro %}
{# 在其他模板中导入 #}
{% from "macros/forms.html" import input, textarea, submit %}

<form>
    {{ input('title', '标题') }}
    {{ textarea('content', '内容') }}
    {{ submit('发布文章') }}
</form>

💡 宏 vs include 的区别:

• 宏(macro):可传参数的"函数",适合生成动态组件
• include:直接插入一段固定的模板片段,不传参数

类比编程:宏 = 函数(有参数),include = 复制粘贴(无参数但带上下文)。


5. 自定义过滤器

🔧 什么时候需要自定义过滤器?

内置过滤器不够用时——比如你想把数字格式化成"万"为单位,或者把 Markdown 转成 HTML。

# app.py
@app.template_filter('reverse')
def reverse_filter(s):
    """反转字符串"""
    return s[::-1]

@app.template_filter('time_ago')
def time_ago_filter(dt):
    """时间距今多久"""
    from datetime import datetime
    diff = datetime.now() - dt
    if diff.days > 365:
        return f'{diff.days // 365} 年前'
    elif diff.days > 30:
        return f'{diff.days // 30} 个月前'
    elif diff.days > 0:
        return f'{diff.days} 天前'
    elif diff.seconds > 3600:
        return f'{diff.seconds // 3600} 小时前'
    elif diff.seconds > 60:
        return f'{diff.seconds // 60} 分钟前'
    else:
        return '刚刚'

@app.template_filter('currency')
def currency_filter(amount):
    """格式化货币"""
    return f'¥{amount:,.2f}'
<!-- 在模板中使用 -->
<p>{{ "Hello" | reverse }}</p>            <!-- olleH -->
<p>{{ post_date | time_ago }}</p>         <!-- 3 天前 -->
<p>{{ 12345.6 | currency }}</p>           <!-- ¥12,345.60 -->

🏷️ 过滤器链

{# 过滤器可以链式调用,从左到右依次执行 #}
{{ "  Hello World  " | trim | upper }}         <!-- HELLO WORLD -->
{{ "hello world" | title | truncate(8) }}       <!-- Hello... -->
{{ items | sort | join(', ') }}                 <!-- a, b, c -->

6. 内置过滤器大全

过滤器
作用
示例
结果
upper
转大写
{{ "hi" | upper }}
HI
lower
转小写
{{ "HI" | lower }}
hi
title
首字母大写
{{ "hi there" | title }}
Hi There
capitalize
首字母大写(仅第一个)
{{ "hi there" | capitalize }}
Hi there
trim
去首尾空白
{{ " hi " | trim }}
hi
length
长度
{{ "hello" | length }}
5
default(v)
空值时用默认值
{{ x | default('N/A') }}
N/A(若 x 为空)
join(sep)
列表拼接
{{ ['a','b'] | join('-') }}
a-b
sort
排序
{{ [3,1,2] | sort }}
[1, 2, 3]
reverse
反转
{{ [1,2,3] | reverse }}
[3, 2, 1]
first
第一个元素
{{ [1,2,3] | first }}
1
last
最后一个元素
{{ [1,2,3] | last }}
3
unique
去重
{{ [1,2,1] | unique }}
[1, 2]
truncate(n)
截断文本
{{ "hello world" | truncate(5) }}
he...
striptags
去除HTML标签
{{ "<b>hi</b>" | striptags }}
hi
escape
HTML转义
{{ "<script>" | escape }}
&lt;script&gt;
safe
标记为安全(不转义)
{{ html_content | safe }}
渲染HTML

⚠️ 关于 safe 过滤器的安全警告:

{{ user_input | safe }} 会直接渲染用户输入的 HTML,这可能导致 XSS 攻击(跨站脚本攻击)。

只有当你100%确定内容是安全的(比如你自己写的 HTML)时才用 safe。对用户输入永远不要用 safe


7. 静态文件

📁 静态文件是什么?

CSS 样式表、JavaScript 脚本、图片、字体——这些不需要 Python 处理的文件就是静态文件。

# 项目结构
myapp/
├── app.py
├── templates/
│   └── index.html
└── static/           ← 静态文件都放这里
    ├── css/
    │   └── style.css
    ├── js/
    │   └── main.js
    └── images/
        └── logo.png

🔗 在模板中引用静态文件

<!-- 引用 CSS -->
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">

<!-- 引用 JavaScript -->
<script src="{{ url_for('static', filename='js/main.js') }}"></script>

<!-- 引用图片 -->
<img src="{{ url_for('static', filename='images/logo.png') }}" alt="Logo">

<!-- favicon -->
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">

💡 为什么用 url_for 而不是直接写路径?

url_for('static', filename='css/style.css') 会自动生成正确的路径,即使你的应用部署在子目录下(如 /myapp/static/css/style.css)。

直接写 /static/css/style.css 在开发环境可能没问题,但部署到生产环境时可能会坏掉。用 url_for 是最佳实践。

🎨 CSS 静态文件示例

/* static/css/style.css */
body {
    font-family: -apple-system, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: 
#f5f5f5;
}

nav {
    background: #07c160;
    padding: 12px 20px;
    border-radius: 8px;
}

nav a {
    color: white;
    text-decoration: none;
    margin-right: 16px;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

8. 模板包含(include)

📎 什么是 include?

include 就是把另一个模板的内容"粘贴"到当前位置。 适合复用不需要传参的模板片段。

{# 直接插入导航栏模板 #}
{% include 'navbar.html' %}

{# 插入侧边栏 #}
{% include 'sidebar.html' %}

{# 带上下文的包含(可以访问当前模板的变量) #}
{% include 'user_card.html' with context %}

{# 忽略缺失的模板(不报错) #}
{% include 'optional_widget.html' ignore missing %}

📝 include vs 继承 vs 宏

技术
用途
传参
比喻
继承 extends
页面整体骨架
通过 block
填空题
宏 macro
可复用的组件
✅ 有参数
函数
include
固定的模板片段
❌ 无参数(用 with context 共享变量)
复制粘贴
{# 导航栏适合用 include(不需要传参) #}
{% include 'partials/navbar.html' %}

{# 表单字段适合用宏(需要传 name、label 等参数) #}
{% from 'macros/forms.html' import input %}
{{ input('username', '用户名') }}

{# 整个页面结构适合用继承 #}
{% extends "base.html" %}

9. 全局变量与上下文处理器

🌍 问题:每个模板都需要的数据怎么办?

比如网站名称、当前用户、导航菜单——每个页面都需要,难道每个视图函数都要传一遍?

上下文处理器(context_processor) 解决了这个问题:

# app.py
@app.context_processor
def inject_globals():
    """这些变量会自动注入到所有模板中"""
    return {
        'site_name': 'Python 学习网',
        'current_year': 2026,
        'nav_items': [
            {'url': '/', 'text': '首页'},
            {'url': '/about', 'text': '关于'},
            {'url': '/blog', 'text': '博客'},
        ]
    }
<!-- 所有模板中都可以直接使用这些变量 -->
<title>{{ site_name }}</title>

<nav>
{% for item in nav_items %}
    <a href="{{ item.url }}">{{ item.text }}</a>
{% endfor %}
</nav>

<footer>© {{ current_year }} {{ site_name }}</footer>

🧙 g 对象

Flask 的 g 对象是一个请求级别的临时存储,在一次请求的生命周期内有效:

from flask import g

@app.before_request
def before_request():
    """每次请求前执行"""
    g.user = get_current_user()  # 存到 g 中
    g.db = get_db_connection()

@app.route('/dashboard')
def dashboard():
    # 在视图函数中使用 g 中的数据
    return render_template('dashboard.html', user=g.user)

💡 g vs session 的区别:

• g:仅在当前请求内有效,请求结束就没了。适合存数据库连接等。
• session:跨请求有效(存在 Cookie 里)。适合存用户登录状态等。

类比:g = 便利贴(用完就扔),session = 记事本(长期保存)。


10. 今日练习

🏋️ 练习 1:模板继承

# 要求:
# 1. 创建 base.html:包含导航栏、content block、页脚
# 2. 创建 index.html:继承 base.html,显示首页内容
# 3. 创建 about.html:继承 base.html,显示关于页面
# 4. 导航栏中当前页面的链接高亮显示(用 block 或变量控制)

🏋️ 练习 2:组件宏

# 要求:
# 创建一个卡片宏 card(title, content, footer='')
# 渲染效果:
# ┌─────────────────────┐
# │ 📌 标题             │
# │                     │
# │ 内容正文            │
# │                     │
# │ 底部信息(可选)    │
# └─────────────────────┘
# 使用这个宏渲染 3 张不同的卡片

🏋️ 练习 3:自定义过滤器

# 要求:
# 1. @app.template_filter('mask') → 邮箱脱敏
#    "test@example.com" → "t***@example.com"
# 2. @app.template_filter('word_count') → 统计字数
#    "hello world" → 2
# 3. @app.template_filter('file_size') → 文件大小格式化
#    1536 → "1.5 KB"
#    1048576 → "1.0 MB"

11. 今日小结

知识点
核心内容
模板继承
{% extends %} + {% block %},一个 base.html 管理所有页面公共部分
super()
在子模板中保留父模板的块内容并追加
宏 macro
模板里的"函数",可传参数,适合复用组件
自定义过滤器
@app.template_filter,管道符 | 调用
静态文件
放在 static/ 目录,用 url_for 引用
include
插入固定模板片段,不需要传参
上下文处理器
context_processor 向所有模板注入全局变量
g 对象
请求级别的临时存储,一次请求内有效

🚀 明日预告:Day 53 — 表单处理

今天你学会了优雅地组织模板,但还没有学会接收用户输入。明天我们会学 WTForms——Flask 最强大的表单处理库。从文本框到文件上传,从数据验证到 CSRF 防护,让你的网站从"只读"变成"可交互"!

轻松时刻:

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 02:17:58 HTTP/2.0 GET : https://f.mffb.com.cn/a/503345.html
  2. 运行时间 : 0.338076s [ 吞吐率:2.96req/s ] 内存消耗:4,652.38kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=b3669c24d9fea925f25de84085a56594
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.001030s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001689s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.016699s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.041368s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001749s ]
  6. SELECT * FROM `set` [ RunTime:0.001631s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001679s ]
  8. SELECT * FROM `article` WHERE `id` = 503345 LIMIT 1 [ RunTime:0.001007s ]
  9. UPDATE `article` SET `lasttime` = 1783102679 WHERE `id` = 503345 [ RunTime:0.013388s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.016062s ]
  11. SELECT * FROM `article` WHERE `id` < 503345 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001254s ]
  12. SELECT * FROM `article` WHERE `id` > 503345 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001358s ]
  13. SELECT * FROM `article` WHERE `id` < 503345 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002181s ]
  14. SELECT * FROM `article` WHERE `id` < 503345 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001771s ]
  15. SELECT * FROM `article` WHERE `id` < 503345 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.052082s ]
0.342024s