├── .eslintignore ├── .eslintrc ├── .github └── img │ └── demo.png ├── .gitignore ├── README.md ├── README.zh-CN.md ├── env.d.ts ├── index.html ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── public └── favicon.ico ├── src ├── App.vue ├── assets │ ├── fonts │ │ └── Monaco.ttf │ └── images │ │ └── bg-macos.jpg ├── components │ ├── FolderTree │ │ ├── FolderTree.vue │ │ └── RootTree.vue │ ├── TermBody │ │ ├── TermBody.vue │ │ └── TermCommand │ │ │ ├── BaseCommand.vue │ │ │ ├── HistoryCommand.vue │ │ │ └── InputCommand.vue │ ├── TermHeader.vue │ ├── TermMessage.vue │ └── common │ │ ├── TermHelp.vue │ │ └── TermWelcome.vue ├── hooks │ ├── useAddEventListener.ts │ ├── useFullScreen.ts │ └── useGlobalFocus.ts ├── main.ts ├── store │ ├── commands │ │ ├── cat.ts │ │ ├── cd.ts │ │ ├── clear.ts │ │ ├── echo.ts │ │ ├── help.ts │ │ ├── ls.ts │ │ ├── mkdir.ts │ │ ├── open.ts │ │ ├── pwd.ts │ │ ├── rm.ts │ │ ├── touch.ts │ │ ├── tree.ts │ │ └── welcome.ts │ └── useDirectoryStore.ts ├── styles │ └── index.css ├── utils │ └── provide-inject_keys.ts └── views │ ├── TermApp.vue │ └── TermContainer.vue ├── tailwind.config.js ├── tsconfig.config.json ├── tsconfig.json └── vite.config.ts /.eslintignore: -------------------------------------------------------------------------------- 1 | *.md 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@antfu", 3 | "rules": { 4 | "no-unused-vars": "off", 5 | "@typescript-eslint/no-unused-vars": ["error"], 6 | "@typescript-eslint/comma-dangle": ["error", "never"], 7 | "@typescript-eslint/brace-style": "off", 8 | "antfu/if-newline": "off", 9 | "curly": "off" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.github/img/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hacker-C/vue3-terminal/22f24c186a9885d5f609e9d33dcf4ad1298b762f/.github/img/demo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Node template 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | 62 | # parcel-bundler cache (https://parceljs.org/) 63 | .cache 64 | 65 | # next.js build output 66 | .next 67 | 68 | # nuxt.js build output 69 | .nuxt 70 | 71 | # Nuxt generate 72 | dist 73 | 74 | # vuepress build output 75 | .vuepress/dist 76 | 77 | # Serverless directories 78 | .serverless 79 | 80 | # IDE 81 | .idea 82 | .vscode 83 | .eslintrc-auto-import.json -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | English | 中文 3 |
4 | 5 | # Vue3-Terminal 6 | 7 | ## About 8 | 9 | Hi! Here is a mini terminal built with Vue3 + TS + Pinia + TailwindCSS! 10 | 11 | Onlie: https://term.mphy.me 12 | 13 |  14 | 15 | It has some basic commands below(with the most basic usage): 16 | 17 | - `tree` - show the file and folder tree 18 | - `echo [message]` - print message 19 | - `echo [message] > [filename]` - write file 20 | - `echo [message] >> [filename]` - append context to file 21 | - `cat [filename]` - read file 22 | - `cd [dirname]` - change directory 23 | - `cd ..` - goto last directory 24 | - `ls` - list files in current directory 25 | - `pwd` - print current directory 26 | - `clear` - clear screen 27 | - `mkdir [dirname]` - create directory 28 | - `touch [filename]` - create file 29 | - `welcome` - welcome message 30 | - `help` - help message 31 | - `open [url]` - open url in new tab' 32 | - `google [keywords]` - search keywords in google 33 | - `baidu [keywords]` - search keywords in baidu 34 | - `github` - the source code of this project 35 | 36 | More commands will be added... 37 | 38 | ## Future plan 39 | 40 | - `rm` - remove file 41 | - `rd` - remove directory 42 | - `j` - jump to a directory 43 | - `mv` - move file 44 | - `mkdir` - limit name of directory(`/`) 45 | - `tree` - optimize the display of file tree 46 | - Make a visual desktop file system(?) 47 | 48 | ## Framework and library 49 | 50 | - Vue3 + TypeScript + Vite 51 | - Pinia 52 | - TailwindCSS 53 | 54 | ## Develop 55 | 56 | ```bash 57 | # Install 58 | pnpm install 59 | # Run 60 | pnpm dev 61 | # Build 62 | pnpm build 63 | ``` 64 | 65 | ## Descriptiton 66 | 67 | The data structure of the terminal system is a *N-ary tree* which simulates the diractory structure of real machine. But there is a slight difference between them, I design a pointer called previous point to its parent node. 68 | 69 | > **Note** 70 | > More about n-ary-tree: [N-ary Tree Data Structure](https://www.studytonight.com/advanced-data-structures/nary-tree) 71 | 72 | ```ts 73 | interface Directory { 74 | id: number // id 75 | name: string // current directory name 76 | files: File[] // all files below current directory 77 | directories: Directory[] // all diractories, alos a pointer which points to its children nodes 78 | previous: Directory | null // a pointer which points to its parent node 79 | } 80 | ``` 81 | 82 | This is the file data structure: 83 | ```ts 84 | interface File { 85 | name: string // file name 86 | value: string // file content 87 | } 88 | ``` -------------------------------------------------------------------------------- /README.zh-CN.md: -------------------------------------------------------------------------------- 1 |2 | English | 中文 3 |
4 | 5 | # Vue3-Terminal 6 | 7 | ## 关于本项目 8 | 9 | Vue3-Terminal 是一个基于 Vue3 的迷你终端,和其他类似的前端模拟终端不同,Vue3-Term 基于 *N叉树*,实现了一些基本的 cd、mkdir、pwd、touch、clear 等命令。 10 | 11 | 在线访问: https://term.mphy.me 12 | 13 |  14 | 15 | 一些已经实现的具有最基本功能的命令: 16 | 17 | - `tree` - 将文件和文件夹以树结构展示 18 | - `echo [message]` - 打印信息 19 | - `echo [message] > [filename]` - 文件写入 20 | - `echo [message] >> [filename]` - 文件内容追加 21 | - `cat [filename]` - 文件读取 22 | - `cd [dirname]` - 改变当前目录 23 | - `cd ..` - 返回上一级目录 24 | - `ls` - 列出当前目录下的文件和目录(文件显示白色,文件夹显示绿色) 25 | - `pwd` - 打印当前目录 26 | - `clear` - 清屏 27 | - `mkdir [dirname]` - 创建目录 28 | - `touch [filename]` - 创建文件 29 | - `welcome` - 欢迎信息 30 | - `help` - 帮助信息 31 | - `google [keywords]` - 在 Google 搜索关键词 32 | - `baidu [keywords]` - 在百度搜索关键词 33 | - `github` - 打开项目源码地址 34 | 35 | 36 | ## 未来计划 37 | 38 | - `rm` - remove file 39 | - `rd` - remove directory 40 | - `j` - jump to a directory 41 | - `mv` - move file 42 | - `mkdir` - limit name of directory(`/`) 43 | - `tree` - optimize the display of file tree 44 | - Make a visual desktop file system(?) 45 | 46 | ## 技术栈 47 | 48 | - Vue3 + TypeScript + Vite 49 | - Pinia 50 | - TailwindCSS 51 | 52 | ## 开发 53 | 54 | ```bash 55 | # Install 56 | pnpm install 57 | # Run 58 | pnpm dev 59 | # Build 60 | pnpm build 61 | ``` 62 | 63 | ## 原理 64 | 65 | 这个终端系统的数据结构是一个 *N叉树(N-ary Tree)*,它模拟了真机的目录结构,以便实现新建文件和目录等功能。但是有一点不同,我设计了一个指针属性 `previous`,指向它的父节点,以便实现 `cd ..` 命令。 66 | 67 | > **Note** 68 | > 更多关于 N 叉树的知识: [N-ary Tree Data Structure](https://www.studytonight.com/advanced-data-structures/nary-tree) 69 | 70 | 目录类型的结构: 71 | ```ts 72 | interface Directory { 73 | id: number // id 74 | name: string // 当前目录名称 75 | files: File[] // 当前目录下的文件列表 76 | directories: Directory[] // 当前目录下的子目录列表,同时也是指向子目录的指针 77 | previous: Directory | null // 指向父目录的指针 78 | } 79 | ``` 80 | 81 | 文件类型的结构: 82 | ```ts 83 | interface File { 84 | name: string // file name 85 | value: string // file content 86 | } 87 | ``` -------------------------------------------------------------------------------- /env.d.ts: -------------------------------------------------------------------------------- 1 | ///
5 | You can start with
6 | pwd,ls,cd,mkdir,touch,clear...(just the most basic usage) to play
7 | with, more commands will be added soon.
8 |
9 | Online:
10 | https://term.mphy.me
11 | Source:
12 | https://github.com/Hacker-C/vue3-terminal
17 |
18 |
19 | Type `help` for more information.
20 |
35 | Vue3 Terminal 36 |
37 |