1 Star 0 Fork 21

jackzhou / yuindex

forked from 程序员鱼皮 / yuindex 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

YuIndex - 极客范儿的浏览器主页

Coolest browser index for geeks!

前后端全栈项目 By 程序员鱼皮

在线体验:https://yuindex.com

YuIndex 定制你的最强主页

YuIndex 用命令来控制网页

YuIndex 是什么?

一个很特别的浏览器主页,支持使用输入命令的方式来操作,目标是帮你在一个 web 终端中高效完成所有的事情!(all in one)

此外,它也是一个功能强大的 web 终端组件。开发者可以在它的基础上定制自己的 web 终端,并且可以在终端中集成任何内容!

如果你是一名程序员,相信你会爱上它~

你可以将音乐、游戏,甚至可以将自己的偶像封装到主页~

1 分钟上手使用

请打开网站:https://yuindex.com

然后在网站内依次输入以下命令:

baidu 程序员鱼皮
github yuindex
goto yupi.icu
todo
music 坤坤
moyu
按键 Ctrl + O 触发折叠, 再按可展开
history
按键 Ctrl + L 清屏

使用 help 命令英文名 可以查询某命令的具体用法,如:help search

使用 shortcut 可以查看所有的快捷键。

完整命令用法请见:命令手册

尽情探索吧~

项目优势

用户

  • 无需鼠标,即可快速完成操作(比如从不同平台搜索内容)
  • 极简炫酷,极客范儿,Linux 的味道儿~
  • 支持快捷键、帮助和输入提示,降低使用成本
  • 支持定制背景等,打造你的个性主页
  • 帮助你熟悉 Linux 命令,感受到编程的乐趣

开发者

  • 可以独立使用功能丰富的 web 终端组件,或二次开发
  • 可以开发自己的命令并接入系统

学习者

  • 可以学到 web 终端的开发方式
  • 可以学到系统设计知识,理解抽象和复用
  • 可以学到较为规范的代码目录和格式

功能和特性

web 终端

  • 命令历史记录、快速执行历史命令
  • 快捷键
  • 清屏
  • 命令输入提示
  • 多种格式输出
  • 内置 5 种输出状态
  • 命令折叠
  • 帮助手册生成
  • 自定义配置(比如更换背景、提示开关等)
  • 支持子命令

已支持命令

完整命令用法请见:命令手册

  • 多平台搜索 search
  • 网页快速跳转 goto
  • 空间管理(类似收藏夹,可以存储网页信息)
  • 查看日期 date
  • 翻译 fanyi
  • 待办事项 todo
  • 网络检测 ping
  • 定时器 timing
  • 更换背景 background
  • 听音乐 music
  • 摸鱼小游戏 moyu
  • 坤坤 ikun
  • 其他。。。

技术栈

前端

主要技术:

  • Vue 3
  • Vite 2
  • Ant Design Vue 3 组件库
  • Pinia 2 状态管理
  • TypeScript 类型控制
  • Eslint 代码规范控制
  • Prettier 美化代码

依赖库:

  • axios 网络请求
  • dayjs 时间处理
  • lodash 工具库
  • getopts 命令参数解析

库:getopts

后端

主要技术:

  • Node.js
  • Express、express-session
  • MySQL
  • Sequelize(ORM 框架)
  • Redis

依赖库:

  • Axios
  • NeteaseCloudMusicApi

依赖服务:

  • 百度翻译 API
  • 新浪壁纸 API

点击了解后端详情

目录结构

  • public 公共静态资源
  • server 后端
  • src
    • assets 静态资源
    • components 组件
      • yu-terminal 终端组件
    • configs 配置
      • routes 路由
    • core 核心
      • commands 命令集
      • commandRegister 命令注册
      • commandExecutor 命令执行器
    • pages 页面
      • IndexPage.vue 主页
    • plugins 第三方依赖
    • utils 工具
    • App.vue 主页面
    • env.d.ts 环境定义
    • main.ts Vue 主文件
  • .eslintrc.js 代码规范
  • components.d.ts 自动生成的组件动态引入
  • Dockerfile 镜像构建
  • index.html 静态主页
  • package.json 项目管理
  • tsconfig.json TS 配置
  • vite.config.ts 打包工具配置

系统设计

设计理念

  1. 开放:采用类插件化设计,便于开发者自定义新命令,且能够通过配置自动生成帮助提示
  2. 重前端轻后端:考虑到扩展性、安全性以及实现的方便,除了核心模块外,尽量不请求后端

核心

系统分为 3 个核心模块,各模块职责分明:

  • 微终端:UI 展示和终端交互逻辑
  • 命令系统:连接微终端和命令集(中介者),负责匹配、解析和执行命令,并通过终端提供的操作接口给予其反馈
  • 命令集:各种不同功能的命令定义和实现

前端架构图:

微终端

从 0 开始实现的 web 终端控制台,包含以下模块:

  • 终端输入:常驻 Input 框,负责接收用户命令
  • 终端输出:负责展示用户的命令及执行结果等,支持以下三种类型的输出
    • 命令类型:输入命令 + 结果列表
    • 文本类型:单行文本展示,内置 5 种不同的展示状态(成功、错误、警告、信息、系统等)
    • 自定义组件类型:可以自由定制要展示的内容
  • 快捷键:更方便地操作终端,使用 document.onkeydown 全局按键事件实现
  • 开放接口:提供一组操作终端的 API,供命令系统调用,比如清屏、立即输出等
  • 命令历史:记录用户输入的命令结果,使用 Vue 3 Composition API 封装部分逻辑
  • 命令提示:根据用户的输入给出提示,使用 Vue 3 Composition API 独立封装

命令系统

一套独立于终端的命令解析执行引擎,包含以下模块:

  • 注册器:用于注册和管理可被匹配的命令集
  • 匹配器:根据输入文本匹配到对应的命令
  • 解析器:从输入文本中解析出参数和选项
  • 执行器:执行命令,完成操作
  • 子命令机制:支持递归解析子命令

命令集

一组可用命令的集合(类似插件),通过 TS 明确命令的定义,支持配置别名、选项、子命令等,便于开发者扩展和定制。

核心命令包括:

  • 空间系统:自实现的类文件系统,可以管理网页链接等内容
  • 用户系统:管理用户、同步个人定制化内容
  • 终端控制:定制或控制终端,比如更换背景、输出帮助等
  • 搜索:可以快速从不同搜索引擎检索内容
  • 其他模块。。。

为什么要自己写终端?

  1. 本来打算使用现成的 xterm.js,但实际使用中发现它的文档比较少、问题难解决(比如中文字符),解决问题消耗的时间足够自己写一套新的 web 终端了。而且它更适用于和后端服务器强交互的场景,与本项目的定位不符。
  2. 开源的 web 终端很少,给开源贡献一份力。
  3. 帮助自己复习 Vue,突破个人系统开发设计能力的边界。

更多讲解

如果你希望获取该项目的完整详细讲解,欢迎加入 鱼皮的编程知识星球 ,这是鱼皮的编程学习圈子,我会在圈子内带大家从 0 到 1 分析解读这个项目,让你也能独立做一个,项目经历 + 1。

贡献指南

欢迎各位朋友贡献代码,还请先阅读以下指南。

开发新命令

  1. 在 commands 下新建目录,目录名称为命令英文名称,所有该命令相关的代码都必须放在该目录中
  2. 编写命令定义文件 xxxCommand.ts(xxx 为命令英文名称),可以参考其他命令,如 music、goto 等
  3. 若命令包含子命令,需要将子命令相关文件放到 subCommands 目录中,可以参考 user 命令
  4. 在 commandRegister 的 commandList 中补充新命令
  5. 测试验证通过后,可以发起 PR 等鱼皮合并

致谢

摸鱼命令的实现依赖于 https://haiyong.site/moyu ,感谢大佬的开源分享。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [coder_yupi] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

✨ 新项目 - 极客范儿的浏览器主页 💻 Vue 3 + Node.js 全栈项目,自实现 web 终端 + 命令系统 展开 收起
TypeScript
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/git_checkout_jack/yuindex.git
git@gitee.com:git_checkout_jack/yuindex.git
git_checkout_jack
yuindex
yuindex
master

搜索帮助