From dcf8384b4a7604e6b4e3b68f2fe76571c0d00d41 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期一, 02 三月 2026 08:13:59 +0800
Subject: [PATCH] 1
---
open-rcs/pages/接口文档.html | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 215 insertions(+), 1 deletions(-)
diff --git "a/open-rcs/pages/\346\216\245\345\217\243\346\226\207\346\241\243.html" "b/open-rcs/pages/\346\216\245\345\217\243\346\226\207\346\241\243.html"
index 85ba237..948b40f 100644
--- "a/open-rcs/pages/\346\216\245\345\217\243\346\226\207\346\241\243.html"
+++ "b/open-rcs/pages/\346\216\245\345\217\243\346\226\207\346\241\243.html"
@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>涓壃RCS寮�鏀惧钩鍙�</title>
+ <script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script>
<style>
* {
margin: 0;
@@ -74,7 +75,6 @@
border: none;
display: block;
}
-
/* 搴曢儴 */
@@ -269,6 +269,8 @@
<div class="fixed-nav">
<div>鈯�<br>鍚堜綔</div>
<div>馃摟<br>鍜ㄨ</div>
+ <div onclick="exportToWord()">馃搫<br>瀵煎嚭Word</div>
+ <div onclick="exportToMarkdown()">馃摑<br>瀵煎嚭MD</div>
<div onclick="scrollToTop()">鈫�</div>
</div>
@@ -343,6 +345,218 @@
});
}
+ // 瀵煎嚭涓篧ord (docx鏍煎紡)
+ function exportToWord() {
+ const contentFrame = document.getElementById('content-frame');
+ if (contentFrame && contentFrame.contentWindow) {
+ try {
+ console.log('寮�濮嬪鍑篧ord');
+
+ const contentDoc = contentFrame.contentDocument;
+ const content = contentDoc.body.innerHTML;
+ console.log('鑾峰彇鍒板唴瀹癸紝闀垮害:', content.length);
+
+ // 鎻愬彇鎺ュ彛鏍稿績鍐呭锛岃繃婊ゆ帀鎵�鏈夋爣棰樺拰鍏冧俊鎭�
+ let coreContent = content;
+
+ // 绉婚櫎鏍囬鍜屽厓淇℃伅
+ coreContent = coreContent.replace(/RCS鎺ュ彛鏂囨。[\s\S]*?鏇存柊鏃堕棿锛歔\s\S]*?\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/g, '');
+ coreContent = coreContent.replace(/<h1[^>]*>.*?<\/h1>/g, '');
+ coreContent = coreContent.replace(/<h2[^>]*>.*?<\/h2>/g, '');
+ coreContent = coreContent.replace(/<h3[^>]*>.*?<\/h3>/g, '');
+ coreContent = coreContent.replace(/<h4[^>]*>.*?<\/h4>/g, '');
+ coreContent = coreContent.replace(/<h5[^>]*>.*?<\/h5>/g, '');
+ coreContent = coreContent.replace(/<h6[^>]*>.*?<\/h6>/g, '');
+ coreContent = coreContent.replace(/鏇存柊鏃堕棿锛�.*?<\/p>/g, '');
+
+ // 鍒涘缓HTML鏍煎紡鐨刉ord鏂囨。
+ const htmlContent = `
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>鎺ュ彛鏂囨。</title>
+ <style>
+ body {
+ font-family: 'Microsoft YaHei', Arial, sans-serif;
+ margin: 40px;
+ line-height: 1.6;
+ }
+ p {
+ margin-bottom: 15px;
+ text-align: justify;
+ }
+ pre {
+ background-color: #f8f9fa;
+ padding: 15px;
+ border-radius: 4px;
+ border: 1px solid #e9ecef;
+ margin: 20px 0;
+ font-family: 'Consolas', 'Monaco', monospace;
+ white-space: pre-wrap;
+ }
+ table {
+ border-collapse: collapse;
+ width: 100%;
+ margin: 20px 0;
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
+ }
+ th {
+ background-color: #3498db;
+ color: white;
+ font-weight: bold;
+ padding: 12px 15px;
+ text-align: left;
+ }
+ td {
+ border: 1px solid #ddd;
+ padding: 10px 15px;
+ text-align: left;
+ }
+ tr:nth-child(even) {
+ background-color: #f8f9fa;
+ }
+ ul, ol {
+ margin: 15px 0;
+ padding-left: 30px;
+ }
+ li {
+ margin-bottom: 8px;
+ }
+ </style>
+</head>
+<body>
+ ${coreContent}
+</body>
+</html>
+ `;
+
+ // 鍒涘缓Blob瀵硅薄
+ const blob = new Blob([htmlContent], { type: 'application/msword' });
+ const url = URL.createObjectURL(blob);
+
+ // 鍒涘缓涓嬭浇閾炬帴
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = '鎺ュ彛鏂囨。.doc';
+ link.click();
+
+ // 閲婃斁URL瀵硅薄
+ setTimeout(() => URL.revokeObjectURL(url), 100);
+ console.log('涓嬭浇瀹屾垚');
+ } catch (e) {
+ console.error('瀵煎嚭Word澶辫触:', e);
+ alert('瀵煎嚭Word澶辫触锛岃閲嶈瘯锛�' + e.message);
+ }
+ } else {
+ console.error('鏃犳硶鑾峰彇鍐呭妗嗘灦');
+ alert('瀵煎嚭Word澶辫触锛氭棤娉曡幏鍙栧唴瀹规鏋�');
+ }
+ }
+
+ // 瀵煎嚭涓篗arkdown
+ function exportToMarkdown() {
+ const contentFrame = document.getElementById('content-frame');
+ if (contentFrame && contentFrame.contentWindow) {
+ try {
+ const contentDoc = contentFrame.contentDocument;
+ const content = contentDoc.body;
+
+ // 杞崲HTML涓篗arkdown
+ let markdown = '';
+
+ // 鎸夋枃妗i『搴忓鐞嗘墍鏈夊厓绱�
+ const processElement = (element) => {
+ // 杩囨护鎺変笉闇�瑕佺殑鍏冪礌
+ if (element.textContent.includes('RCS鎺ュ彛鏂囨。') ||
+ element.textContent.includes('鎺ュ彛璇︽儏') ||
+ element.textContent.includes('鏇存柊鏃堕棿锛�') ||
+ element.textContent.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
+ return;
+ }
+
+ const tagName = element.tagName;
+
+ if (['H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(tagName)) {
+ // 澶勭悊鏍囬
+ const level = parseInt(tagName.substring(1));
+ const hashes = '#'.repeat(level);
+ markdown += `${hashes} ${element.textContent}\n\n`;
+ } else if (tagName === 'P') {
+ // 澶勭悊娈佃惤
+ markdown += `${element.textContent}\n\n`;
+ } else if (tagName === 'PRE') {
+ // 澶勭悊浠g爜鍧�
+ markdown += '```\n';
+ markdown += element.textContent;
+ markdown += '\n```\n\n';
+ } else if (tagName === 'UL' || tagName === 'OL') {
+ // 澶勭悊鍒楄〃
+ const items = element.querySelectorAll('li');
+ items.forEach(item => {
+ const prefix = tagName === 'UL' ? '- ' : '1. ';
+ markdown += `${prefix}${item.textContent}\n`;
+ });
+ markdown += '\n';
+ } else if (tagName === 'TABLE') {
+ // 澶勭悊琛ㄦ牸
+ const headers = element.querySelectorAll('th');
+ if (headers.length > 0) {
+ markdown += '| ';
+ headers.forEach(header => {
+ markdown += `${header.textContent} | `;
+ });
+ markdown += '\n';
+
+ // 鍒嗛殧绾�
+ markdown += '| ';
+ headers.forEach(() => {
+ markdown += '--- | ';
+ });
+ markdown += '\n';
+ }
+
+ // 澶勭悊琛ㄦ牸琛�
+ const rows = element.querySelectorAll('tr');
+ rows.forEach(row => {
+ const cells = row.querySelectorAll('td');
+ if (cells.length > 0) {
+ markdown += '| ';
+ cells.forEach(cell => {
+ markdown += `${cell.textContent} | `;
+ });
+ markdown += '\n';
+ }
+ });
+ markdown += '\n';
+ } else if (element.children && element.children.length > 0) {
+ // 澶勭悊瀹瑰櫒鍏冪礌锛岄�掑綊澶勭悊瀛愬厓绱�
+ Array.from(element.children).forEach(child => processElement(child));
+ }
+ };
+
+ // 鎸夐『搴忓鐞嗘墍鏈夊瓙鍏冪礌
+ Array.from(content.children).forEach(child => processElement(child));
+
+ // 鍒涘缓Blob瀵硅薄
+ const blob = new Blob([markdown], {type: 'text/markdown'});
+ const url = URL.createObjectURL(blob);
+
+ // 鍒涘缓涓嬭浇閾炬帴
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = '鎺ュ彛鏂囨。.md';
+ link.click();
+
+ // 閲婃斁URL瀵硅薄
+ setTimeout(() => URL.revokeObjectURL(url), 100);
+ } catch (e) {
+ console.error('瀵煎嚭Markdown澶辫触:', e);
+ alert('瀵煎嚭Markdown澶辫触锛岃閲嶈瘯');
+ }
+ }
+ }
+
// 鐩戝惉iframe鍔犺浇瀹屾垚
window.addEventListener('load', function () {
console.log('椤甸潰鍔犺浇瀹屾垚');
--
Gitblit v1.9.1