forked from nacos-group/nacos-group.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update wuyi & Rafractor Docs (nacos-group#701)
* feat: 更新无疑 * update By Robot2024-06-17 16:25:43 * update By Robot2024-06-17 17:36:28 * update By Robot2024-06-17 21:32:10 * update By Robot2024-06-18 10:50:03 * update By Robot2024-06-18 11:41:03 * update By Robot2024-06-18 12:17:20 * update By Robot2024-06-18 15:19:05 * update By Robot2024-06-18 15:50:37 * update By Robot2024-06-19 09:17:17 * update By Robot2024-06-19 10:03:10 * update By Robot2024-06-19 12:17:16 * update By Robot2024-06-19 23:02:00 * update By Robot2024-06-20 10:32:41 * update By Robot2024-06-20 22:02:28 * update By Robot2024-06-20 22:32:24 * update By Robot2024-06-21 11:22:03 * update By Robot2024-06-21 12:04:37 * feat: add 更新docs latest * feat: upload gpt * fix: docs * feat: fix description * fix bug --------- Co-authored-by: heimanba <[email protected]>
- Loading branch information
Showing
84 changed files
with
1,643 additions
and
1,030 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
import fs from "fs/promises"; | ||
import path from "path"; | ||
import { fileURLToPath } from 'url'; | ||
import { config } from "dotenv"; | ||
import { request } from "./util.js"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const envPath = path.resolve(__dirname, '../.env'); | ||
config({ path: envPath }); | ||
|
||
const isTranslate = false; | ||
|
||
const askAI = async (content) => { | ||
const url = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" | ||
const header = { | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer "+ process.env.QWEN_TOKEN | ||
} | ||
const body = { | ||
"model": "qwen-max", | ||
"input":{ | ||
"messages": [ | ||
{ | ||
"role": "system", | ||
"content": "你是SEO领域的专家,擅长总结文章并输出有利于SEO的关键词。你还是一个翻译专家,擅长以开源微服务为技术背景做中/英文之间的翻译,生成与中文文档格式完全一致的英文翻译稿" | ||
}, | ||
{ | ||
"role": "user", | ||
"content": `请阅读以下markdown格式的文章,并严格按照下面的格式输出回答,方便后续进行正则匹配和内容截取(关键词、描述信息、翻译后的英文文章},这些小标题一个字都不允许变),同时请注意关键词与描述信息需要为中文内容: | ||
1. 关键词: "总结的中文关键词,要求格式为数组,多个关键词用英文逗号分隔,不超过5个", | ||
2. 描述信息: "总结的内容,语言为中文,大概在150-160字之间,不要超过200字" | ||
3. 翻译后的英文文章:"根据原文翻译之后的英文文章。需要与我给你的格式完全相同,即需要有front-matter。不需要为markdown格式,为字符串格式即可" | ||
请根据以下原文进行生成返回内容: | ||
${content} | ||
` | ||
} | ||
] | ||
|
||
}, | ||
"parameters": { | ||
"result_format": "message" | ||
} | ||
} | ||
try { | ||
let res = await request(url, "POST", header, body); | ||
return res.output.choices[0].message.content | ||
} catch (error) { | ||
throw(error) | ||
} | ||
|
||
} | ||
|
||
async function traverseDirectorySync (dir) { | ||
try { | ||
const files = await fs.readdir(dir,{ withFileTypes: true }) | ||
// console.log("-======",files) | ||
for (const file of files) { | ||
const filePath = path.join(dir, file.name); | ||
if (file.isDirectory()) { | ||
// 如果是文件夹,输出文件夹路径并递归遍历 | ||
console.log(`目录:${filePath}`); | ||
traverseDirectorySync(filePath); | ||
} else if (file.name.endsWith('.md') || file.name.endsWith('.mdx')) { | ||
const data = await fs.readFile(filePath, 'utf8'); | ||
let res = await askAI(data); | ||
console.log(file.name, "回答问题完成"); | ||
console.log("======",res) | ||
const { keywords, description, content } = regContent(res); | ||
|
||
// 替换中文文档内容 | ||
await replaceZhContent( filePath, data, keywords, description ); | ||
// 生成英文翻译文件 | ||
isTranslate && await generateEnFile(filePath, content) | ||
} | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
|
||
function regContent(res) { | ||
const keywordsRegex = /关键词:\s*"([^"]*)"/; | ||
const regDescrip = /描述信息:\s*"([^"]*)"/; | ||
const regContent = /翻译后的英文文章:\s*"([\s\S]*)"/; | ||
|
||
const keywordsMatch = res.match(keywordsRegex); | ||
const keywords = keywordsMatch ? keywordsMatch[1].trim() : ''; | ||
|
||
const descripMatch = res.match(regDescrip); | ||
const description = descripMatch ? descripMatch[1].trim() : ''; | ||
|
||
const contentMatch = res.match(regContent); | ||
const content = contentMatch ? contentMatch[1].trim() : ''; | ||
return { keywords, description, content }; | ||
} | ||
// const filename = "activity-preview-nacos.md" | ||
// fs.readFile(path.resolve(__dirname, '../src/content/blog/activity-preview-nacos.md'), 'utf8') | ||
// .then(async data => { | ||
// // let res = await askAI(data); | ||
// // console.log(res) | ||
// const keywordsRegex = /关键词:\s*"([^"]*)"/; | ||
// const regDescrip = /描述信息:\s*"([^"]*)"/; | ||
// const regContent = /翻译后的英文文章:\s*"([\s\S]*)"/; | ||
|
||
// // const keywordsMatch = res.match(keywordsRegex); | ||
// // const keywords = keywordsMatch ? keywordsMatch[1].trim() : ''; | ||
// // console.log("关键词:", keywords); | ||
|
||
// // const descripMatch = res.match(regDescrip); | ||
// // const description = descripMatch ? descripMatch[1].trim() : ''; | ||
// // console.log("描述信息:", description); | ||
|
||
// // const contentMatch = res.match(regContent); | ||
// // const content = contentMatch ? contentMatch[1].trim() : ''; | ||
// // console.log("翻译后的英文文章:\n", content); | ||
|
||
// const keywords = "Nacos 0.1.0, Review活动, 社区交流, GitHub issue, 贡献流程, 小礼品奖励"; | ||
// const description = "文章概述了Nacos 0.1.0版本的Review活动设计,包括任务列表如官网与文档审查、功能测试、提供建议等,参与方式涉及加入社区微信群与提交GitHub issue,奖励机制鼓励突出贡献者,并强调沟通透明与建议采纳原则。"; | ||
// const content = ` | ||
// --- | ||
// title: Nacos 0.1.0 Version Review Event Design | ||
// keywords: [Nacos 0.1.0, Review event, community engagement, GitHub issue, contribution process, reward] | ||
// description: This article outlines the design of the Nacos 0.1.0 version review event, featuring tasks such as reviewing official website and documentation, testing functionalities, and providing suggestions. It details participation methods including joining the community WeChat group and submitting GitHub issues, with a reward mechanism to incentivize notable contributors, emphasizing transparent communication and the principle of suggestion adoption. | ||
// date: \"2018-11-15\" | ||
// category: activity-preview | ||
// --- | ||
|
||
// # Nacos 0.1.0 Version Review Event Design | ||
|
||
// ## I. Activity Task List | ||
|
||
// - Review official content, identify bugs, and suggest improvements for both Chinese and English websites. | ||
// - Read through the Chinese and English documentation, find errors, and propose enhancements, especially focusing on poor English translations. | ||
// - Test the code compilation, Nacos server startup/shutdown流程, and suggest improvements. | ||
// - Attempt to configure and launch multi-node Nacos cluster mode, offering improvement advice. | ||
// - Utilize the Nacos Java SDK and provide feedback for enhancements. | ||
// - Try the Nacos Open API and suggest improvements. | ||
// - Follow the 'How to Contribute to Nacos Documentation TODO' guide, test the contribution process, and give feedback. | ||
// - Submit requirements, development plans, ideas, and requests for Nacos. | ||
|
||
// ## II. Participation Methods | ||
|
||
// - Scan the WeChat QR code of 'Super Brother' to join the 'Nacos Community Chat Group'. | ||
// - Choose one or more tasks from Section I. | ||
// - Report issues or bugs found following the 'Issue Reporting Process' in Section III, assigning them to @github user[xuechaos](https://github.com/xuechaos). | ||
|
||
// ## III. Issue Reporting Process | ||
|
||
// * Process details TODO | ||
|
||
// ## IV. Reward Mechanism | ||
|
||
// * Customized small gifts are being prepared for contributors who make outstanding contributions, with consideration for shipping to those who stand out during the process. | ||
// * The gifts, though modest, aim to express gratitude for your assistance. | ||
|
||
// ## V. Additional Notes | ||
|
||
// * Not every suggestion will necessarily be adopted, but we will endeavor to communicate our considerations if your suggestion is not implemented. | ||
// * Prefer using email lists or reporting issues over reporting problems in the WeChat group to document and facilitate our communication process.` | ||
// replaceZhContent(path.resolve(__dirname, '../src/content/blog/activity-preview-nacos.md'),data, keywords, description); | ||
// // generateEnFile(filename, content ) | ||
// }) | ||
|
||
const replaceZhContent = async (filePath, data, keywords, description) => { | ||
const keywordsRegex = /keywords: \[\s*([^"]*)\]\n/s; | ||
const regDescrip = /description:\s*([^\n]*)\n/; | ||
const oriKeywordMatch = data.match(keywordsRegex); | ||
const originKeywords = oriKeywordMatch ? oriKeywordMatch[0].trim() : ''; | ||
const oriDescripMatch = data.match(regDescrip); | ||
const originDescrip = oriDescripMatch ? oriDescripMatch[0].trim() : ''; | ||
|
||
const newData = data.replace(originKeywords,`keywords: [${keywords}]`).replace(originDescrip, `description: ${description}`); | ||
|
||
try { | ||
await fs.writeFile(filePath, newData, 'utf8'); | ||
console.log(`${filePath} 已被更新完成`); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
|
||
const generateEnFile = async (filename, content) => { | ||
const enFilename = filename.replace('zh-cn', 'en'); | ||
try { | ||
await fs.writeFile(enFilename, content, 'utf8'); | ||
console.log(`${enFilename} 已被生成`); | ||
} catch (err) { | ||
console.log("err",err) | ||
} | ||
} | ||
|
||
await traverseDirectorySync(path.resolve(__dirname, '../src/content/docs/ebook/zh-cn')) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const request = async (url, method = "GET", headers = {}, body = {}) => { | ||
const res = await fetch(url, { headers, method, body: JSON.stringify(body) }); | ||
if (!res.ok) throw new Error(res.statusText); | ||
const data = await res.json(); | ||
if (data.error) { | ||
throw new Error(data.error) | ||
} else { | ||
return data; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
id: "question-history-15791" | ||
title: "nacos配置中心原理 nacos-opensource" | ||
date: "2024-06-21" | ||
category: "expertConsultation" | ||
description: "Nacos配置中心的工作原理主要基于以下几个核心步骤,结合您提供的知识内容,我们可以深入解析这一过程:### 1. **服务启动与配置初始化**- **添加依赖**:在Spring Boot项目中,通过添加`nacos-config-spring-boot-starter`依赖,使得应用能够与Nac" | ||
--- | ||
|
||
## 用户问题 : | ||
nacos配置中心原理 nacos-opensource | ||
|
||
--------------- | ||
## 专家官方解答 : | ||
|
||
Nacos配置中心的工作原理主要基于以下几个核心步骤,结合您提供的知识内容,我们可以深入解析这一过程: | ||
|
||
### 1. **服务启动与配置初始化** | ||
|
||
- **添加依赖**:在Spring Boot项目中,通过添加`nacos-config-spring-boot-starter`依赖,使得应用能够与Nacos配置服务集成。 | ||
- **配置Nacos地址**:在`application.properties`或`application.yml`中指定Nacos服务器的地址,确保应用能连接到Nacos服务器。 | ||
- **加载配置源**:使用`@NacosPropertySource`注解,可以在应用启动时从Nacos服务器加载指定的配置文件(dataId)。此步骤实现了配置的初始加载。 | ||
|
||
### 2. **动态配置更新** | ||
|
||
- **自动刷新**:通过在`@NacosPropertySource`注解中设置`autoRefreshed=true`,可以使应用在Nacos中的配置发生变化时自动刷新这些配置。这依赖于Nacos客户端监听Nacos服务器上的配置变更事件。 | ||
- **属性注入**:使用`@NacosValue`注解,可以将Nacos中的配置值直接注入到Bean的字段中,并支持自动刷新。这意味着应用运行时的配置可以做到实时更新而无需重启服务。 | ||
|
||
### 3. **服务注册与发现** | ||
|
||
- **添加依赖**:通过引入`nacos-discovery-spring-boot-starter`,使应用具备服务注册与发现的能力。 | ||
- **配置发现服务器地址**:同样在`application.properties`中设置Nacos发现服务的地址。 | ||
- **服务实例注册**:应用启动时,会自动向Nacos服务器注册自身信息(如IP、端口等),使得其他服务可以通过Nacos发现并调用它。 | ||
- **服务发现**:应用可以通过Nacos提供的API查询注册在Nacos上的其他服务实例,实现服务间的调用和负载均衡。 | ||
|
||
### 原理解释 | ||
|
||
Nacos配置中心的核心在于其提供了一个集中式的配置管理和服务发现平台。应用通过Spring Boot Starter与Nacos集成后,能够在启动时自动从Nacos服务器获取配置信息,并在配置变更时自动更新,保证了配置的一致性和实时性。同时,Nacos的服务发现机制允许微服务在启动时注册自身信息,并能发现其他服务实例,为微服务架构中的服务调用提供了基础。 | ||
|
||
### 结论 | ||
|
||
综上所述,Nacos配置中心原理涉及到配置的初始化加载、动态更新以及服务的注册与发现,通过Spring Boot与Nacos的紧密集成,极大地简化了分布式系统中的配置管理和服务治理工作。如果您有更细节的技术疑问或实践操作上的问题,欢迎继续提问。 | ||
|
||
|
||
<font color="#949494">---------------</font> | ||
|
||
|
||
## 参考链接 : | ||
|
||
*[Nacos 融合 Spring Boot,成为注册配置中心](https://nacos.io/docs/latest/ecology/use-nacos-with-spring-boot) | ||
|
||
|
||
<font color="#949494">---------------</font> | ||
|
||
|
||
|
||
## <font color="#FF0000">答疑服务说明:</font> | ||
|
||
本内容经由技术专家审阅的用户问答的镜像生成,我们提供了<font color="#FF0000">专家智能答疑服务</font>,在<font color="#FF0000">页面的右下的浮窗”专家答疑“</font>。您也可以访问 : [全局专家答疑](https://answer.opensource.alibaba.com/docs/intro) 。 咨询其他产品的的问题 | ||
|
||
### 反馈 | ||
如问答有错漏,欢迎点:[差评](https://ai.nacos.io/user/feedbackByEnhancerGradePOJOID?enhancerGradePOJOId=15801)给我们反馈。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
id: "question-history-15792" | ||
title: "如何快速搭建nacos配置中心? nacos-opensource" | ||
date: "2024-06-21" | ||
category: "expertConsultation" | ||
description: "要快速搭建 Nacos 配置中心,请按照以下步骤操作:1. **下载并启动 Nacos Server**: 首先,您需要从 Nacos 的官方 GitHub 仓库下载 Nacos 并启动 Nacos Server。这一步是使用 Nacos 的前提条件。具体操作步骤可以参考 Nacos 官方文档的" | ||
--- | ||
|
||
## 用户问题 : | ||
如何快速搭建nacos配置中心? nacos-opensource | ||
|
||
--------------- | ||
## 专家官方解答 : | ||
|
||
要快速搭建 Nacos 配置中心,请按照以下步骤操作: | ||
|
||
1. **下载并启动 Nacos Server**: | ||
首先,您需要从 Nacos 的官方 GitHub 仓库下载 Nacos 并启动 Nacos Server。这一步是使用 Nacos 的前提条件。具体操作步骤可以参考 Nacos 官方文档的[快速入门](../quickstart/quick-start.md)部分。这个环节涉及到解压下载的 Nacos 压缩包,然后通过命令行启动 Nacos 服务器。 | ||
|
||
2. **配置 Nacos Server**: | ||
在启动 Nacos Server 时,您可能需要根据实际情况调整一些配置项,比如端口号、数据存储方式等。这些配置通常在 Nacos 的 `conf` 目录下的 `application.properties` 文件中完成。 | ||
|
||
3. **在 Spring 应用中集成 Nacos 配置管理**: | ||
- **添加依赖**: 在您的 Spring 项目的 `pom.xml` 文件中添加 Nacos Spring Context 的依赖。确保使用的版本是最新的,您可以在 [mvnrepository.com](https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-spring-context) 查找最新版本号。 | ||
- **配置启用**: 在 Spring 配置类上添加 `@EnableNacosConfig` 注解以启用 Nacos 配置管理,并通过 `@NacosPropertySource` 加载特定的配置文件,例如 `dataId` 为 `example` 的配置源。同时,设置 `globalProperties` 来指定 Nacos Server 的地址,如 `"127.0.0.1:8848"`。 | ||
- **使用注解读取配置**: 在需要使用配置的类或方法上,使用 `@NacosValue` 注解读取配置值,支持自动刷新配置。 | ||
|
||
4. **验证配置管理功能**: | ||
- 启动您的 Spring Boot 应用后,尝试通过 REST API 访问应用中受 Nacos 管理的配置项,验证配置是否生效以及是否能动态更新。比如,访问 `http://localhost:8080/config/get` 查看配置值。 | ||
- 动态修改 Nacos Server 上的配置,并观察 Spring 应用是否能实时获取到最新的配置信息。可以通过 Nacos 提供的 Open API 发布配置,例如更新 `example` 配置的 `useLocalCache` 值。 | ||
|
||
以上步骤完成后,您就成功搭建并验证了一个基本的 Nacos 配置中心环境,可以开始在分布式系统中利用 Nacos 进行配置管理了。请确保每一步操作都符合您的实际开发和部署环境需求。 | ||
|
||
|
||
<font color="#949494">---------------</font> | ||
|
||
|
||
## 参考链接 : | ||
|
||
*[Nacos 融合 Spring,成为注册配置中心](https://nacos.io/docs/latest/ecology/use-nacos-with-spring) | ||
|
||
|
||
<font color="#949494">---------------</font> | ||
|
||
|
||
|
||
## <font color="#FF0000">答疑服务说明:</font> | ||
|
||
本内容经由技术专家审阅的用户问答的镜像生成,我们提供了<font color="#FF0000">专家智能答疑服务</font>,在<font color="#FF0000">页面的右下的浮窗”专家答疑“</font>。您也可以访问 : [全局专家答疑](https://answer.opensource.alibaba.com/docs/intro) 。 咨询其他产品的的问题 | ||
|
||
### 反馈 | ||
如问答有错漏,欢迎点:[差评](https://ai.nacos.io/user/feedbackByEnhancerGradePOJOID?enhancerGradePOJOId=15802)给我们反馈。 |
Oops, something went wrong.