在线预览 多格式文档预览与水印审计 AI 提示词 (Prompts)

下面是一组“在线预览”方向的在线工具生成型 AI 提示词(Prompts)。每条 Prompt 都要求 AI 直接产出可运行的完整项目:包含源码、文件结构、运行命令、部署说明与测试/QA 清单,适合用于企业内网文档预览、权限分享、水印审计与访问日志留存等场景。

多格式文档在线预览网关(PDF/DOCX/PPTX/XLSX/图片/文本)

目标是做一个统一入口的预览网关:上传或给链接,就能在浏览器内预览,并且支持在本地/内网部署。

英文 Prompt:

You are a senior full-stack engineer. Build a production-ready "Document Preview Gateway" web app. Tech stack requirements: - Frontend: Next.js (App Router) + Type + Tailwind. - Backend: Node.js (Express) OR Next.js Route Handlers. - Conversion/preview pipeline: use LibreOffice headless for office->pdf conversion, and PDF.js for PDF rendering. - Storage: local disk by default, optional S3-compatible storage behind an interface. Functional requirements: - Upload files (PDF, DOCX, PPTX, XLSX, TXT, MD, PNG/JPG/WebP) and preview in browser. - For office formats, convert to PDF server-side; show conversion status and errors. - Generate safe preview URLs with short-lived tokens. - Show file data (size, mime, pages when applicable). - Strict security: sanitize file names, validate mime/signature, limit file size, rate limit, virus-scan hook (stub). Deliverables (must output all): 1) Complete source code with a clear file tree. 2) Step-by-step local run commands. 3) Dockerfile + docker-compose.yml (include LibreOffice dependencies). 4) Deployment guide for Linux VPS and for internal network. 5) At least 8 test cases (unit/integration) OR a QA checklist with >= 10 items. Provide the exact file structure first, then the code for each file.

中文释义:

让 AI 生成一个可部署的“文档预览网关”项目:多格式上传与预览,Office 文件自动转 PDF,带令牌访问、状态提示与安全校验,并且给出 Docker 部署与测试/QA 清单。

预览链接权限分享(一次性口令/过期时间/访问次数)

用于把预览链接安全地发给同事/客户:支持一次性口令、到期自动失效、限制访问次数。

英文 Prompt:

Build an "Expiring Share " module and integrate it into the Document Preview Gateway. Requirements: - Share s support: expiresAt, maxViews, optional one-time passcode. - Server enforces: token signature (HMAC), view counting (atomic), lock when exceeded. - Admin UI page to create/revoke share s and see current counters. - Auditable events: share_created, share_viewed, share_revoked, share_expired. Implementation constraints: - Use SQLite for local dev (Prisma or better-sqlite3), and provide a migration story. - Provide API routes + UI pages. Deliverables: - Full code changes (file tree and code). - Migration s. - Tests: at least 6 cases covering expiry, maxViews, passcode, revocation. - Security notes: common pitfalls and how you mitigated them.

中文释义:

让 AI 产出一个可落地的“预览分享链接权限系统”:可设过期、限制次数、可选口令,并带事件审计与测试用例。

可验证水印与泄露追踪(动态水印/用户标识/时间戳)

在预览层做动态水印:屏幕截图也能追踪泄露来源;同时避免“水印被轻易去掉”。

英文 Prompt:

Implement "Dynamic Watermark" overlay for document previews. Requirements: - Watermark content: userId/email (or share Id), current timestamp, client IP (server-provided), and a short hash. - Watermark rendered as a repeating diagonal pattern over the preview area. - Watermark settings per share : enabled/disabled, opacity, density, rotation. - Must work for PDF.js rendering and image preview. Deliverables: - Complete code. - Explain how you prevent easy removal (e.g., canvas overlay + randomized offsets per session). - Provide QA checklist (>= 8 items), including screenshot/print attempts.

中文释义:

让 AI 生成“动态水印”功能:在 PDF.js 与图片预览上叠加可追踪的水印,并提供配置与 QA 自检点,适合敏感文档外发。

访问审计与可检索日志(按文件/用户/时间筛选导出)

把预览行为做成可查询的审计日志:谁在什么时候看了哪个文件、看了几页、是否下载过。

英文 Prompt:

Add an "Audit Log" subsystem. Requirements: - Log events: preview_open, page_view, download_attempt, share_view, auth_fail. - Store: user/session identifiers, share Id, fileId, timestamp, userAgent, ip. - UI: searchable table with filters (date range, fileId, userId/share Id, eventType) + CSV export. - Privacy: allow masking IP and userAgent in export via config. Deliverables: - DB schema + migrations. - API endpoints + UI page. - Provide at least 5 integration tests and a load note (how to handle high volume).

中文释义:

让 AI 生成“访问审计系统”:记录预览/翻页/下载尝试等事件,提供筛选与导出,并兼顾隐私脱敏与高并发扩展思路。

大文件与分页预览性能优化(切片、缓存与断点续传)

面向 100MB+ 文档:需要更稳定的上传、缓存与预览体验,避免一次性加载导致卡顿。

英文 Prompt:

Optimize for large files. Requirements: - Resumable upload (tus protocol or chunked upload) with server-side assembly. - Cache converted PDFs and generated page thumbnails (derived from existing pages) with TTL. - Streaming download for PDF bytes; support Range requests. - Observability: structured logs + basic metrics endpoint. Deliverables: - Complete implementation code. - Docker-compose remains working. - QA checklist >= 10 items focusing on large file behavior and Range requests.

中文释义:

让 AI 生成“大文件预览优化”方案:分片上传、缓存、Range 流式传输与可观测性,保证内网部署也能稳。

安全沙箱与文件处理隔离(队列、超时与资源限制)

把转换/解析放到隔离进程里:防止恶意文件拖垮主服务,并可限制 CPU/内存/超时。

英文 Prompt:

Design a "Conversion Worker" isolated service. Requirements: - Main app enqueues conversion jobs (office->pdf) into a queue (BullMQ + Redis or a simple SQLite queue). - Worker runs conversions with timeouts and resource limits; returns artifacts and status. - UI shows job status and retries. - Security: run worker with non-root user; document container hardening steps. Deliverables: - Architecture diagram (ASCII ok). - Full code for main app + worker. - docker-compose with Redis (if used). - Tests/QA: at least 8 items.

中文释义:

让 AI 输出“转换工作进程”的可运行方案:队列化、超时与资源限制、状态可视化,并给出容器安全建议。

可插拔预览适配器(新格式快速接入)

把预览能力做成适配器:未来要加 CAD、Epub 或更多格式时,只需新增一个适配器模块。

英文 Prompt:

Implement a plugin-style "Preview Adapter" system. Requirements: - Define interfaces: canHandle(mime, ext), prepare(file), renderStrategy(). - Built-in adapters: pdf, image, text/markdown (render sanitized HTML), office (convert then pdf). - Add a developer doc explaining how to add a new adapter. Deliverables: - Refactor code to use adapters. - Provide an example "epub" adapter stub (no need for full epub support, but show structure). - QA checklist >= 8.

中文释义:

让 AI 把预览系统重构成“适配器插件架构”:内置 PDF/图片/文本/Markdown/Office,给出新增适配器的开发文档与示例。

企业内网部署与反向代理(HTTPS、鉴权、路径前缀)

强调可部署性:支持反向代理、路径前缀、HTTPS 与企业 SSO/基础鉴权接入点。

英文 Prompt:

Write a deployment-focused iteration. Requirements: - Provide Nginx reverse proxy config examples (path prefix, static caching, websocket if needed). - Add optional auth middleware: Basic Auth and an SSO stub (OIDC placeholder). - Ensure the app works under a Path (e.g., /preview) and behind HTTPS. Deliverables: - Updated code + config samples. - A checklist for production readiness (>= 12 items), including backups, log retention, and monitoring.

中文释义:

让 AI 输出“企业内网可交付”的部署迭代:反代配置、HTTPS、鉴权与 Path 兼容,并给出上线检查清单。

用户评论 (0)

登录后参与讨论

立即登录 注册账号

暂无评论,快来抢沙发吧~

操作成功