# 代码查看器

免费在线代码查看器。在浏览器中直接打开源码与配置文件（.sh、.vue、.cpp、.toml、.rb、.swift 等），无需上传。

> 标准页面: https://elysiatools.com/zh/viewers/code

- **分类:** 文本文件

- **支持格式:** .sh, .bash, .vue, .ini, .toml, .proto, .hcl, .log, .diff, .patch, .bundle, .bdl, .ipynb, .http, .react, .gv, .tex, .rb, .swift, .kt, .c, .cpp, .cc, .h, .hpp, .cs, .php

## 概述

这个代码查看器在浏览器本地渲染多种长尾源码与配置文件。它涵盖 shell 脚本、Vue 单文件组件、C/C++ 头文件与源文件、TOML/INI 等配置格式，以及许多没有独立查看器的语言和标记文件。选择一个样本或你自己的文件，即可带语法高亮地查看。

## 适用场景

- 你有 shell、配置或不常见的源码文件，想在没有编辑器的情况下阅读。
- 需要快速查看 Vue 组件、C/C++ 文件或脚本。
- 在没有代码编辑器的设备上浏览代码或配置文件。

## 工作原理

- 选择内置样本或你自己的代码/配置文件。
- 查看器在浏览器中以语法高亮渲染源码，无需上传。
- 查看文件后，可随时切换样本或加载其他文件。

## 使用案例

- 查看 shell 脚本、Vue 组件与 C/C++ 源码。
- 检查 TOML、INI、Graphviz DOT 等配置文件。
- 在任何设备上浏览长尾语言（Ruby、Swift、Kotlin、PHP）。

## 示例

- **C++注释**: C++ file with single-line and multi-line comments including function documentation
- **Shell 脚本**: A Bash script with a function, local vars, and error handling
- **Vue 组件 (.vue)**: A Vue 3 single-file component with script setup and reactivity
- **C++ 模板**: A C++ example using templates, the STL, and range-based loops
- **TOML 配置**: A structured TOML configuration with nested tables
- **Graphviz (.gv)**: A Graphviz DOT file describing a small directed pipeline graph
- **标准 Nginx 访问日志**: Standard Nginx access log in Combined Log Format with typical GET/POST requests, various status codes, and different UserAgents
- **包含各种 HTTP 状态码的访问日志**: Nginx access log demonstrating comprehensive HTTP status codes across 2xx, 3xx, 4xx, and 5xx ranges for testing parser capabilities
- **包含爬虫机器人流量的访问日志**: Nginx access log featuring various web crawlers and bots including Googlebot, Amazonbot, Bingbot, and MSNBot for bot detection testing
- **基础 Nginx 错误日志**: Nginx error log with common error scenarios including directory index forbidden, upstream timeouts, and FastCGI errors in standard error format
- **Nginx 错误日志 - Upstream 连接问题**: Specialized Nginx error log focusing on upstream connection problems including connection refused, premature closure, timeout issues, and no live upstreams
- **混合访问和错误日志（真实场景）**: Real-world scenario combining access logs and error logs interleaved, demonstrating actual production environment with normal traffic and error conditions

## 常见问题

### 这个代码查看器免费吗？

免费。它在浏览器中运行，无需注册或安装。

### 我的文件会被上传吗？

不会。从你的设备打开的文件保留在本地，只有公开的样本文件来自服务器。

### 它支持哪些格式？

它涵盖长尾代码与配置格式，如 .sh、.vue、.ini、.toml、.proto、.log、.diff、.ipynb、.tex、.rb、.swift、.kt、.c、.cpp、.h、.hpp、.cs、.php。高流量语言（JavaScript、TypeScript、Python、Java、SQL、Go、CSS）各有独立查看器，不在此合并页中。

## 相关内容

- [Markdown 查看器](https://elysiatools.com/zh/viewers/md): 免费在线 Markdown 查看器。直接在浏览器中打开 .md 和 .markdown 文件，无需上传。
- [TXT 查看器](https://elysiatools.com/zh/viewers/txt): 免费在线 TXT 查看器。直接在浏览器中打开纯文本 .txt 文件，无需上传。
- [JSON 查看器](https://elysiatools.com/zh/viewers/json): 免费在线 JSON 查看器。直接在浏览器中打开 .json、.jsonc 和 .json5 文件，无需上传。
- [YAML 查看器](https://elysiatools.com/zh/viewers/yaml): 免费在线 YAML 查看器。在浏览器中直接打开 .yaml 和 .yml 文件，无需上传。
- [XML 查看器](https://elysiatools.com/zh/viewers/xml): 免费在线 XML 查看器。在浏览器中直接打开 .xml 文件，无需上传。
- [HTML 查看器](https://elysiatools.com/zh/viewers/html): 免费在线 HTML 查看器。在浏览器中直接打开 .html 和 .htm 文件，无需上传。
