对比示例

以下每组示例与首页一键按钮载入的内容相同。它们是简短的规划样本,不是生产文件,也不是对某个供应商或技术栈的推荐。

JSON 配置

结账 API 的配置。修改稿提高了速率限制、切换了功能开关,并增加了一个 CORS 来源。

原文

{
  "service": "checkout-api",
  "version": "1.4.0",
  "rateLimit": {
    "windowSeconds": 60,
    "maxRequests": 120
  },
  "featureFlags": {
    "newCheckout": false,
    "legacyCart": true,
    "auditLog": true
  },
  "cors": {
    "origins": [
      "shop.example.com",
      "admin.example.com"
    ],
    "allowCredentials": true
  }
}

修改稿

{
  "service": "checkout-api",
  "version": "1.5.0",
  "rateLimit": {
    "windowSeconds": 60,
    "maxRequests": 200
  },
  "featureFlags": {
    "newCheckout": true,
    "legacyCart": false,
    "auditLog": true,
    "expressPay": true
  },
  "cors": {
    "origins": [
      "shop.example.com",
      "admin.example.com",
      "preview.example.com"
    ],
    "allowCredentials": true
  }
}

Nginx 虚拟主机

一台虚拟主机。修改稿启用了 HTTP/2 与 gzip,加长了代理超时,并收紧了静态资源的缓存头。

原文

upstream shop_app {
    server 127.0.0.1:8080;
}

server {
    listen 80;
    server_name shop.example.com;
    root /var/www/shop;
    index index.html;

    location / {
        proxy_pass shop_app;
        proxy_set_header Host $host;
        proxy_read_timeout 30s;
    }

    location /assets/ {
        expires 1h;
        add_header Cache-Control "public";
    }
}

修改稿

upstream shop_app {
    server 127.0.0.1:8080;
}

server {
    listen 443 ssl http2;
    server_name shop.example.com;
    root /var/www/shop;
    index index.html;

    gzip on;
    gzip_types text/css application/javascript application/json;

    location / {
        proxy_pass shop_app;
        proxy_set_header Host $host;
        proxy_read_timeout 90s;
        proxy_http_version 1.1;
    }

    location /assets/ {
        expires 30d;
        add_header Cache-Control "public, immutable";
        add_header X-Content-Type-Options nosniff;
    }
}

SQL 变更

订单报表查询。修改稿增加了索引,调整了连接方式,并收紧了日期与状态过滤条件。

原文

SELECT
  o.id,
  o.created_at,
  c.email,
  SUM(i.qty * i.unit_price) AS total
FROM orders o
INNER JOIN customers c ON c.id = o.customer_id
INNER JOIN order_items i ON i.order_id = o.id
WHERE o.created_at >= '2024-01-01'
  AND o.status <> 'cancelled'
GROUP BY o.id, o.created_at, c.email
ORDER BY o.created_at DESC;

修改稿

CREATE INDEX idx_orders_created_status
  ON orders (created_at, status);

SELECT
  o.id,
  o.created_at,
  c.email,
  SUM(i.qty * i.unit_price) AS total
FROM orders o
LEFT JOIN customers c ON c.id = o.customer_id
INNER JOIN order_items i ON i.order_id = o.id
WHERE o.created_at >= '2025-01-01'
  AND o.status IN ('paid', 'shipped')
GROUP BY o.id, o.created_at, c.email
ORDER BY o.created_at DESC;

Markdown 说明

一则简短更新说明。修改稿提升了版本号,记录了新的 --dry-run 参数,并更新了用法一行。

原文

# Release notes

## 1.2.0

- Format and minify a query in the browser.
- Add a --watch flag for local previews.
- Document the default port in the README.

Usage:

    desk format --file query.sql

修改稿

# Release notes

## 1.3.0

- Format and minify a query in the browser.
- Add a --dry-run flag before writing a file.
- Add a --watch flag for local previews.
- Document the default port and locale prefix in the README.

Usage:

    desk format --file query.sql --dry-run

返回对比台

常见问题

可以在本页直接编辑示例吗?

本页是静态阅读副本。请打开首页对比台,用一键示例按钮把同一组内容载入编辑器。