开始使用Open Claw的准备工作
<div class="ce-block" data-id="XiczxoAdf_" ><div class="ce-block__content" style="">
<h1 class="ce-header ce-header--left">准备工作</h1>
</div>
</div><div class="ce-block ce-block--focused" data-id="eVJojpakyK" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">在开始使用
<span style="color: rgb(55, 65, 81); font-family: "Public Sans", "Public Sans Fallback"; font-size: medium; letter-spacing: normal;">Open</span> Claw 之前,你需要准备好开发环境和必要的账号资源。本章将指导你完成所有前置准备工作。</div>
</div>
</div><div class="ce-block" data-id="qNaR0FhDzr" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">系统要求</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="mQFEtB6aPj" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><span style="color: rgb(55, 65, 81); font-family: "Public Sans", "Public Sans Fallback"; font-size: medium; letter-spacing: normal;">Open</span> Claw 支持主流操作系统,但对硬件和软件环境有一定要求:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="GFq-wZaiWf" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>最低配置</b>:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="wzqtR8eKw2" >
<div class="ce-block__content">
<ul class="cdx-list-unordered"><li class="cdx-list__item">CPU: 2核心</li><li class="cdx-list__item">内存: 4GB RAM</li><li class="cdx-list__item">存储: 10GB 可用空间</li><li class="cdx-list__item">操作系统: Linux (Ubuntu 20.04+), macOS (12+), Windows 10/11 (with WSL2)</li></ul>
</div>
</div><div class="ce-block ce-block--focused" data-id="x2ClwF_WHJ" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>推荐配置</b>:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="yXOp7yz_QZ" >
<div class="ce-block__content">
<ul class="cdx-list-unordered"><li class="cdx-list__item">CPU: 4核心或更多</li><li class="cdx-list__item">内存: 8GB RAM 或更多</li><li class="cdx-list__item">存储: 20GB SSD</li><li class="cdx-list__item">稳定的网络连接(用于 API 调用)</li></ul>
</div>
</div><div class="ce-block ce-block--focused" data-id="xoZKbrnJmO" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">对于生产环境部署,建议使用至少 8GB 内存和 4 核 CPU,以确保多 Agent 并发执行时的稳定性。如果你计划使用浏览器自动化功能,内存需求会更高(建议 16GB)。</div>
</div>
</div><div class="ce-block" data-id="AiThlW-1td" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">必备软件安装</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="Ko_j6C9ddM" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>Node.js 环境</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="oUBniDVsi8" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><span style="color: rgb(55, 65, 81); font-family: "Public Sans", "Public Sans Fallback"; font-size: medium; letter-spacing: normal;">Open</span> Claw 需要 Node.js 18 或更高版本。推荐使用 LTS 版本:undefined</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="KYxMC6rzOT" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-KYxMC6rzOT">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-KYxMC6rzOT">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-KYxMC6rzOT" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-KYxMC6rzOT">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535qh5rR = document.getElementById('codeflask-KYxMC6rzOT');
var isCollapsed1793590535qh5rR = true;
const flask1793590535qh5rR = new CodeFlask(editorElem1793590535qh5rR, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535qh5rR = `# 检查当前 Node.js 版本
node --version
# 使用 nvm 安装(推荐)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 20
nvm use 20
# 验证安装
node --version# 应显示 v20.x.x
npm --version # 应显示 10.x.x
`;
code1793590535qh5rR = code1793590535qh5rR.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535qh5rR.addLanguage('python', Prism.languages['python']);
flask1793590535qh5rR.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535qh5rR.updateCode(code1793590535qh5rR);
const currentCode1793590535qh5rR = flask1793590535qh5rR.getCode();
var coderow1793590535qh5rR = parseInt('');
if (coderow1793590535qh5rR === undefined || coderow1793590535qh5rR !== coderow1793590535qh5rR || coderow1793590535qh5rR === 0) {
coderow1793590535qh5rR = flask1793590535qh5rR.lineNumber;
}
if (coderow1793590535qh5rR < 20) {
editorElem1793590535qh5rR.parentElement.style.height = '300px';
editorElem1793590535qh5rR.style.height = '300px';
} else if (coderow1793590535qh5rR >= 20) {
editorElem1793590535qh5rR.parentElement.style.height = '500px';
editorElem1793590535qh5rR.style.height = '500px';
}
//console.log({currentCode1793590535qh5rR})
const copyBtn1793590535qh5rR = document.getElementById('codeflask-copy-KYxMC6rzOT');
copyBtn1793590535qh5rR.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535qh5rR).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535qh5rR.innerHTML;
copyBtn1793590535qh5rR.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535qh5rR.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535qh5rR);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535qh5rR);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535qh5rR.innerHTML;
copyBtn1793590535qh5rR.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535qh5rR.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535qh5rR = document.getElementById('codeflask-bottomBtn-KYxMC6rzOT');
const Toggle1793590535qh5rR = document.getElementById('codeflask-Toggle-KYxMC6rzOT');
bottomBtn1793590535qh5rR.addEventListener('click', function() {
if (isCollapsed1793590535qh5rR) {
// 展开代码
isCollapsed1793590535qh5rR = false;
const codeElement1793590535qh5rR = editorElem1793590535qh5rR.querySelector('.codeflask__code');
if (codeElement1793590535qh5rR) {
const actualHeight1793590535qh5rR = codeElement1793590535qh5rR.scrollHeight + 20;
editorElem1793590535qh5rR.parentElement.style.height = actualHeight1793590535qh5rR + 'px';
editorElem1793590535qh5rR.style.height = actualHeight1793590535qh5rR + 'px';
}
bottomBtn1793590535qh5rR.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535qh5rR.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535qh5rR = true;
if (coderow1793590535qh5rR < 20) {
editorElem1793590535qh5rR.parentElement.style.height = '300px';
editorElem1793590535qh5rR.style.height = '300px';
} else if (coderow1793590535qh5rR >= 20) {
editorElem1793590535qh5rR.parentElement.style.height = '500px';
editorElem1793590535qh5rR.style.height = '500px';
}
bottomBtn1793590535qh5rR.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535qh5rR.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535qh5rR.addEventListener('click', function() {
bottomBtn1793590535qh5rR.click();
});
</script><div class="ce-block ce-block--focused" data-id="lDiZjDfqYp" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">如果你使用的是 Windows,可以从<span> </span><a href="https://nodejs.org/">Node.js 官网</a><span> </span>下载安装包,或使用<span> </span><code><mark style="background-color: rgb(236, 120, 120);">nvm-windows</mark></code>。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="LPL_l8AQue" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>Docker 安装(推荐)</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="kp2zctvul1" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">Docker 是运行 Claw 最简单的方式,避免了复杂的依赖配置:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="MZrfPy6K-b" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-MZrfPy6K-b">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-MZrfPy6K-b">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-MZrfPy6K-b" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-MZrfPy6K-b">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535RYZOz = document.getElementById('codeflask-MZrfPy6K-b');
var isCollapsed1793590535RYZOz = true;
const flask1793590535RYZOz = new CodeFlask(editorElem1793590535RYZOz, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535RYZOz = `# macOS 和 Windows: 下载 Docker Desktop
# https://www.docker.com/products/docker-desktop
# Linux (Ubuntu) 安装
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# 验证安装
docker --version
docker compose version
# 配置用户权限(Linux)
sudo usermod -aG docker $USER
# 需要重新登录以生效
`;
code1793590535RYZOz = code1793590535RYZOz.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535RYZOz.addLanguage('python', Prism.languages['python']);
flask1793590535RYZOz.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535RYZOz.updateCode(code1793590535RYZOz);
const currentCode1793590535RYZOz = flask1793590535RYZOz.getCode();
var coderow1793590535RYZOz = parseInt('');
if (coderow1793590535RYZOz === undefined || coderow1793590535RYZOz !== coderow1793590535RYZOz || coderow1793590535RYZOz === 0) {
coderow1793590535RYZOz = flask1793590535RYZOz.lineNumber;
}
if (coderow1793590535RYZOz < 20) {
editorElem1793590535RYZOz.parentElement.style.height = '300px';
editorElem1793590535RYZOz.style.height = '300px';
} else if (coderow1793590535RYZOz >= 20) {
editorElem1793590535RYZOz.parentElement.style.height = '500px';
editorElem1793590535RYZOz.style.height = '500px';
}
//console.log({currentCode1793590535RYZOz})
const copyBtn1793590535RYZOz = document.getElementById('codeflask-copy-MZrfPy6K-b');
copyBtn1793590535RYZOz.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535RYZOz).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535RYZOz.innerHTML;
copyBtn1793590535RYZOz.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535RYZOz.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535RYZOz);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535RYZOz);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535RYZOz.innerHTML;
copyBtn1793590535RYZOz.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535RYZOz.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535RYZOz = document.getElementById('codeflask-bottomBtn-MZrfPy6K-b');
const Toggle1793590535RYZOz = document.getElementById('codeflask-Toggle-MZrfPy6K-b');
bottomBtn1793590535RYZOz.addEventListener('click', function() {
if (isCollapsed1793590535RYZOz) {
// 展开代码
isCollapsed1793590535RYZOz = false;
const codeElement1793590535RYZOz = editorElem1793590535RYZOz.querySelector('.codeflask__code');
if (codeElement1793590535RYZOz) {
const actualHeight1793590535RYZOz = codeElement1793590535RYZOz.scrollHeight + 20;
editorElem1793590535RYZOz.parentElement.style.height = actualHeight1793590535RYZOz + 'px';
editorElem1793590535RYZOz.style.height = actualHeight1793590535RYZOz + 'px';
}
bottomBtn1793590535RYZOz.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535RYZOz.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535RYZOz = true;
if (coderow1793590535RYZOz < 20) {
editorElem1793590535RYZOz.parentElement.style.height = '300px';
editorElem1793590535RYZOz.style.height = '300px';
} else if (coderow1793590535RYZOz >= 20) {
editorElem1793590535RYZOz.parentElement.style.height = '500px';
editorElem1793590535RYZOz.style.height = '500px';
}
bottomBtn1793590535RYZOz.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535RYZOz.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535RYZOz.addEventListener('click', function() {
bottomBtn1793590535RYZOz.click();
});
</script><div class="ce-block ce-block--focused" data-id="57Xsr1v5o9" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">对于生产环境,建议使用 Docker Compose 进行部署,这样可以更方便地管理配置和数据持久化。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="6vCDBiAxYY" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>Git 版本控制</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="bK97rC7KM8" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-bK97rC7KM8">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-bK97rC7KM8">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-bK97rC7KM8" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-bK97rC7KM8">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535D19zN = document.getElementById('codeflask-bK97rC7KM8');
var isCollapsed1793590535D19zN = true;
const flask1793590535D19zN = new CodeFlask(editorElem1793590535D19zN, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535D19zN = `# 安装 Git(如果尚未安装)
# macOS
brew install git
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install git
# 验证安装
git --version
`;
code1793590535D19zN = code1793590535D19zN.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535D19zN.addLanguage('python', Prism.languages['python']);
flask1793590535D19zN.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535D19zN.updateCode(code1793590535D19zN);
const currentCode1793590535D19zN = flask1793590535D19zN.getCode();
var coderow1793590535D19zN = parseInt('');
if (coderow1793590535D19zN === undefined || coderow1793590535D19zN !== coderow1793590535D19zN || coderow1793590535D19zN === 0) {
coderow1793590535D19zN = flask1793590535D19zN.lineNumber;
}
if (coderow1793590535D19zN < 20) {
editorElem1793590535D19zN.parentElement.style.height = '300px';
editorElem1793590535D19zN.style.height = '300px';
} else if (coderow1793590535D19zN >= 20) {
editorElem1793590535D19zN.parentElement.style.height = '500px';
editorElem1793590535D19zN.style.height = '500px';
}
//console.log({currentCode1793590535D19zN})
const copyBtn1793590535D19zN = document.getElementById('codeflask-copy-bK97rC7KM8');
copyBtn1793590535D19zN.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535D19zN).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535D19zN.innerHTML;
copyBtn1793590535D19zN.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535D19zN.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535D19zN);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535D19zN);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535D19zN.innerHTML;
copyBtn1793590535D19zN.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535D19zN.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535D19zN = document.getElementById('codeflask-bottomBtn-bK97rC7KM8');
const Toggle1793590535D19zN = document.getElementById('codeflask-Toggle-bK97rC7KM8');
bottomBtn1793590535D19zN.addEventListener('click', function() {
if (isCollapsed1793590535D19zN) {
// 展开代码
isCollapsed1793590535D19zN = false;
const codeElement1793590535D19zN = editorElem1793590535D19zN.querySelector('.codeflask__code');
if (codeElement1793590535D19zN) {
const actualHeight1793590535D19zN = codeElement1793590535D19zN.scrollHeight + 20;
editorElem1793590535D19zN.parentElement.style.height = actualHeight1793590535D19zN + 'px';
editorElem1793590535D19zN.style.height = actualHeight1793590535D19zN + 'px';
}
bottomBtn1793590535D19zN.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535D19zN.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535D19zN = true;
if (coderow1793590535D19zN < 20) {
editorElem1793590535D19zN.parentElement.style.height = '300px';
editorElem1793590535D19zN.style.height = '300px';
} else if (coderow1793590535D19zN >= 20) {
editorElem1793590535D19zN.parentElement.style.height = '500px';
editorElem1793590535D19zN.style.height = '500px';
}
bottomBtn1793590535D19zN.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535D19zN.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535D19zN.addEventListener('click', function() {
bottomBtn1793590535D19zN.click();
});
</script><div class="ce-block" data-id="Slptr5ALVF" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">LLM API 密钥准备</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="gs7t143pkQ" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">Claw 的核心功能依赖于大语言模型 API。你需要至少准备一个 LLM 提供商的 API 密钥。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="_-a9fKq-Sr" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>OpenAI API</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="UD59XDS9Tm" >
<div class="ce-block__content">
<ol class="cdx-list-ordered" style="list-style-type:none; margin-left: -15px;"><li class="cdx-list__item">1. 访问<span> </span><a href="https://platform.openai.com/">OpenAI Platform</a></li><li class="cdx-list__item">2. 注册并完成身份验证</li><li class="cdx-list__item">3. 在 Dashboard 中创建 API Key</li><li class="cdx-list__item">4. 设置使用限额和预算提醒(推荐)</li></ol>
</div>
</div><div class="ce-block ce-block--focused" data-id="hio6UNZ6dr" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-hio6UNZ6dr">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-hio6UNZ6dr">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-hio6UNZ6dr" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-hio6UNZ6dr">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535nSNDt = document.getElementById('codeflask-hio6UNZ6dr');
var isCollapsed1793590535nSNDt = true;
const flask1793590535nSNDt = new CodeFlask(editorElem1793590535nSNDt, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535nSNDt = `# 测试 API 密钥
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
`;
code1793590535nSNDt = code1793590535nSNDt.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535nSNDt.addLanguage('python', Prism.languages['python']);
flask1793590535nSNDt.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535nSNDt.updateCode(code1793590535nSNDt);
const currentCode1793590535nSNDt = flask1793590535nSNDt.getCode();
var coderow1793590535nSNDt = parseInt('');
if (coderow1793590535nSNDt === undefined || coderow1793590535nSNDt !== coderow1793590535nSNDt || coderow1793590535nSNDt === 0) {
coderow1793590535nSNDt = flask1793590535nSNDt.lineNumber;
}
if (coderow1793590535nSNDt < 20) {
editorElem1793590535nSNDt.parentElement.style.height = '300px';
editorElem1793590535nSNDt.style.height = '300px';
} else if (coderow1793590535nSNDt >= 20) {
editorElem1793590535nSNDt.parentElement.style.height = '500px';
editorElem1793590535nSNDt.style.height = '500px';
}
//console.log({currentCode1793590535nSNDt})
const copyBtn1793590535nSNDt = document.getElementById('codeflask-copy-hio6UNZ6dr');
copyBtn1793590535nSNDt.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535nSNDt).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535nSNDt.innerHTML;
copyBtn1793590535nSNDt.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535nSNDt.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535nSNDt);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535nSNDt);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535nSNDt.innerHTML;
copyBtn1793590535nSNDt.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535nSNDt.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535nSNDt = document.getElementById('codeflask-bottomBtn-hio6UNZ6dr');
const Toggle1793590535nSNDt = document.getElementById('codeflask-Toggle-hio6UNZ6dr');
bottomBtn1793590535nSNDt.addEventListener('click', function() {
if (isCollapsed1793590535nSNDt) {
// 展开代码
isCollapsed1793590535nSNDt = false;
const codeElement1793590535nSNDt = editorElem1793590535nSNDt.querySelector('.codeflask__code');
if (codeElement1793590535nSNDt) {
const actualHeight1793590535nSNDt = codeElement1793590535nSNDt.scrollHeight + 20;
editorElem1793590535nSNDt.parentElement.style.height = actualHeight1793590535nSNDt + 'px';
editorElem1793590535nSNDt.style.height = actualHeight1793590535nSNDt + 'px';
}
bottomBtn1793590535nSNDt.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535nSNDt.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535nSNDt = true;
if (coderow1793590535nSNDt < 20) {
editorElem1793590535nSNDt.parentElement.style.height = '300px';
editorElem1793590535nSNDt.style.height = '300px';
} else if (coderow1793590535nSNDt >= 20) {
editorElem1793590535nSNDt.parentElement.style.height = '500px';
editorElem1793590535nSNDt.style.height = '500px';
}
bottomBtn1793590535nSNDt.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535nSNDt.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535nSNDt.addEventListener('click', function() {
bottomBtn1793590535nSNDt.click();
});
</script><div class="ce-block ce-block--focused" data-id="VPcsvlu_IZ" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">成本估算:<span> </span>GPT-4 Turbo 的成本约为 $0.01/1K tokens (输入) + $0.03/1K tokens (输出)。一般的对话任务,每天 100 次交互大约花费 $2-5。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="N5k6S5Fows" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>Anthropic Claude API</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="r1fzG1ZEuv" >
<div class="ce-block__content">
<ol class="cdx-list-ordered" style="list-style-type:none; margin-left: -15px;"><li class="cdx-list__item">1. 访问<span> </span><a href="https://console.anthropic.com/">Anthropic Console</a></li><li class="cdx-list__item">2. 申请 API 访问权限</li><li class="cdx-list__item">3. 生成 API Key</li><li class="cdx-list__item">4. 记录你的配额限制</li></ol>
</div>
</div><div class="ce-block ce-block--focused" data-id="G25q1VksvB" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">Claude 3.5 Sonnet 在编码和推理任务上表现优异,适合作为 Claw 的主力模型。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="zvrt_WGSnp" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>本地模型(可选)</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="JUBm2KvCj5" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">如果你担心成本或隐私问题,可以使用本地模型:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="18XCqSbadX" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-18XCqSbadX">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-18XCqSbadX">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-18XCqSbadX" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-18XCqSbadX">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535Uf5kM = document.getElementById('codeflask-18XCqSbadX');
var isCollapsed1793590535Uf5kM = true;
const flask1793590535Uf5kM = new CodeFlask(editorElem1793590535Uf5kM, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535Uf5kM = `# 安装 Ollama
curl -fsSL https://ollama.com/install.sh | sh
# 拉取模型
ollama pull llama3.1:8b
ollama pull qwen2.5-coder:7b
# 验证运行
ollama run llama3.1:8b "Hello!"
`;
code1793590535Uf5kM = code1793590535Uf5kM.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535Uf5kM.addLanguage('python', Prism.languages['python']);
flask1793590535Uf5kM.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535Uf5kM.updateCode(code1793590535Uf5kM);
const currentCode1793590535Uf5kM = flask1793590535Uf5kM.getCode();
var coderow1793590535Uf5kM = parseInt('');
if (coderow1793590535Uf5kM === undefined || coderow1793590535Uf5kM !== coderow1793590535Uf5kM || coderow1793590535Uf5kM === 0) {
coderow1793590535Uf5kM = flask1793590535Uf5kM.lineNumber;
}
if (coderow1793590535Uf5kM < 20) {
editorElem1793590535Uf5kM.parentElement.style.height = '300px';
editorElem1793590535Uf5kM.style.height = '300px';
} else if (coderow1793590535Uf5kM >= 20) {
editorElem1793590535Uf5kM.parentElement.style.height = '500px';
editorElem1793590535Uf5kM.style.height = '500px';
}
//console.log({currentCode1793590535Uf5kM})
const copyBtn1793590535Uf5kM = document.getElementById('codeflask-copy-18XCqSbadX');
copyBtn1793590535Uf5kM.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535Uf5kM).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535Uf5kM.innerHTML;
copyBtn1793590535Uf5kM.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535Uf5kM.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535Uf5kM);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535Uf5kM);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535Uf5kM.innerHTML;
copyBtn1793590535Uf5kM.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535Uf5kM.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535Uf5kM = document.getElementById('codeflask-bottomBtn-18XCqSbadX');
const Toggle1793590535Uf5kM = document.getElementById('codeflask-Toggle-18XCqSbadX');
bottomBtn1793590535Uf5kM.addEventListener('click', function() {
if (isCollapsed1793590535Uf5kM) {
// 展开代码
isCollapsed1793590535Uf5kM = false;
const codeElement1793590535Uf5kM = editorElem1793590535Uf5kM.querySelector('.codeflask__code');
if (codeElement1793590535Uf5kM) {
const actualHeight1793590535Uf5kM = codeElement1793590535Uf5kM.scrollHeight + 20;
editorElem1793590535Uf5kM.parentElement.style.height = actualHeight1793590535Uf5kM + 'px';
editorElem1793590535Uf5kM.style.height = actualHeight1793590535Uf5kM + 'px';
}
bottomBtn1793590535Uf5kM.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535Uf5kM.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535Uf5kM = true;
if (coderow1793590535Uf5kM < 20) {
editorElem1793590535Uf5kM.parentElement.style.height = '300px';
editorElem1793590535Uf5kM.style.height = '300px';
} else if (coderow1793590535Uf5kM >= 20) {
editorElem1793590535Uf5kM.parentElement.style.height = '500px';
editorElem1793590535Uf5kM.style.height = '500px';
}
bottomBtn1793590535Uf5kM.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535Uf5kM.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535Uf5kM.addEventListener('click', function() {
bottomBtn1793590535Uf5kM.click();
});
</script><div class="ce-block ce-block--focused" data-id="hVtLrFmfe1" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">本地模型的优势是零 API 成本和完全的数据隐私,但需要更强的硬件配置(至少 16GB RAM 用于 7B 模型)。</div>
</div>
</div><div class="ce-block" data-id="N1MWvqz1Jn" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">消息平台账号</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="-8YUrVsgRs" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">根据你的需求,准备以下平台的机器人账号:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="yMd2-VPPVD" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>Telegram Bot</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="X22bAtDg-o" >
<div class="ce-block__content">
<ol class="cdx-list-ordered" style="list-style-type:none; margin-left: -15px;"><li class="cdx-list__item">1. 在 Telegram 中找到<span> </span><a href="https://t.me/botfather">@BotFather</a></li><li class="cdx-list__item">2. 发送<span> </span><code></code><mark style="background-color: rgb(236, 120, 120);"><code>/newbot</code></mark> 创建新机器人</li><li class="cdx-list__item">3. 按提示设置机器人名称和用户名</li><li class="cdx-list__item">4. 保存 Bot Token(格式:<code><mark style="background-color: rgb(236, 120, 120);">123456789:ABCdefGHIjklMNOpqrsTUVwxyz</mark></code>)</li></ol>
</div>
</div><div class="ce-block ce-block--focused" data-id="gdWBtViRaF" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-gdWBtViRaF">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-gdWBtViRaF">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-gdWBtViRaF" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-gdWBtViRaF">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535s0mt0 = document.getElementById('codeflask-gdWBtViRaF');
var isCollapsed1793590535s0mt0 = true;
const flask1793590535s0mt0 = new CodeFlask(editorElem1793590535s0mt0, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535s0mt0 = `# 测试 Bot Token
curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getMe"
`;
code1793590535s0mt0 = code1793590535s0mt0.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535s0mt0.addLanguage('python', Prism.languages['python']);
flask1793590535s0mt0.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535s0mt0.updateCode(code1793590535s0mt0);
const currentCode1793590535s0mt0 = flask1793590535s0mt0.getCode();
var coderow1793590535s0mt0 = parseInt('');
if (coderow1793590535s0mt0 === undefined || coderow1793590535s0mt0 !== coderow1793590535s0mt0 || coderow1793590535s0mt0 === 0) {
coderow1793590535s0mt0 = flask1793590535s0mt0.lineNumber;
}
if (coderow1793590535s0mt0 < 20) {
editorElem1793590535s0mt0.parentElement.style.height = '300px';
editorElem1793590535s0mt0.style.height = '300px';
} else if (coderow1793590535s0mt0 >= 20) {
editorElem1793590535s0mt0.parentElement.style.height = '500px';
editorElem1793590535s0mt0.style.height = '500px';
}
//console.log({currentCode1793590535s0mt0})
const copyBtn1793590535s0mt0 = document.getElementById('codeflask-copy-gdWBtViRaF');
copyBtn1793590535s0mt0.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535s0mt0).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535s0mt0.innerHTML;
copyBtn1793590535s0mt0.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535s0mt0.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535s0mt0);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535s0mt0);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535s0mt0.innerHTML;
copyBtn1793590535s0mt0.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535s0mt0.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535s0mt0 = document.getElementById('codeflask-bottomBtn-gdWBtViRaF');
const Toggle1793590535s0mt0 = document.getElementById('codeflask-Toggle-gdWBtViRaF');
bottomBtn1793590535s0mt0.addEventListener('click', function() {
if (isCollapsed1793590535s0mt0) {
// 展开代码
isCollapsed1793590535s0mt0 = false;
const codeElement1793590535s0mt0 = editorElem1793590535s0mt0.querySelector('.codeflask__code');
if (codeElement1793590535s0mt0) {
const actualHeight1793590535s0mt0 = codeElement1793590535s0mt0.scrollHeight + 20;
editorElem1793590535s0mt0.parentElement.style.height = actualHeight1793590535s0mt0 + 'px';
editorElem1793590535s0mt0.style.height = actualHeight1793590535s0mt0 + 'px';
}
bottomBtn1793590535s0mt0.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535s0mt0.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535s0mt0 = true;
if (coderow1793590535s0mt0 < 20) {
editorElem1793590535s0mt0.parentElement.style.height = '300px';
editorElem1793590535s0mt0.style.height = '300px';
} else if (coderow1793590535s0mt0 >= 20) {
editorElem1793590535s0mt0.parentElement.style.height = '500px';
editorElem1793590535s0mt0.style.height = '500px';
}
bottomBtn1793590535s0mt0.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535s0mt0.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535s0mt0.addEventListener('click', function() {
bottomBtn1793590535s0mt0.click();
});
</script><div class="ce-block ce-block--focused" data-id="d2nolCUn_B" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>Discord Bot(可选)</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="S6Wd669m_4" >
<div class="ce-block__content">
<ol class="cdx-list-ordered" style="list-style-type:none; margin-left: -15px;"><li class="cdx-list__item">1. 访问<span> </span><a href="https://discord.com/developers/applications">Discord Developer Portal</a></li><li class="cdx-list__item">2. 创建新的 Application</li><li class="cdx-list__item">3. 在 Bot 选项卡中创建 Bot</li><li class="cdx-list__item">4. 启用必要的 Intents(Message Content Intent 等)</li><li class="cdx-list__item">5. 复制 Bot Token</li></ol>
</div>
</div><div class="ce-block" data-id="H2uRRvaLhW" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">环境变量模板</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="W91fLXfYul" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">创建一个<span> </span><code></code><mark style="background-color: rgb(236, 120, 120);"><code>.env</code></mark> 文件作为配置模板:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="Ipyld9AnVw" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">python</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-Ipyld9AnVw">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-Ipyld9AnVw">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-Ipyld9AnVw" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-Ipyld9AnVw">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SeC"></script>
<script type="application/javascript">
const editorElem1793590535NQgJf = document.getElementById('codeflask-Ipyld9AnVw');
var isCollapsed1793590535NQgJf = true;
const flask1793590535NQgJf = new CodeFlask(editorElem1793590535NQgJf, {
language: 'python',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1793590535NQgJf = ``;
code1793590535NQgJf = code1793590535NQgJf.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1793590535NQgJf.addLanguage('python', Prism.languages['python']);
flask1793590535NQgJf.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1793590535NQgJf.updateCode(code1793590535NQgJf);
const currentCode1793590535NQgJf = flask1793590535NQgJf.getCode();
var coderow1793590535NQgJf = parseInt('');
if (coderow1793590535NQgJf === undefined || coderow1793590535NQgJf !== coderow1793590535NQgJf || coderow1793590535NQgJf === 0) {
coderow1793590535NQgJf = flask1793590535NQgJf.lineNumber;
}
if (coderow1793590535NQgJf < 20) {
editorElem1793590535NQgJf.parentElement.style.height = '300px';
editorElem1793590535NQgJf.style.height = '300px';
} else if (coderow1793590535NQgJf >= 20) {
editorElem1793590535NQgJf.parentElement.style.height = '500px';
editorElem1793590535NQgJf.style.height = '500px';
}
//console.log({currentCode1793590535NQgJf})
const copyBtn1793590535NQgJf = document.getElementById('codeflask-copy-Ipyld9AnVw');
copyBtn1793590535NQgJf.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1793590535NQgJf).then(function() {
// 复制成功提示
const originalText = copyBtn1793590535NQgJf.innerHTML;
copyBtn1793590535NQgJf.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1793590535NQgJf.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1793590535NQgJf);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1793590535NQgJf);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1793590535NQgJf.innerHTML;
copyBtn1793590535NQgJf.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1793590535NQgJf.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1793590535NQgJf = document.getElementById('codeflask-bottomBtn-Ipyld9AnVw');
const Toggle1793590535NQgJf = document.getElementById('codeflask-Toggle-Ipyld9AnVw');
bottomBtn1793590535NQgJf.addEventListener('click', function() {
if (isCollapsed1793590535NQgJf) {
// 展开代码
isCollapsed1793590535NQgJf = false;
const codeElement1793590535NQgJf = editorElem1793590535NQgJf.querySelector('.codeflask__code');
if (codeElement1793590535NQgJf) {
const actualHeight1793590535NQgJf = codeElement1793590535NQgJf.scrollHeight + 20;
editorElem1793590535NQgJf.parentElement.style.height = actualHeight1793590535NQgJf + 'px';
editorElem1793590535NQgJf.style.height = actualHeight1793590535NQgJf + 'px';
}
bottomBtn1793590535NQgJf.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1793590535NQgJf.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1793590535NQgJf = true;
if (coderow1793590535NQgJf < 20) {
editorElem1793590535NQgJf.parentElement.style.height = '300px';
editorElem1793590535NQgJf.style.height = '300px';
} else if (coderow1793590535NQgJf >= 20) {
editorElem1793590535NQgJf.parentElement.style.height = '500px';
editorElem1793590535NQgJf.style.height = '500px';
}
bottomBtn1793590535NQgJf.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1793590535NQgJf.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1793590535NQgJf.addEventListener('click', function() {
bottomBtn1793590535NQgJf.click();
});
</script><div class="ce-block ce-block--focused" data-id="9hP6cBGt-i" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>安全提示</b>:<span> </span>永远不要将<span> </span><code><mark style="background-color: rgb(236, 120, 120);">.env</mark></code><span> </span>文件提交到 Git 仓库。确保<span> </span><code><mark style="background-color: rgb(236, 120, 120);">.gitignore</mark></code><span> </span>中包含<span> </span><code><mark style="background-color: rgb(236, 120, 120);">.env</mark></code>。</div>
</div>
</div><div class="ce-block" data-id="vngXAOxx_8" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">检查清单</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="FoVINQUSj6" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">在进入下一章之前,确认你已完成:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="LW86W1PgqO" >
<div class="ce-block__content">
<ul class="cdx-list-unordered"><li class="cdx-list__item"><span> </span>安装 Node.js 18+ 或 Docker</li><li class="cdx-list__item"><span> </span>安装 Git 并配置基本信息</li><li class="cdx-list__item"><span> </span>获得至少一个 LLM API 密钥并测试可用</li><li class="cdx-list__item"><span> </span>创建至少一个消息平台机器人账号</li><li class="cdx-list__item"><span> </span>准备好<span> </span><code><mark style="background-color: rgb(236, 120, 120);">.env</mark></code><span> </span>配置文件模板</li><li class="cdx-list__item"><span> </span>确保网络可以访问相关 API 服务</li></ul>
</div>
</div><div class="ce-block ce-block--focused" data-id="-2lhoXuqeH" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">完成这些准备后,你就可以开始安装
<span style="color: rgb(55, 65, 81); font-family: "Public Sans", "Public Sans Fallback"; font-size: medium; letter-spacing: normal;">Open</span> Claw 了。</div>
</div>
</div><style type="text/css">
.ce-block {
margin-top: 20px;
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
}
/**
* Plugin styles
*/
.ce-header {
position: relative;
padding: 1px 0px 1px 15px;
margin: 0;
line-height: 1.25em;
outline: none;
margin-bottom: 10px;
}
.ce-header p,
.ce-header div {
padding: 0 !important;
margin: 0 !important;
}
.ce-header::before {
content: "";
background-color: #3e8fe3;
width: 6px;
height: 100%;
position: absolute;
left: 0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
/**
* Styles for Plugin icon in Toolbar
*/
.ce-header__icon {
}
.ce-header::before {
position: absolute;
content: attr(data-placeholder);
color: #707684;
font-weight: normal;
display: none;
cursor: text;
}
.ce-header:empty::before {
display: block;
}
.ce-header:empty:focus::before {
display: none;
}
/* FontSize */
h1.ce-header {
font-size: 2.0em;
}
h2.ce-header {
font-size: 1.7em;
}
h3.ce-header {
font-size: 1.4em;
}
h4.ce-header {
font-size: 1.15em;
}
h5.ce-header {
font-size: 0.95em;
}
h6.ce-header {
font-size: 0.8em;
}
/* Alignment*/
.ce-header--right {
text-align: right;
}
.ce-header--center {
text-align: center;
}
.ce-header--left {
text-align: left;
}
.ce-header--justify {
text-align: justify;
}
</style><style type="text/css">
.ce-block {
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
}
.ce-paragraph {
line-height: 1.6em;
outline: none;
text-indent: 2em;
font-size: 16px;
}
.ce-paragraph--right {
text-align: right;
}
.ce-paragraph--center {
text-align: center;
}
.ce-paragraph--left {
text-align: left;
}
.ce-paragraph--justify {
text-align: justify;
}
.ce-paragraph-text-indent {
text-align: justify;
}
.ce-paragraph:empty::before{
content: attr(data-placeholder);
color: #707684;
font-weight: normal;
opacity: 0;
}
/** Show placeholder at the first paragraph if Editor is empty */
.codex-editor--empty .ce-block:first-child .ce-paragraph:empty::before {
opacity: 1;
}
.codex-editor--toolbox-opened .ce-block:first-child .ce-paragraph:empty::before,
.codex-editor--empty .ce-block:first-child .ce-paragraph:empty:focus::before {
opacity: 0;
}
.ce-paragraph p:first-of-type{
margin-top: 0;
}
.ce-paragraph p:last-of-type{
margin-bottom: 0;
}
.svg-icon {
width: 1em;
height: 1em;
}
.svg-icon path,
.svg-icon polygon,
.svg-icon rect {
fill: #4691f6;
}
.svg-icon circle {
stroke: #4691f6;
stroke-width: 1;
}
</style><style type="text/css">
.ce-block {
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
}
.cdx-list {
margin:0;
outline:none;
display:block;
counter-reset:item;
padding:6px;
}
.cdx-list__item {
line-height:1.45em;
display:block;
padding-top:8px;
margin-left: 2em;
}
.cdx-list__item-children {
display:block;
}
.cdx-list__item {
outline:none
}
.cdx-list__item-content {
word-break:break-word;
white-space:pre-wrap;
grid-area:content;
padding-left:8px
}
.cdx-list__item:before {
counter-increment:item;
white-space:nowrap
}
.cdx-list-li-container {
display: flex;
}
.cdx-list-ordered .cdx-list__item:before {
/* content:counters(item,".",numeric) "." */
}
.cdx-list-ordered {
list-style-type: none;
margin-left: -15px;
counter-reset:item;
font-size: 16px;
}
.cdx-list-unordered {
font-size: 16px;
}
.cdx-list-unordered .cdx-list__item:before {
content:"•"
}
.cdx-list-checklist .cdx-list__item:before {
content:""
}
.cdx-list__settings .cdx-settings-button {
width:50%
}
.cdx-list__checkbox {
padding-top:calc((1.45em - 1.2em) / 2);
grid-area:checkbox;
width:1.2em;
height:1.2em;
display:flex;
cursor:pointer;
font-size: 16px;
}
.cdx-list__checkbox svg {
opacity:0;
height:1.2em;
width:1.2em;
left:-1px;
top:-1px;
position:absolute
}
@media (hover:hover) {
.cdx-list__checkbox:not(.cdx-list__checkbox--no-hover):hover .cdx-list__checkbox-check svg {
opacity:1
}
}.cdx-list__checkbox--checked-1 {
line-height:1.45em
}
@media (hover:hover) {
.cdx-list__checkbox--checked-1:not(.cdx-list__checkbox--checked-1--no-hover):hover .cdx-checklist__checkbox-check {
background:#0059AB;
border-color:#0059AB
}
}.cdx-list__checkbox--checked-1 .cdx-list__checkbox-check {
background:#369FFF;
border-color:#369FFF
}
.cdx-list__checkbox--checked-1 .cdx-list__checkbox-check svg {
opacity:1
}
.cdx-list__checkbox--checked-1 .cdx-list__checkbox-check svg path {
stroke:#fff
}
.cdx-list__checkbox--checked-1 .cdx-list__checkbox-check:before {
opacity:0;
visibility:visible;
transform:scale(2.5)
}
.cdx-list__checkbox-check {
cursor:pointer;
display:inline-block;
position:relative;
margin:0 auto;
width:1.2em;
height:1.2em;
box-sizing:border-box;
border-radius:5px;
border:1px solid #C9C9C9;
background:#fff
}
.cdx-list__checkbox-check:before {
content:"";
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
border-radius:100%;
background-color:#369FFF;
visibility:hidden;
pointer-events:none;
transform:scale(1);
transition:transform .4s ease-out,opacity .4s
}
.cdx-list__checkbox-check--disabled {
pointer-events:none
}
.cdx-list-start-with-field {
background:#F8F8F8;
border:1px solid rgba(226,226,229,.2);
border-radius:6px;
padding:2px;
display:grid;
grid-template-columns:auto auto 1fr;
grid-template-rows:auto
}
.cdx-list-start-with-field--invalid {
background:#FFECED;
border:1px solid #E13F3F
}
.cdx-list-start-with-field--invalid .cdx-list-start-with-field__input {
color:#e13f3f
}
.cdx-list-start-with-field__input {
font-size:16px;
outline:none;
font-weight:500;
font-family:inherit;
border:0;
background:transparent;
margin:0;
padding:0;
line-height:22px;
min-width:calc(100% - 10px)
}
.cdx-list-start-with-field__input::placeholder {
color:#797979;
font-weight:500
}
</style><style type="text/css">
.ce-block {
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
position: relative;
}
/* 主容器 */
.editorjs-codeFlask_Wrapper {
border: 1px solid #dcdfe6;
border-radius: 5px;
background-color: #f6f8fa;
margin-bottom: 10px;
position: relative;
transition: all 0.3s ease;
width: 100%;
min-height: 100px;
overflow: hidden;
}
/* 标题栏 */
.editorjs-codeFlask_Header {
display: flex;
justify-content: flex-end;
align-items: center;
padding: 8px 12px;
background-color: #e9ecef;
border-bottom: 1px solid #dcdfe6;
position: relative;
z-index: 0; /* 从10降低到2 */
}
/* 语言显示 */
.editorjs-codeFlask_LangDisplay {
padding: 2px 8px;
background-color: #409eff;
color: white;
border-radius: 3px;
font-size: 12px;
font-weight: 500;
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
}
/* 内容容器 - 禁止纵向滚动 */
.editorjs-codeFlask_ContentContainer {
position: relative;
min-height: 100px;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
transition: height 0.3s ease;
}
/* 编辑器容器 - 禁止纵向滚动 */
.editorjs-codeFlask_Editor {
position: relative;
min-height: 100px;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
transition: height 0.3s ease;
}
/* 底部按钮容器 - 优化为更简洁的样式 */
.editorjs-codeFlask_BottomButtonContainer {
display: flex;
justify-content: center;
align-items: center;
padding: 4px;
background-color: #f8f9fa;
border-top: 1px solid #e9ecef;
position: relative;
z-index: 0;
}
/* 底部横向折叠/展开按钮 - 优化样式,使其更融入设计 */
.editorjs-codeFlask_BottomToggle {
width: 100%;
background-color: transparent;
color: #606266;
border: none;
border-radius: 4px;
padding: 6px 12px;
font-size: 12px;
font-weight: 400;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
text-align: center;
position: relative;
}
.editorjs-codeFlask_BottomToggle:hover {
background-color: #e9ecef;
color: #409eff;
}
.editorjs-codeFlask_BottomToggle:active {
background-color: #dee2e6;
}
.editorjs-codeFlask_BottomToggle .toggle-icon {
font-size: 11px;
transition: transform 0.3s ease;
}
/* 展开按钮(显示"展开"文本)上边缘添加渐变虚化效果 */
.editorjs-codeFlask_BottomToggle:has(span.toggle-icon:contains("▲"))::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 6px;
background: linear-gradient(to bottom, rgba(248, 249, 250, 0) 0%, rgba(248, 249, 250, 1) 100%);
pointer-events: none;
}
/* 展开按钮(显示"展开"文本)上边缘添加渐变虚化效果 */
/* 删除不被广泛支持的:contains()选择器 */
.editorjs-codeFlask_BottomToggle.expand-mode::before {
content: '';
position: absolute;
top: -60px;
left: 0;
right: 0;
height: 60px;
background: linear-gradient(to bottom, rgb(255 255 255 / 0%) 0%, rgba(248, 249, 250, 1) 100%);
pointer-events: none;
}
/* CodeFlask 主容器样式 */
.editorjs-codeFlask_Editor .codeflask {
position: relative;
background: #fafafa;
border-radius: 0 0 4px 4px;
min-height: 100px;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}
/* 行号容器 */
.editorjs-codeFlask_Editor .codeflask.codeflask--has-line-numbers:before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 40px;
background-color: #f5f5f5;
border-right: 1px solid #e0e0e0;
z-index: 0;
}
/* 行号 */
.editorjs-codeFlask_Editor .codeflask__lines {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 40px;
padding: 10px 0;
background-color: #f5f5f5;
border-right: 1px solid #e0e0e0;
z-index: 0;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
color: #666;
text-align: right;
user-select: none;
overflow: hidden;
}
.editorjs-codeFlask_Editor .codeflask__lines__line {
padding-right: 8px;
}
/* 文本区域 - 输入框 */
.editorjs-codeFlask_Editor .codeflask__textarea {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 10px;
border: none;
background: transparent;
color: transparent;
caret-color: #333;
resize: none;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
z-index: 1;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
white-space: pre-wrap; /* 自动换行 */
tab-size: 4;
outline: none;
}
/* 添加选中文本样式 */
.editorjs-codeFlask_Editor .codeflask__textarea::selection {
background-color: #b3d4fc;
color: #333;
}
.editorjs-codeFlask_Editor .codeflask__textarea::-moz-selection {
background-color: #b3d4fc;
color: #333;
}
/* 代码预览区域 */
.editorjs-codeFlask_Editor .codeflask__pre {
position: absolute;
top: 0;
left: 0;
width: 100%; /* 确保宽度不超出容器 */
height: 100%;
padding: 10px;
margin: 0;
border: none;
background: transparent;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
z-index: 0;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
white-space: pre-wrap; /* 自动换行 */
pointer-events: none;
}
/* 代码高亮区域 */
.editorjs-codeFlask_Editor .codeflask__code {
display: block;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
color: #333;
white-space: pre-wrap; /* 自动换行 */
tab-size: 4;
overflow: visible;
}
/* 语法高亮样式 - 确保Prism.js样式正确应用 */
.editorjs-codeFlask_Editor .codeflask__code {
background: transparent !important;
}
/* 通用语法高亮token样式 */
.editorjs-codeFlask_Editor .token.comment,
.editorjs-codeFlask_Editor .token.prolog,
.editorjs-codeFlask_Editor .token.doctype,
.editorjs-codeFlask_Editor .token.cdata {
color: #708090;
}
.editorjs-codeFlask_Editor .token.punctuation {
color: #999;
}
.editorjs-codeFlask_Editor .token.namespace {
opacity: 0.7;
}
.editorjs-codeFlask_Editor .token.property,
.editorjs-codeFlask_Editor .token.tag,
.editorjs-codeFlask_Editor .token.boolean,
.editorjs-codeFlask_Editor .token.number,
.editorjs-codeFlask_Editor .token.constant,
.editorjs-codeFlask_Editor .token.symbol,
.editorjs-codeFlask_Editor .token.deleted {
color: #905;
}
.editorjs-codeFlask_Editor .token.selector,
.editorjs-codeFlask_Editor .token.attr-name,
.editorjs-codeFlask_Editor .token.string,
.editorjs-codeFlask_Editor .token.char,
.editorjs-codeFlask_Editor .token.builtin,
.editorjs-codeFlask_Editor .token.inserted {
color: #690;
}
.editorjs-codeFlask_Editor .token.operator,
.editorjs-codeFlask_Editor .token.entity,
.editorjs-codeFlask_Editor .token.url,
.editorjs-codeFlask_Editor .language-css .token.string,
.editorjs-codeFlask_Editor .style .token.string {
color: #9a6e3a;
background: hsla(0, 0%, 100%, 0.5);
}
.editorjs-codeFlask_Editor .token.atrule,
.editorjs-codeFlask_Editor .token.attr-value,
.editorjs-codeFlask_Editor .token.keyword {
color: #07a;
}
.editorjs-codeFlask_Editor .token.function,
.editorjs-codeFlask_Editor .token.class-name {
color: #dd4a68;
}
.editorjs-codeFlask_Editor .token.regex,
.editorjs-codeFlask_Editor .token.important,
.editorjs-codeFlask_Editor .token.variable {
color: #e90;
}
/* 复制按钮样式 */
.editorjs-codeFlask_CopyButton {
background-color: #409eff;
color: white;
border: none;
border-radius: 3px;
padding: 6px 12px;
margin-right: 8px;
font-size: 12px;
cursor: pointer;
transition: background-color 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
min-width: 28px;
height: 28px;
}
.editorjs-codeFlask_CopyButton:hover {
background-color: #66b1ff;
}
.editorjs-codeFlask_CopyButton.copied {
background-color: #67c23a;
}
/* 折叠/展开按钮样式 */
.editorjs-codeFlask_Toggle {
background-color: #909399;
color: white;
border: none;
border-radius: 3px;
padding: 0 8px;
font-size: 12px;
cursor: pointer;
transition: background-color 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
min-width: 28px;
height: 28px;
font-weight: bold;
}
.editorjs-codeFlask_Toggle:hover {
background-color: #a6a9ad;
}
/* 响应式调整 */
@media (max-width: 768px) {
.editorjs-codeFlask_Header {
padding: 6px 8px;
}
.editorjs-codeFlask_Editor .codeflask__textarea,
.editorjs-codeFlask_Editor .codeflask__pre,
.editorjs-codeFlask_Editor .codeflask__code {
font-size: 13px;
line-height: 19px;
padding: 8px;
}
.editorjs-codeFlask_Editor .codeflask.codeflask--has-line-numbers:before {
width: 35px;
}
.editorjs-codeFlask_Editor .codeflask__lines {
width: 35px;
font-size: 12px;
}
}
/* 滚动条样式 - 完全隐藏纵向滚动条 */
.editorjs-codeFlask_Wrapper ::-webkit-scrollbar {
width: 0;/* 纵向滚动条宽度为0 */
height: 6px;/* 横向滚动条保持6px宽度 */
}
.editorjs-codeFlask_Wrapper ::-webkit-scrollbar-track {
background: transparent;
border-radius: 0;
}
.editorjs-codeFlask_Wrapper ::-webkit-scrollbar-thumb {
background: transparent;
border-radius: 0;
}
/* Firefox 滚动条隐藏 */
.editorjs-codeFlask_Wrapper {
scrollbar-width: none;/* Firefox 隐藏纵向滚动条 */
}
.editorjs-codeFlask_Wrapper ::-moz-scrollbar {
width: 0;
height: 6px;
}
/* 焦点状态 */
.editorjs-codeFlask_Wrapper:focus-within {
border-color: #409eff;
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}
/* 只读模式样式 */
.editorjs-codeFlask_Wrapper.readonly .editorjs-codeFlask_Header {
background-color: #f5f7fa;
}
.editorjs-codeFlask_Wrapper.readonly .editorjs-codeFlask_Editor .codeflask__textarea {
cursor: default;
}
/* 确保所有元素正确显示 */
.editorjs-codeFlask_Wrapper * {
box-sizing: border-box;
}
/* 修复行号对齐 */
.editorjs-codeFlask_Editor .codeflask--has-line-numbers .codeflask__textarea,
.editorjs-codeFlask_Editor .codeflask--has-line-numbers .codeflask__pre {
padding-left: 50px;
}
.editorjs-codeFlask_Editor .codeflask--has-line-numbers .codeflask__lines {
padding-top: 10px;
}
/* 语言显示元素 - 添加点击样式 */
.editorjs-codeFlask_LangDisplay {
padding: 2px 8px;
background-color: #409eff;
color: white;
border-radius: 3px;
font-size: 12px;
font-weight: 500;
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
transition: all 0.2s ease;
}
.editorjs-codeFlask_LangDisplay:hover {
background-color: #66b1ff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* 语言选择弹窗 */
.editorjs-codeFlask_LanguagePopup {
background-color: white;
border: 1px solid #dcdfe6;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
width: 250px;
max-height: 300px;
z-index: 1000;
overflow: hidden;
}
/* 搜索框 */
.editorjs-codeFlask_LanguageSearch {
width: 100%;
padding: 8px 12px;
border: none;
border-bottom: 1px solid #ebeef5;
font-size: 12px;
outline: none;
box-sizing: border-box;
}
/* 语言列表 */
.editorjs-codeFlask_LanguagesList {
max-height: 250px;
overflow-y: auto;
}
/* 语言选项 */
.editorjs-codeFlask_LanguageItem {
padding: 8px 12px;
font-size: 12px;
cursor: pointer;
transition: background-color 0.2s ease;
}
.editorjs-codeFlask_LanguageItem:hover {
background-color: #f5f7fa;
}
.editorjs-codeFlask_LanguageItem.selected {
background-color: #ecf5ff;
color: #409eff;
font-weight: 500;
}
/* 滚动条样式 */
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar {
width: 6px;
}
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar-track {
background-color: #f5f7fa;
}
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar-thumb {
background-color: #c0c4cc;
border-radius: 3px;
}
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar-thumb:hover {
background-color: #909399;
}
</style><style type="text/css">
.inline-code {
background: rgba(250, 239, 240, 0.78);
color: #b44437;
padding: 3px 4px;
border-radius: 5px;
margin: 0 1px;
font-family: inherit;
font-size: 0.86em;
font-weight: 500;
letter-spacing: 0.3px;
}
</style>
页:
[1]