Compare commits

..

1 Commits
main ... v3.0.0

Author SHA1 Message Date
chaos-zhu
6dce6fe87c plus&功能重构 2024-11-09 13:05:38 +08:00
40 changed files with 616 additions and 2207 deletions

1
.gitignore vendored
View File

@ -14,4 +14,3 @@ plan.md
.env-encrypt-key
*clear.js
local-script
版本发布.md

View File

@ -1,22 +1,3 @@
## [3.0.3](https://github.com/chaos-zhu/easynode/releases) (2024-12-22)
* 支持keyboard-interactive服务器验证(serv00验证通过)
* 支持TG Bot通知方式
* 添加web端Plus授权功能
* 修复一些UI问题
* 修复MFA2登录验证码为0开头无法输入的bug
## [3.0.2](https://github.com/chaos-zhu/easynode/releases) (2024-11-20)
* 修复添加实例错误禁用的bug
## [3.0.1](https://github.com/chaos-zhu/easynode/releases) (2024-11-18)
* 修复同IP实例SFTP连接到其他的实例的bug
* 修复一些UI问题
## [3.0.0](https://github.com/chaos-zhu/easynode/releases) (2024-11-09)
* 新增跳板机功能,支持选择多台机器跳转
@ -26,7 +7,6 @@
* 分组添加实例数量标识
* 优化登录逻辑
* 默认登录有效期更改为当天有效
* 优化脚本库新增脚本时序号自动累加
* 修复一些小bug
## [2.3.0](https://github.com/chaos-zhu/easynode/releases) (2024-10-24)

131
README.md
View File

@ -1,61 +1,29 @@
<div align="center">
# EasyNode
_✨ 一个多功能Linux服务器WEB终端面板(webSSH&webSFTP) ✨_
</div>
<p align="center">
<a href="https://github.com/chaos-zhu/easynode/releases/latest">
<img src="https://img.shields.io/github/v/release/chaos-zhu/easynode?color=brightgreen" alt="release">
</a>
<a href="https://github.com/chaos-zhu/easynode/actions">
<img src="https://img.shields.io/github/actions/workflow/status/chaos-zhu/easynode/docker-builder.yml?branch=main" alt="deployment status">
</a>
<a href="https://hub.docker.com/repository/docker/chaoszhu/easynode">
<img src="https://img.shields.io/docker/pulls/chaoszhu/easynode?color=brightgreen" alt="docker pull">
</a>
<a href="https://github.com/chaos-zhu/easynode/releases/latest">
<img src="https://img.shields.io/github/downloads/chaos-zhu/easynode/total?color=brightgreen&include_prereleases" alt="release">
</a>
<a href="https://raw.githubusercontent.com/chaos-zhu/easynode/main/LICENSE">
<img src="https://img.shields.io/github/license/chaos-zhu/easynode?color=brightgreen" alt="license">
</a>
</p>
<p align="center">
<a href="#功能">功能</a>
·
<a href="#面板展示">面板展示</a>
·
<a href="#项目部署">项目部署</a>
·
<a href="#监控服务安装">监控服务安装</a>
·
<a href="#安全与建议">安全与建议</a>
·
<a href="#常见问题">常见问题</a>
<!-- ·
<a href="#Plus功能">Plus版功能</a> -->
</p>
<!-- - [功能](#功能)
- [安装](#安装)
- [监控服务安装](#监控服务安装)
- [版本日志](#版本日志)
- [开发](#开发)
- [QA](#QA)
- [安全与建议](#安全与建议)
- [捐赠](#捐赠)
- [License](#license) -->
## 功能
+ [x] 功能完善的**SSH终端**&**SFTP**
+ [x] 批量导入、导出、编辑服务器配置、脚本等
+ [x] 脚本库
+ [x] 实例分组
+ [x] 凭据托管
+ [x] 多渠道通知
+ [x] 批量下发指令
+ [x] 自定义终端主题
- [x] 功能完善的**SSH终端**&**SFTP**
- [x] 批量**导入导出**实例(Xshell&FinalShell&EasyNode)
- [x] **实例分组**
- [x] **凭据托管**
- [x] **多渠道通知**
- [x] **脚本库**
- [x] **批量指令**
- [x] **终端主题背景自定义**
## 面板展示
![实例面板](./doc_images/merge.gif)
![面板展示](./doc_images/merge.gif)
## 项目部署
## 安装
- 默认账户密码 `admin/admin`
- web端口8082
@ -63,15 +31,35 @@ _✨ 一个多功能Linux服务器WEB终端面板(webSSH&webSFTP) ✨_
### docker镜像
```shell
docker run -d -p 8082:8082 --restart=always -v /root/easynode/db:/easynode/app/db chaoszhu/easynode
docker run -d -p 8082:8082 --name=easynode --restart=always -v /root/easynode/db:/easynode/app/db chaoszhu/easynode
```
环境变量:
- `PLUS_KEY`: 激活PLUS功能的授权码
- `DEBUG`: 启动debug日志 0关闭 1开启, 默认关闭
- `ALLOWED_IPS`: 可以访问服务的IP白名单, 多个使用逗号分隔, 支持填写部分ip前缀, 例如: `-e ALLOWED_IPS=127.0.0.1,196.168`
### 手动部署
依赖Nodejs版本 > 20+
```shell
git clone https://github.com/chaos-zhu/easynode
cd easynode
yarn
cd web
yarn build
mv dist/* ../server/app/static
cd ../server
yarn start
# 后台运行需安装pm2
pm2 start index.js --name easynode-server
```
---
## 监控服务安装
- 监控服务用于实时向服务端&web端推送**系统、公网IP、CPU、内存、硬盘、网卡**等基础信息
- 监控服务用于实时向服务端推送**系统、公网IP、CPU、内存、硬盘、网卡**等基础信息不安装不影响使用面板但是无法实时同步cpu占用、实时网速、硬盘容量等实用信息。
- 默认端口:**22022**
@ -79,16 +67,16 @@ docker run -d -p 8082:8082 --restart=always -v /root/easynode/db:/easynode/app/d
```shell
# 使用默认端口22022安装
curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash
curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash
# 使用自定义端口安装, 例如54321
curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash -s -- 54321
curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash -s -- 54321
```
> 卸载
```shell
curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-uninstall.sh | bash
curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-uninstall.sh | bash
```
> 查看监控服务状态:`systemctl status easynode-client`
@ -99,6 +87,20 @@ curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easy
---
## 开发
1. 拉取代码,环境 `nodejs>=20`
2. cd到项目根目录`yarn install` 执行安装依赖
3. `yarn dev`启动项目
4. web: `http://localhost:18090/`
## 版本日志
- [CHANGELOG](./CHANGELOG.md)
## QA
- [QA](./Q%26A.md)
## 安全与建议
@ -109,15 +111,14 @@ curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easy
webssh与监控服务都将以`该服务器作为中转`。中国大陆用户建议使用香港、新加坡、日本、韩国等地区的低延迟服务器来安装服务端面板
## 常见问题
## 捐赠
- [QA](./Q%26A.md)
如果您认为此项目帮到了您, 您可以请我喝杯阔乐~
<!-- ## Plus版功能
![wx](./doc_images/wx.jpg)
- 跳板机功能,拯救被墙实例与龟速终端输入
- 本地socket断开自动重连,无需手动重新连接
- 批量修改实例配置(优化版)
- 脚本库批量导出导入
- 凭据管理支持解密带密码保护的密钥
- 提出的功能需求享有更高的开发优先级 -->
## License
[MIT](LICENSE). Copyright (c).
![访问数](https://profile-counter.glitch.me/easynode/count.svg)

View File

@ -10,7 +10,7 @@ SERVER_NAME=easynode-client
FILE_PATH=/root/local/easynode-client
SERVICE_PATH=/etc/systemd/system
CLIENT_VERSION=client-2024-10-13 # 目前监控客户端版本发布需手动更改为最新版本号
SERVER_PROXY="https://git.221022.xyz/"
SERVER_PROXY="https://ghp.ci/"
if [ ! -z "$1" ]; then
clientPort=$1

View File

@ -1,12 +1,12 @@
[
{
"name": "easynode监控服务安装",
"command": "curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash",
"command": "curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash",
"description": "easynode-监控服务-安装脚本"
},
{
"name": "easynode监控服务卸载",
"command": "curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-uninstall.sh | bash",
"command": "curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-uninstall.sh | bash",
"description": "easynode-监控服务-卸载脚本"
},
{

View File

@ -1,17 +1,17 @@
const path = require('path')
const decryptAndExecuteAsync = require('../utils/decrypt-file')
const { RSADecryptAsync, AESEncryptAsync, AESDecryptAsync } = require('../utils/encrypt')
const { HostListDB } = require('../utils/db-class')
const hostListDB = new HostListDB().getInstance()
async function getHostList({ res }) {
// console.log('get-host-list')
let data = await hostListDB.findAsync({})
data?.sort((a, b) => Number(b.index || 0) - Number(a.index || 0))
for (const item of data) {
try {
let { authType, _id: id, credential } = item
let { username, port, authType, _id: id, credential } = item
// console.log('解密凭证title: ', credential)
if (credential) credential = await AESDecryptAsync(credential)
const isConfig = Boolean(authType && item[authType])
const isConfig = Boolean(username && port && (item[authType]))
Object.assign(item, { id, isConfig, password: '', privateKey: '', credential })
} catch (error) {
consola.error('getHostList error: ', error.message)
@ -21,49 +21,86 @@ async function getHostList({ res }) {
}
async function addHost({ res, request }) {
let { body } = request
if (!body.name || !body.host) return res.fail({ msg: 'missing params: name or host' })
let newRecord = { ...body }
const { authType, tempKey } = newRecord
if (newRecord[authType] && tempKey) {
const clearTempKey = await RSADecryptAsync(tempKey)
const clearSSHKey = await AESDecryptAsync(newRecord[authType], clearTempKey)
newRecord[authType] = await AESEncryptAsync(clearSSHKey)
let {
body: {
name, host, index, expired, expiredNotify, group, consoleUrl, remark,
port: newPort, clientPort, username, authType, password, privateKey, credential, command, tempKey
}
await hostListDB.insertAsync(newRecord)
} = request
// console.log(request)
if (!host || !name) return res.fail({ msg: 'missing params: name or host' })
let record = {
name, host, index, expired, expiredNotify, group, consoleUrl, remark,
port: newPort, clientPort, username, authType, password, privateKey, credential, command
}
if (record[authType]) {
const clearTempKey = await RSADecryptAsync(tempKey)
console.log('clearTempKey:', clearTempKey)
const clearSSHKey = await AESDecryptAsync(record[authType], clearTempKey)
console.log(`${ authType }原密文: `, clearSSHKey)
record[authType] = await AESEncryptAsync(clearSSHKey)
// console.log(`${ authType }__commonKey加密存储: `, record[authType])
}
await hostListDB.insertAsync(record)
res.success()
}
async function updateHost({ res, request }) {
let {
body
body: {
hosts,
id,
host: newHost, name: newName, index, oldHost, expired, expiredNotify, group, consoleUrl, remark,
port, clientPort, username, authType, password, privateKey, credential, command, tempKey, jumpHosts = []
}
} = request
if (typeof body !== 'object') return res.fail({ msg: '参数错误' })
const updateFiled = { ...body }
const { id, authType, tempKey } = updateFiled
if (authType && updateFiled[authType]) {
const clearTempKey = await RSADecryptAsync(tempKey)
const clearSSHKey = await AESDecryptAsync(updateFiled[authType], clearTempKey)
updateFiled[authType] = await AESEncryptAsync(clearSSHKey)
delete updateFiled.tempKey
let isBatch = Array.isArray(hosts)
if (isBatch) {
if (!hosts.length) return res.fail({ msg: 'hosts为空' })
let hostList = await hostListDB.findAsync({})
for (let oldRecord of hostList) {
let target = hosts.find(item => item.id === oldRecord._id)
if (!target) continue
let { authType } = target
// 如果存在原认证方式则保存下来
if (!target[authType]) {
target[authType] = oldRecord[authType]
} else {
delete updateFiled.authType
delete updateFiled.password
delete updateFiled.privateKey
delete updateFiled.credential
const clearTempKey = await RSADecryptAsync(target.tempKey)
// console.log('批量解密tempKey:', clearTempKey)
const clearSSHKey = await AESDecryptAsync(target[authType], clearTempKey)
// console.log(`${ authType }原密文: `, clearSSHKey)
target[authType] = await AESEncryptAsync(clearSSHKey)
// console.log(`${ authType }__commonKey加密存储: `, target[authType])
}
console.log('updateFiled: ', updateFiled)
await hostListDB.updateAsync({ _id: id }, { $set: { ...updateFiled } })
res.success({ msg: '修改成功' })
}
delete target.monitorData
delete target.tempKey
Object.assign(oldRecord, target)
await hostListDB.updateAsync({ _id: oldRecord._id }, oldRecord)
}
return res.success({ msg: '批量修改成功' })
}
if (!newHost || !newName || !oldHost) return res.fail({ msg: '参数错误' })
async function batchUpdateHost({ res, request }) {
let { updateHosts } = (await decryptAndExecuteAsync(path.join(__dirname, 'plus.js'))) || {}
if (updateHosts) {
await updateHosts({ res, request })
} else {
return res.fail({ data: false, msg: 'Plus专属功能!' })
let updateRecord = {
name: newName, host: newHost, index, expired, expiredNotify, group, consoleUrl, remark,
port, clientPort, username, authType, password, privateKey, credential, command, jumpHosts
}
let oldRecord = await hostListDB.findOneAsync({ _id: id })
// 如果存在原认证方式则保存下来
if (!updateRecord[authType] && oldRecord[authType]) {
updateRecord[authType] = oldRecord[authType]
} else {
const clearTempKey = await RSADecryptAsync(tempKey)
// console.log('clearTempKey:', clearTempKey)
const clearSSHKey = await AESDecryptAsync(updateRecord[authType], clearTempKey)
// console.log(`${ authType }原密文: `, clearSSHKey)
updateRecord[authType] = await AESEncryptAsync(clearSSHKey)
// console.log(`${ authType }__commonKey加密存储: `, updateRecord[authType])
}
await hostListDB.updateAsync({ _id: oldRecord._id }, updateRecord)
res.success({ msg: '修改成功' })
}
async function removeHost({ res, request }) {
@ -111,6 +148,5 @@ module.exports = {
addHost,
updateHost,
removeHost,
importHost,
batchUpdateHost
importHost
}

View File

@ -1,5 +1,3 @@
const path = require('path')
const decryptAndExecuteAsync = require('../utils/decrypt-file')
const { sendServerChan, sendEmail } = require('../utils/notify')
const { NotifyConfigDB, NotifyDB } = require('../utils/db-class')
const notifyDB = new NotifyDB().getInstance()
@ -7,6 +5,7 @@ const notifyConfigDB = new NotifyConfigDB().getInstance()
async function getNotifyConfig({ res }) {
const data = await notifyConfigDB.findOneAsync({})
console.log(data)
return res.success({ data })
}
@ -14,7 +13,6 @@ async function updateNotifyConfig({ res, request }) {
let { body: { noticeConfig } } = request
let { type } = noticeConfig
try {
// console.log('noticeConfig: ', noticeConfig[type])
switch (type) {
case 'sct':
await sendServerChan(noticeConfig[type]['sendKey'], 'EasyNode通知测试', '这是一条测试通知')
@ -22,12 +20,6 @@ async function updateNotifyConfig({ res, request }) {
case 'email':
await sendEmail(noticeConfig[type], 'EasyNode通知测试', '这是一条测试通知')
break
case 'tg':
let { sendTg } = await decryptAndExecuteAsync(path.join(__dirname, '../utils/plus.js')) || {}
console.log('sendTg: ', sendTg)
if (!sendTg) return res.fail({ msg: 'Plus专属功能点请激活Plus' })
await sendTg(noticeConfig[type], 'EasyNode通知测试', '这是一条测试通知')
break
}
await notifyConfigDB.update({}, { $set: noticeConfig }, { upsert: true })
return res.success({ msg: '测试通过 | 保存成功' })

View File

@ -1 +1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hunk/Q3vGuS/x8FCjK

View File

@ -1,8 +1,8 @@
const path = require('path')
const decryptAndExecuteAsync = require('../utils/decrypt-file')
const localShellJson = require('../config/shell.json')
const { randomStr } = require('../utils/tools')
const { ScriptsDB } = require('../utils/db-class')
const localShellJson = require('../config/shell.json')
const decryptAndExecuteAsync = require('../utils/decrypt-file')
const scriptsDB = new ScriptsDB().getInstance()
let localShell = JSON.parse(JSON.stringify(localShellJson)).map((item) => {
@ -58,7 +58,7 @@ const importScript = async ({ res, request }) => {
if (impScript) {
await impScript({ res, request })
} else {
return res.fail({ data: false, msg: 'Plus专属功能!' })
return res.fail({ data: false, msg: 'Plus专属功能,无法导入脚本!' })
}
}

View File

@ -2,14 +2,10 @@ const jwt = require('jsonwebtoken')
const axios = require('axios')
const speakeasy = require('speakeasy')
const QRCode = require('qrcode')
const version = require('../../package.json').version
const getLicenseInfo = require('../utils/get-plus')
const { plusServer1, plusServer2 } = require('../utils/plus-server')
const { sendNoticeAsync } = require('../utils/notify')
const { RSADecryptAsync, AESEncryptAsync, SHA1Encrypt } = require('../utils/encrypt')
const { getNetIPInfo } = require('../utils/tools')
const { KeyDB, LogDB, PlusDB } = require('../utils/db-class')
const keyDB = new KeyDB().getInstance()
const logDB = new LogDB().getInstance()
const plusDB = new PlusDB().getInstance()
@ -90,7 +86,7 @@ const beforeLoginHandler = async (clientIp, jwtExpires) => {
let token = jwt.sign({ date: Date.now() }, commonKey, { expiresIn: jwtExpires }) // 生成token
token = await AESEncryptAsync(token) // 对称加密token后再传输给前端
// 记录客户端登录IP(用于判断是否异地且只保留最近10<EFBFBD><EFBFBD>)
// 记录客户端登录IP(用于判断是否异地且只保留最近10)
const clientIPInfo = await getNetIPInfo(clientIp)
const { ip, country, city } = clientIPInfo || {}
consola.info('登录成功:', new Date(), { ip, country, city })
@ -176,40 +172,6 @@ const getPlusInfo = async ({ res }) => {
res.success({ data, msg: 'success' })
}
const getPlusDiscount = async ({ res } = {}) => {
if (process.env.EXEC_ENV === 'local') return res.success({ discount: false })
const servers = [plusServer1, plusServer2]
for (const server of servers) {
try {
const url = `${ server }/api/announcement/public?version=${ version }`
const response = await fetch(url)
if (!response.ok) {
throw new Error(`HTTP error! status: ${ response.status }`)
}
const data = await response.json()
return res.success({ data, msg: 'success' })
} catch (error) {
if (server === servers[servers.length - 1]) {
consola.error('All servers failed:', error.message)
return res.success({ discount: false })
}
continue
}
}
}
const getPlusConf = async ({ res }) => {
const { key } = await plusDB.findOneAsync({}) || {}
res.success({ data: key || '', msg: 'success' })
}
const updatePlusKey = async ({ res, request }) => {
const { body: { key } } = request
const { success, msg } = await getLicenseInfo(key)
if (!success) return res.fail({ msg })
res.success({ msg: 'success' })
}
module.exports = {
login,
getpublicKey,
@ -219,8 +181,5 @@ module.exports = {
getMFA2Code,
enableMFA2,
disableMFA2,
getPlusInfo,
getPlusDiscount,
getPlusConf,
updatePlusKey
getPlusInfo
}

View File

@ -71,7 +71,8 @@ async function initNotifyDB() {
async function initNotifyConfigDB() {
const notifyConfigDB = new NotifyConfigDB().getInstance()
let notifyConfig = await notifyConfigDB.findOneAsync({})
let count = await notifyConfigDB.countAsync({})
if (count !== 0) return
consola.log('初始化NotifyConfigDB✔')
const defaultData = {
type: 'sct',
@ -82,17 +83,8 @@ async function initNotifyConfigDB() {
service: 'QQ',
user: '',
pass: ''
},
tg: {
token: '',
chatId: ''
}
}
if (notifyConfig) {
await notifyConfigDB.removeAsync({ _id: notifyConfig._id })
delete notifyConfig._id
return notifyConfigDB.insertAsync(Object.assign({}, defaultData, notifyConfig))
}
return notifyConfigDB.insertAsync(defaultData)
}

View File

@ -1,6 +1,6 @@
const { getSSHList, addSSH, updateSSH, removeSSH, getCommand, decryptPrivateKey } = require('../controller/ssh')
const { getHostList, addHost, updateHost, batchUpdateHost, removeHost, importHost } = require('../controller/host')
const { login, getpublicKey, updatePwd, getEasynodeVersion, getMFA2Status, getMFA2Code, enableMFA2, disableMFA2, getPlusInfo, getPlusDiscount, getPlusConf, updatePlusKey } = require('../controller/user')
const { getHostList, addHost, updateHost, removeHost, importHost } = require('../controller/host')
const { login, getpublicKey, updatePwd, getEasynodeVersion, getMFA2Status, getMFA2Code, enableMFA2, disableMFA2, getPlusInfo } = require('../controller/user')
const { getNotifyConfig, updateNotifyConfig, getNotifyList, updateNotifyList } = require('../controller/notify')
const { getGroupList, addGroupList, updateGroupList, removeGroup } = require('../controller/group')
const { getScriptList, getLocalScriptList, addScript, updateScriptList, removeScript, batchRemoveScript, importScript } = require('../controller/scripts')
@ -55,11 +55,6 @@ const host = [
path: '/host-save',
controller: updateHost
},
{
method: 'put',
path: '/batch-update-host',
controller: batchUpdateHost
},
{
method: 'post',
path: '/host-remove',
@ -116,21 +111,6 @@ const user = [
method: 'get',
path: '/plus-info',
controller: getPlusInfo
},
{
method: 'get',
path: '/plus-discount',
controller: getPlusDiscount
},
{
method: 'get',
path: '/plus-conf',
controller: getPlusConf
},
{
method: 'post',
path: '/plus-conf',
controller: updatePlusKey
}
]
const notify = [

View File

@ -1 +1 @@
U2FsdGVkX1+P63MsIfF2N9/XM16sWy0/pZMWy+0Ptf+FhySv/AiawI4Pcf/HQU7Auxde+GszGb7+t+i1Ckngo6VK9PkwALR87GbqCJtGeMazZTkEGkmNuePdpej0O3oAuwITI1FOKPW4Xe4RIFAkJfghqCgUD0Ps0Y6sPwIxOX7fTi4TopNksRMQ5X+UvezrGnPsF5EC2CAPmKwtRFWVqx5csAFhifvMxwEA+WCA7l9KLLvcybGtY4RZf0uSLb6qGxrJBN/zbQ1MMxVw9JbUML09uQ3VKLvQMJZmjctIpZDr4YEMMMdDD/qDk64feV8Tc5VPENsyl2i9kxZ4Z3s5pUu6oDm+/GE2ag0OMITgg7Wc6QpeqlWJwgAeGuqxz2nnuQfGbhHv4g800Hwc7C6ylYgHHeSY+gx39PyDQy1tE7vtW/83ZQUSgWRXxMYTMHUgYKh6P3XG+HxJz6vRjpZqwjPIc3jd253EQnHVG4YZ7VxjBFwpcmidnkvKMa+dvQSZypO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AaS8u6XtYctVC+zN5wEB6rraGLlJiEUhE2IJpMIx7iFpaseSqHnLGrz02o/rRmvK+erXp4YgAfM2VBdiBRc/tyTjI49CVnO29qDWfw2XUrm6XMhDb1AcH2f0BnspQ6EwSxoj2cFcLm73W9RLl+giMN360h7DPXIlCDSbfLNDLEjUyjaBJFa1z70Dq2vHRZ7gV5Erz9SE6gkd89u3NPHKMLZXneFWJIn8

View File

@ -224,18 +224,18 @@ module.exports = (httpServer) => {
let sftpClient = new SFTPClient()
consola.success('terminal websocket 已连接')
socket.on('create', async ({ hostId, token }) => {
socket.on('create', async ({ host: ip, token }) => {
const { code } = await verifyAuthSync(token, requestIP)
consola.log('code:', code)
if (code !== 1) {
socket.emit('token_verify_fail')
socket.disconnect()
return
}
const targetHostInfo = await hostListDB.findOneAsync({ _id: hostId })
if (!targetHostInfo) throw new Error(`Host with ID ${ hostId } not found`)
const hostList = await hostListDB.findAsync({})
const targetHostInfo = hostList.find(item => item.host === ip) || {}
let { authType, host, port, username } = targetHostInfo
if (!host) return socket.emit('create_fail', `查找id【${ hostId }】凭证信息失败`)
if (!host) return socket.emit('create_fail', `查找${ ip }】凭证信息失败`)
let authInfo = { host, port, username }
// 解密放到try里面防止报错【commonKey必须配对, 否则需要重新添加服务器密钥】

View File

@ -88,14 +88,11 @@ async function createTerminal(hostId, socket, targetSSHClient) {
consola.error('连接终端失败:', host, err.message)
socket.emit('connect_terminal_fail', err.message)
})
.on('keyboard-interactive', function (name, instructions, instructionsLang, prompts, finish) {
finish([targetConnectionOptions[authType]])
})
.connect({
tryKeyboard: true,
...targetConnectionOptions
// debug: (info) => console.log(info)
})
} catch (err) {
consola.error('创建终端失败: ', host, err.message)
socket.emit('create_terminal_fail', err.message)

View File

@ -1,17 +1,11 @@
const schedule = require('node-schedule')
const { getLocalNetIP } = require('./tools')
const { AESEncryptAsync } = require('./encrypt')
const version = require('../../package.json').version
const { plusServer1, plusServer2 } = require('./plus-server')
const { PlusDB } = require('./db-class')
const plusDB = new PlusDB().getInstance()
async function getLicenseInfo(key = '') {
const { key: plusKey } = await plusDB.findOneAsync({}) || {}
// console.log('plusKey: ', plusKey)
// console.log('key: ', key)
// console.log('process.env.PLUS_KEY: ', process.env.PLUS_KEY)
key = key || plusKey || process.env.PLUS_KEY
if (!key || key.length < 16) return { success: false, msg: 'Invalid Plus Key' }
async function getLicenseInfo() {
let key = process.env.PLUS_KEY
if (!key || typeof key !== 'string' || key.length < 20) return
let ip = ''
if (global.serverIp && (Date.now() - global.getServerIpLastTime) / 1000 / 60 < 60) {
ip = global.serverIp
@ -25,7 +19,7 @@ async function getLicenseInfo(key = '') {
if (!ip) {
consola.error('activate plus failed: get public ip failed')
global.serverIp = ''
return { success: false, msg: 'get public ip failed' }
return
}
try {
let response
@ -34,7 +28,7 @@ async function getLicenseInfo(key = '') {
let headers = { 'Content-Type': 'application/json' }
let timeout = 10000
try {
response = await fetch(plusServer1 + '/api/licenses/activate', {
response = await fetch('https://en1.221022.xyz/api/licenses/activate', {
method,
headers,
body,
@ -47,7 +41,7 @@ async function getLicenseInfo(key = '') {
} catch (error) {
consola.log('retry to activate plus by backup server')
response = await fetch(plusServer2 + '/api/licenses/activate', {
response = await fetch('https://en2.221022.xyz/api/licenses/activate', {
method,
headers,
body,
@ -69,7 +63,9 @@ async function getLicenseInfo(key = '') {
let { decryptKey, expiryDate, usedIPCount, maxIPs, usedIPs } = data
decryptKey = await AESEncryptAsync(decryptKey)
consola.success('activate plus success')
const { PlusDB } = require('./db-class')
const plusData = { key, decryptKey, expiryDate, usedIPCount, maxIPs, usedIPs }
const plusDB = new PlusDB().getInstance()
let count = await plusDB.countAsync({})
if (count === 0) {
await plusDB.insertAsync(plusData)
@ -77,17 +73,21 @@ async function getLicenseInfo(key = '') {
await plusDB.removeAsync({}, { multi: true })
await plusDB.insertAsync(plusData)
}
return { success: true, msg: '激活成功' }
}
consola.error('activate plus failed: ', data)
return { success: false, msg: '激活失败' }
} catch (error) {
consola.error(`activate plus failed: ${ error.message || error.errMsg?.message }`)
if (error.clear) {
const { PlusDB } = require('./db-class')
const plusDB = new PlusDB().getInstance()
await plusDB.removeAsync({}, { multi: true })
}
return { success: false, msg: error.message || error.errMsg?.message }
}
}
const randomHour = Math.floor(Math.random() * 24)
const randomMinute = Math.floor(Math.random() * 60)
const randomDay = Math.floor(Math.random() * 7)
const cronExpression = `${ randomMinute } ${ randomHour } * * ${ randomDay }`
schedule.scheduleJob(cronExpression, getLicenseInfo)
module.exports = getLicenseInfo

View File

@ -1,5 +1,3 @@
const path = require('path')
const decryptAndExecuteAsync = require('./decrypt-file')
const nodemailer = require('nodemailer')
const axios = require('axios')
const commonTemp = require('../template/commonTemp')
@ -8,6 +6,7 @@ const notifyConfigDB = new NotifyConfigDB().getInstance()
const notifyDB = new NotifyDB().getInstance()
function sendServerChan(sendKey, title, content) {
if (!sendKey) return consola.error('发送server酱通知失败, sendKey 为空')
return new Promise((async (resolve, reject) => {
try {
consola.info('server酱通知预发送: ', title)
@ -29,6 +28,7 @@ function sendServerChan(sendKey, title, content) {
}
function sendEmail({ service, user, pass }, title, content) {
if (!service || !user || !pass) return consola.info('发送通知失败, 邮箱配置信息不完整: ', { service, user, pass })
return new Promise((async (resolve, reject) => {
try {
consola.info('邮箱通知预发送: ', title)
@ -60,8 +60,8 @@ async function sendNoticeAsync(noticeAction, title, content) {
try {
let notifyList = await notifyDB.findAsync({})
let { sw } = notifyList.find((item) => item.type === noticeAction) // 获取对应动作的通知开关
// console.log('notify swtich: ', noticeAction, sw)
if (!sw) return consola.info('通知开关关闭, 不发送通知: ', noticeAction)
console.log('notify swtich: ', noticeAction, sw)
if (!sw) return
let notifyConfig = await notifyConfigDB.findOneAsync({})
let { type } = notifyConfig
if (!type) return consola.error('通知类型不存在: ', type)
@ -78,15 +78,7 @@ async function sendNoticeAsync(noticeAction, title, content) {
if (!service || !user || !pass) return consola.info('未发送邮件通知通知, 未配置邮箱: ', { service, user, pass })
await sendEmail({ service, user, pass }, title, content)
break
case 'tg':
let { token, chatId } = notifyConfig['tg']
if (!token || !chatId) return consola.info('未发送Telegram通知, 未配置token或chatId: ', { token, chatId })
let { sendTg } = await decryptAndExecuteAsync(path.join(__dirname, 'plus.js'))
if (!sendTg) return consola.info('未发送Telegram通知, Plus功能解析失败')
await sendTg({ token, chatId }, title, content)
break
default:
consola.info('未配置通知类型: ', type)
break
}
} catch (error) {

View File

@ -1,4 +0,0 @@
module.exports = {
plusServer1: 'https://en1.221022.xyz',
plusServer2: 'https://en2.221022.xyz'
}

View File

@ -1 +0,0 @@
U2FsdGVkX1+Gus2FIC0WsNp0rUXPA+Ui1NQUjtnqP6Ycb1pyHglCADvKu51oxYaGJ0ZdoRZYo7YP3tQgIhp3f96WxP1/QFdypVrVlS7+jbAH6Gzc4CPlD3UeFsCm1j32ArFX60tPSSkq6+DJ3OF6pIVxstGIbCkmv5NQaf0J95zCxgqGm+fo/nZmZ6oj21uspGWZjhHssFRol0KpzINFDSWE9+/hJ43ybT5G6OHvEiaF83YH6h3CXAa6zz2zV18LKvnO8A4nTYR2/EBmGiP6NE3YqQ7hTE7SFmEDtRaxKJfyBxs0bHDCcFifVZh8GE25VyDwvOihUHztgvIRMh9vkgehzx9YN3sZdAsBJqcWyqi1mEPZU/l+zq2tbO+EczCvz6JQ77RZToQxm0vXzJc/ctcCEoVvjDx1pJhsQiTj5tJirFgcYz4VC7ihFYIq2XUQNISZaLynpYUUPdjvIfXGcvk0500SK9VAKb6603Z3fABdsENDGuxl2UKXMed4sL/PFwLy9siEX3BgMg1hFFiwoqqEp/x75341BoeRavEIJBEv8BdTS66mel1lUa/L3so7LyjGpdgfzOZlv+0t6Uhzy82HwYkAWmvuYpK6s6JItsG1ftYrOBzHZbpu36wn0e4N4NLqBnm6Hx1+tQJY7lTmgokgUy+5sVtp4LEsTbgE64HbDLYhME4m/3Yw5ij5D1OhoNwm/9r6MEYyJOyv8j8nDjudLRe1YQ0D2JLQsr04LYpVrjU1+Tsg780K0j0JdnFfVhe/SdkVU8nbkIIfRkv/86N6U2ZQaCYaScZmKYdBQmsK//I2yuYym0tM5q2d5kesYTxy8uAtVIXL1rE065eZFPlg/7Mgu0sqUsspG+EeDJE=

View File

@ -1,6 +1,6 @@
{
"name": "server",
"version": "3.0.3",
"version": "3.0.0",
"description": "easynode-server",
"bin": "./bin/www",
"scripts": {
@ -43,7 +43,6 @@
"node-os-utils": "^1.3.7",
"node-rsa": "^1.1.1",
"node-schedule": "^2.1.1",
"node-telegram-bot-api": "^0.66.0",
"nodemailer": "^6.9.14",
"qrcode": "^1.5.4",
"socket.io": "^4.7.5",

View File

@ -1,6 +1,6 @@
{
"name": "web",
"version": "3.0.3",
"version": "3.0.0",
"description": "easynode-web",
"private": true,
"scripts": {

View File

@ -22,9 +22,6 @@ export default {
getPlusInfo() {
return axios({ url: '/plus-info', method: 'get' })
},
getPlusDiscount() {
return axios({ url: '/plus-discount', method: 'get' })
},
getCommand(hostId) {
return axios({ url: '/command', method: 'get', params: { hostId } })
},
@ -40,9 +37,6 @@ export default {
updateHost(data) {
return axios({ url: '/host-save', method: 'put', data })
},
batchUpdateHost(data) {
return axios({ url: '/batch-update-host', method: 'put', data })
},
removeHost(data) {
return axios({ url: '/host-remove', method: 'post', data })
},
@ -126,11 +120,5 @@ export default {
},
getEasynodeVersion() {
return axios({ url: '/version', method: 'get' })
},
getPlusConf() {
return axios({ url: '/plus-conf', method: 'get' })
},
updatePlusKey(data) {
return axios({ url: '/plus-conf', method: 'post', data })
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -10,7 +10,7 @@
size="small"
type="primary"
link
@click="gotoPlusPage"
@click="handlePlusSupport"
>
去激活
</el-button>
@ -22,15 +22,13 @@
<script setup>
import { computed, getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router'
const { proxy: { $store } } = getCurrentInstance()
const router = useRouter()
const isPlusActive = computed(() => $store.isPlusActive)
const gotoPlusPage = () => {
router.push('/setting?tabKey=plus')
const handlePlusSupport = () => {
window.open('https://en.221022.xyz/buy-plus', '_blank')
}
</script>

View File

@ -1,206 +0,0 @@
<template>
<div class="comparison-container">
<!-- 基础版卡片 -->
<el-card class="comparison-card basic-card">
<template #header>
<div class="card-header">
<span class="title">基础功能(免费)</span>
<el-tag size="small">Basic</el-tag>
</div>
</template>
<div class="feature-list">
<div v-for="(feature, index) in basicFeatures" :key="index" class="feature-item">
<el-icon>
<Check />
</el-icon>
<span>{{ feature }}</span>
</div>
</div>
</el-card>
<!-- Plus版卡片 -->
<el-card class="comparison-card plus-card">
<template #header>
<div class="card-header">
<div>
<span class="title">Plus专属功能</span>
<span class="link" style="margin-right: 15px;" @click="() => plusTipsShow = true">Plus说明</span>
</div>
<el-tag type="success" size="small">PLUS</el-tag>
</div>
</template>
<div class="feature-list">
<div v-for="(feature, index) in plusFeatures" :key="index" class="feature-item plus">
<el-icon color="#67c23a">
<Check />
</el-icon>
<span>{{ feature }}</span>
</div>
</div>
</el-card>
<el-dialog
v-model="plusTipsShow"
title="Plus说明"
top="20vh"
width="30%"
:append-to-body="false"
:close-on-click-modal="false"
>
<div class="about_content">
<p style="line-height: 2;letter-spacing: 1px;">
<!-- <strong style="color: #F56C6C;font-weight: 600;">PLUS说明:</strong><br> -->
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>EasyNode</strong>最初是一个简单的Web终端工具随着用户群的不断扩大功能需求也日益增长为了实现大家的功能需求我投入了大量的业余时间进行开发和维护
一直在为爱发电渐渐的也没了开发的动力
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;为了项目的可持续发展<strong>后续</strong>版本开始推出<strong>PLUS</strong>版本后续特性功能开发也会优先在<strong>PLUS</strong>版本中实现但即使不升级到<strong>PLUS</strong>也不会影响到<strong>EasyNode</strong>的基础功能使用注意:
暂不支持纯内网用户激活PLUS功能
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="text-decoration: underline;">
为了感谢前期赞赏过的用户, <strong>PLUS</strong>功能正式发布前所有进行过赞赏的用户无论金额大小均可联系作者TG: <a
class="link"
href="https://t.me/chaoszhu"
target="_blank"
>@chaoszhu</a> 凭打赏记录免费获取永久<strong>PLUS</strong>授权码
</span>
</p>
<div class="about_footer">
<el-button type="info" @click="plusTipsShow = false">关闭</el-button>
<el-button type="primary" @click="handlePlusSupport">购买Plus Key</el-button>
</div>
</div>
</el-dialog>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { Check } from '@element-plus/icons-vue'
import { handlePlusSupport } from '@/utils'
const plusTipsShow = ref(false)
//
const basicFeatures = [
'服务器管理',
'服务器导入导出',
'服务器分组',
'凭据管理',
'脚本库',
'批量连接',
'批量指令',
'通知方式(有限制)',
]
// Plus
const plusFeatures = [
'包含基础版全部功能',
'服务器跳板机功能,支持任意数量服务器的连续跳板',
'批量修改实例配置(优化版)',
'脚本库批量导出导入',
'凭据管理支持解密带密码保护的密钥',
'通知方式无限制',
'本地socket断开自动重连',
'功能需求更高开发优先级',
]
</script>
<style scoped lang="scss">
.comparison-container {
display: flex;
gap: 20px;
padding-bottom: 20px;
max-width: 1200px;
}
.comparison-card {
flex: 1;
min-width: 300px;
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
}
.title {
font-size: 18px;
font-weight: bold;
margin-right: 10px;
}
.link {
text-decoration: underline;
}
.feature-list {
// padding: 10px 0;
line-height: 1.3;
}
.feature-item {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 0;
/* border-bottom: 1px solid #eee; */
border-bottom: 1px solid var(--el-border-color);
}
.feature-item:last-child {
border-bottom: none;
}
.feature-item .el-icon {
color: #409EFF;
}
.plus-card .feature-item.plus {
color: #67c23a;
}
.about_content {
h1 {
font-size: 24px;
font-weight: 600;
margin: 20px 0;
}
p {
line-height: 1.8;
margin: 12px 0;
font-size: 14px;
}
.link {
color: #409EFF;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.conspicuous {
color: #F56C6C;
font-weight: 500;
}
.about_footer {
display: flex;
justify-content: center;
margin-top: 20px;
}
}
/* 响应式设计 */
@media (max-width: 768px) {
.comparison-container {
flex-direction: column;
}
.comparison-card {
width: 100%;
}
}
</style>

View File

@ -20,7 +20,7 @@
link
@click="visible = true"
>
版本更新 <span class="new_version">{{ isNew ? `(新版本可用)` : '' }}</span>
关于 <span class="new_version">{{ isNew ? `(新版本可用)` : '' }}</span>
</el-button>
<el-dropdown trigger="click">
<span class="username_wrap">
@ -37,34 +37,100 @@
</el-dropdown-menu>
</template>
</el-dropdown>
<div class="plus_icon_wrapper" @click="gotoPlusPage">
<el-popover placement="left" :width="320" trigger="hover">
<template #reference>
<img
class="plus_icon"
src="@/assets/plus.png"
alt="PLUS"
:style="{ filter: isPlusActive ? 'grayscale(0%)' : 'grayscale(100%)' }"
>
<img
v-if="!isPlusActive && discount"
class="discount_badge"
src="@/assets/discount.png"
alt="Discount"
>
</template>
<template #default>
<div class="plus_content_wrap">
<!-- Plus 激活状态信息 -->
<div v-if="isPlusActive" class="plus_status">
<div class="status_header">
<el-icon>
<CircleCheckFilled />
</el-icon>
<span>Plus专属功能已激活</span>
</div>
<div class="status_info">
<div class="info_item">
<span class="label">到期时间:</span>
<span class="value holder">{{ plusInfo.expiryDate }}</span>
</div>
<div class="info_item">
<span class="label">授权IP数:</span>
<span class="value">{{ plusInfo.maxIPs }}</span>
</div>
<div class="info_item">
<span class="label">已授权IP数:</span>
<span class="value">{{ plusInfo.usedIPCount }}</span>
</div>
<div class="info_item ip_list">
<span class="label">已授权IP:</span>
<div class="ip_tags">
<el-tag
v-for="ip in plusInfo.usedIPs"
:key="ip"
size="small"
class="ip_tag"
>
{{ ip }}
</el-tag>
</div>
</div>
</div>
</div>
<div class="plus_benefits" :class="{ active: isPlusActive }" @click="handlePlus">
<span v-if="!isPlusActive" class="support_btn" @click="handlePlusSupport">去支持</span>
<div class="benefits_header">
<el-icon>
<el-icon><StarFilled /></el-icon>
</el-icon>
<span>Plus功能介绍</span>
</div>
<div class="current_benefits">
<div v-for="plusFeature in plusFeatures" :key="plusFeature" class="benefit_item">
<el-icon>
<Star />
</el-icon>
<span>{{ plusFeature }}</span>
</div>
</div>
<div class="coming_soon">
<div class="soon_header">开发中的PLUS功能</div>
<div class="current_benefits">
<div v-for="soonFeature in soonFeatures" :key="soonFeature" class="benefit_item">
<el-icon>
<Star />
</el-icon>
<span>{{ soonFeature }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
</el-popover>
</div>
<el-dialog
v-model="visible"
title="版本更新"
top="20vh"
title="关于"
top="10vh"
width="30%"
:append-to-body="false"
:close-on-click-modal="false"
>
<div class="about_content">
<!-- <h1>EasyNode</h1> -->
<h1>EasyNode</h1>
<p>当前版本: {{ currentVersion }} <span v-show="!isNew">(最新)</span> </p>
<p v-if="checkVersionErr" class="conspicuous">Error版本更新检测失败(版本检测API需要外网环境),请手动访问GitHub查看</p>
<p v-if="checkVersionErr" class="conspicuous">Error版本更新检测失败(版本检测API需要外网环境)</p>
<p v-if="isNew" class="conspicuous">
新版本可用: {{ latestVersion }} -> <a
class="link"
@ -73,17 +139,28 @@
>https://github.com/chaos-zhu/easynode/releases</a>
</p>
<p>
功能更新日志<a
更新日志<a
class="link"
href="https://github.com/chaos-zhu/easynode/blob/main/CHANGELOG.md"
target="_blank"
>https://github.com/chaos-zhu/easynode/blob/main/CHANGELOG.md</a>
</p>
<p>
TG更新通知频道<a class="link" href="https://t.me/easynode_notify" target="_blank">https://t.me/easynode_notify</a>
tg更新通知<a class="link" href="https://t.me/easynode_notify" target="_blank">https://t.me/easynode_notify</a>
</p>
<div class="about_footer">
<el-button type="info" @click="visible = false">关闭</el-button>
<p style="line-height: 2;letter-spacing: 1px;">
<strong style="color: #F56C6C;font-weight: 600;">PLUS说明:</strong><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>EasyNode</strong>最初是一个简单的Web终端工具随着用户群的不断扩大功能需求也日益增长为了实现大家的功能需求我投入了大量的业余时间进行开发和维护
一直在为爱发电渐渐的也没了开发的动力
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;为了项目的可持续发展<strong>3.0.0</strong>版本开始推出了<strong>PLUS</strong>版本具体特性鼠标悬浮右上角PLUS图标查看后续特性功能开发也会优先在<strong>PLUS</strong>版本中实现但即使不升级到<strong>PLUS</strong>也不会影响到<strong>EasyNode</strong>的基础功能使用注意: 暂不支持纯内网用户激活PLUS功能
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="text-decoration: underline;">
为了感谢前期赞赏过的用户, <strong>PLUS</strong>功能正式发布前所有进行过赞赏的用户无论金额大小均可联系作者TG: <a class="link" href="https://t.me/chaoszhu" target="_blank">@chaoszhu</a> 凭打赏记录获取永久<strong>PLUS</strong>授权码
</span>
</p>
<div v-if="!isPlusActive" class="about_footer">
<el-button type="primary" @click="handlePlusSupport">去支持</el-button>
</div>
</div>
</el-dialog>
@ -104,24 +181,36 @@
</template>
<script setup>
import { ref, getCurrentInstance, computed, onMounted, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import { User, Sunny, Moon, Fold } from '@element-plus/icons-vue'
import { ref, getCurrentInstance, computed } from 'vue'
import { User, Sunny, Moon, Fold, CircleCheckFilled, Star, StarFilled } from '@element-plus/icons-vue'
import packageJson from '../../package.json'
import MenuList from './menuList.vue'
const { proxy: { $router, $store, $api, $message } } = getCurrentInstance()
const router = useRouter()
const { proxy: { $router, $store, $message } } = getCurrentInstance()
const visible = ref(false)
const checkVersionErr = ref(false)
const currentVersion = ref(`v${ packageJson.version }`)
const latestVersion = ref(null)
const menuCollapse = ref(false)
const discount = ref(false)
const plusFeatures = [
'跳板机功能,拯救被墙实例与龟速终端输入',
'本地socket断开自动重连,无需手动重新连接',
'脚本库批量导出导入',
'凭据管理支持解密带密码保护的密钥',
'提出的功能需求享有更高的开发优先级',
]
const soonFeatures = [
'终端脚本变量及终端脚本输入优化',
'终端分屏功能',
'系统操作日志审计',
]
const isNew = computed(() => latestVersion.value && latestVersion.value !== currentVersion.value)
const user = computed(() => $store.user)
const title = computed(() => $store.title)
const plusInfo = computed(() => $store.plusInfo)
const isPlusActive = computed(() => $store.isPlusActive)
const isDark = computed({
@ -141,8 +230,8 @@ const handleLogout = () => {
$router.push('/login')
}
const gotoPlusPage = () => {
router.push('/setting?tabKey=plus')
const handlePlusSupport = () => {
window.open('https://en.221022.xyz/buy-plus', '_blank')
}
async function checkLatestVersion() {
@ -178,32 +267,6 @@ async function checkLatestVersion() {
checkLatestVersion()
let timer = null
const checkFirstVisit = () => {
timer = setTimeout(() => {
const visitedVersion = localStorage.getItem('visitedVersion')
if (!visitedVersion || visitedVersion !== currentVersion.value) {
visible.value = true
localStorage.setItem('visitedVersion', currentVersion.value)
}
}, 1500)
}
const getPlusDiscount = async () => {
const { data } = await $api.getPlusDiscount()
if (data?.discount) {
discount.value = data.discount
}
}
onMounted(() => {
checkFirstVisit()
getPlusDiscount()
})
onBeforeUnmount(() => {
clearTimeout(timer)
})
</script>
<style lang="scss" scoped>
@ -250,26 +313,10 @@ onBeforeUnmount(() => {
}
}
.plus_icon_wrapper {
margin-left: 15px;
display: flex;
align-items: center;
cursor: pointer;
.plus_icon {
margin-left: 15px;
width: 35px;
margin-right: 5px;
}
.discount_badge {
width: 22px;
color: white;
font-size: 12px;
transform: rotate(25deg);
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
animation: pulse 2s infinite;
}
cursor: pointer;
}
}
@ -306,18 +353,6 @@ onBeforeUnmount(() => {
text-align: center;
}
}
@keyframes pulse {
0% {
transform: rotate(25deg) scale(1);
}
50% {
transform: rotate(25deg) scale(1.1);
}
100% {
transform: rotate(25deg) scale(1);
}
}
</style>
<style lang="scss">
@ -424,19 +459,5 @@ onBeforeUnmount(() => {
}
}
}
.discount_content {
margin: 8px 0;
.el-tag {
display: flex;
align-items: center;
padding: 6px 12px;
.el-icon {
margin-right: 4px;
}
}
}
}
</style>

View File

@ -101,7 +101,7 @@ const useStore = defineStore({
this.$patch({ localScriptList })
},
async getPlusInfo() {
const { data: plusInfo = {} } = await $api.getPlusInfo()
const { data: plusInfo } = await $api.getPlusInfo()
if (plusInfo?.expiryDate) {
const isPlusActive = new Date(plusInfo.expiryDate) > new Date()
this.$patch({ isPlusActive })
@ -111,9 +111,6 @@ const useStore = defineStore({
}
plusInfo.expiryDate = dayjs(plusInfo.expiryDate).format('YYYY-MM-DD')
plusInfo.expiryDate?.startsWith('9999') && (plusInfo.expiryDate = '永久授权')
this.$patch({ plusInfo })
} else {
this.$patch({ isPlusActive: false })
}
this.$patch({ plusInfo })
},

View File

@ -149,7 +149,3 @@ export const isMobile = () => {
let userAgent = navigator.userAgent || navigator.vendor || window.opera
return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent)
}
export const handlePlusSupport = () => {
window.open('https://en.221022.xyz/buy-plus', '_blank')
}

View File

@ -46,7 +46,7 @@
</el-form-item>
<el-form-item prop="mfa2Token" label="MFA2验证码">
<el-input
v-model="loginForm.mfa2Token"
v-model.trim.number="loginForm.mfa2Token"
type="text"
placeholder="MFA2应用上的6位数字(未设置可忽略)"
autocomplete="off"
@ -103,7 +103,7 @@ const loginForm = reactive({
const rules = reactive({
loginName: { required: true, message: '需输入用户名', trigger: 'change' },
pwd: { required: true, message: '需输入密码', trigger: 'change' },
mfa2Token: { required: false, message: '需输入MFA2验证码', trigger: 'change' }
mfa2Token: { required: false, message: '需输入码', trigger: 'change' }
})
const handleLogin = () => {
@ -124,7 +124,7 @@ const handleLogin = () => {
if (ciphertext === -1) return $message.error({ message: '公钥加载失败', center: true })
loading.value = true
try {
let { data, msg } = await $api.login({ loginName, ciphertext, jwtExpires, mfa2Token: Number(mfa2Token) })
let { data, msg } = await $api.login({ loginName, ciphertext, jwtExpires, mfa2Token })
const { token } = data
$store.setJwtToken(token, expireEnum.ONE_SESSION === expireTime.value)
$store.setUser(loginName)

View File

@ -426,7 +426,7 @@ onActivated(async () => {
const { hostIds, execClientInstallScript } = route.query
if (!hostIds) return
if (execClientInstallScript === 'true') {
let clientInstallScript = 'curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash\n'
let clientInstallScript = 'curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash\n'
console.log(hostIds.split(','))
createExecShell(hostIds.split(','), clientInstallScript, 300)
// $messageBox.confirm(`${ host }`, 'Warning', {
@ -435,7 +435,7 @@ onActivated(async () => {
// type: 'warning'
// })
// .then(async () => {
// let clientInstallScript = 'curl -o- https://git.221022.xyz/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash\n'
// let clientInstallScript = 'curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash\n'
// createExecShell([host,], clientInstallScript, 300)
// })
}

View File

@ -196,7 +196,6 @@ const isPlusActive = computed(() => $store.isPlusActive)
let addScript = () => {
formData.id = null
formData.index = scriptList.value.reduce((acc, cur) => Math.max(acc, Number(cur.index) || 0), 0) + 1
isModify.value = false
formVisible.value = true
}

View File

@ -30,6 +30,7 @@
label-width="100px"
:show-message="false"
>
<transition-group name="list" mode="out-in" tag="div">
<el-form-item key="group" label="分组" prop="group">
<el-select
v-model="hostForm.group"
@ -113,12 +114,14 @@
<el-button type="primary" size="small" @click="handleClickUploadBtn">
本地私钥...
</el-button>
<!-- <el-button type="primary" size="small" @click="handleClickUploadBtn">
从凭据导入...
</el-button> -->
<input
ref="privateKeyRef"
type="file"
name="privateKey"
style="display: none;"
autocomplete="off"
@change="handleSelectPrivateKeyFile"
>
<el-input
@ -141,7 +144,7 @@
v-model.trim="hostForm.password"
type="password"
placeholder=""
autocomplete="new-password"
autocomplete="off"
clearable
show-password
/>
@ -277,14 +280,12 @@
placeholder="简单记录实例用途"
/>
</el-form-item>
</transition-group>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">关闭</el-button>
<el-button v-if="!isBatchModify" type="primary" @click="handleSave">确认</el-button>
<PlusSupportTip v-else>
<el-button type="primary" :disabled="!isPlusActive" @click="handleSave">确认</el-button>
</PlusSupportTip>
<el-button type="primary" @click="handleSave">确认</el-button>
</span>
</template>
</el-dialog>
@ -326,7 +327,7 @@ const formField = {
host: '',
port: 22,
username: 'root',
authType: 'privateKey', // privateKey, password, credential
authType: 'privateKey',
password: '',
privateKey: '',
credential: '', // credentials -> _id
@ -342,6 +343,7 @@ const formField = {
let hostForm = ref({ ...formField })
let privateKeyRef = ref(null)
let oldHost = ref('')
let formRef = ref(null)
let isBatchModify = computed(() => props.isBatchModify)
@ -385,11 +387,9 @@ let confHostList = computed(() => {
const setDefaultData = () => {
if (!defaultData.value) return
// eslint-disable-next-line no-unused-vars
let { id, ...rest } = defaultData.value
for (let [key,] of Object.entries(hostForm.value)) {
if (rest[key] !== undefined) hostForm.value[key] = rest[key]
}
hostForm.value.id = id
let { host, monitorData, ...rest } = defaultData.value
oldHost.value = host
Object.assign(hostForm.value, { host, ...rest })
}
const setBatchDefaultData = () => {
@ -397,18 +397,15 @@ const setBatchDefaultData = () => {
Object.assign(hostForm.value, { ...formField }, { group: '', port: '', username: '', authType: '', clientPort: '', jumpHosts: [] })
}
const handleOpen = async () => {
if (isBatchModify.value) {
setBatchDefaultData()
} else {
setDefaultData()
}
setBatchDefaultData()
await nextTick()
formRef.value.clearValidate()
}
const handleClosed = async () => {
emit('closed')
hostForm.value = { ...formField }
Object.assign(hostForm.value, { ...formField })
await nextTick()
formRef.value.resetFields()
}
@ -455,39 +452,30 @@ const handleSave = () => {
let formData = { ...hostForm.value }
if (isBatchModify.value) {
// eslint-disable-next-line
let updateFieldData = Object.fromEntries(Object.entries(formData).filter(([key, value]) => {
if (Array.isArray(value)) return value.length > 0
return Boolean(value)
})) //
let { authType = '' } = updateFieldData
if (authType && !updateFieldData[authType]) {
delete updateFieldData.authType
delete updateFieldData.privateKey
delete updateFieldData.password
delete updateFieldData.credential
}
if (Object.keys(updateFieldData).length === 0) return $message.warning('没有任何修改')
console.log(updateFieldData)
if (updateFieldData.authType) {
let updateFileData = Object.fromEntries(Object.entries(formData).filter(([key, value]) => Boolean(value))) //
if (Object.keys(updateFileData).length === 0) return $message.warning('没有任何修改')
console.log(updateFileData)
let newHosts = batchHosts.value
.map(item => ({ ...item, ...updateFileData }))
.map(item => {
const { authType } = item
let tempKey = randomStr(16)
updateFieldData[authType] = AESEncrypt(updateFieldData[authType], tempKey)
updateFieldData.tempKey = RSAEncrypt(tempKey)
}
let updateIds = batchHosts.value.map(item => item.id)
let { msg } = await $api.batchUpdateHost({ updateIds, updateFieldData })
if (item[authType]) item[authType] = AESEncrypt(item[authType], tempKey)
item.tempKey = RSAEncrypt(tempKey)
return item
})
let { msg } = await $api.updateHost({ hosts: newHosts })
$message({ type: 'success', center: true, message: msg })
} else {
let tempKey = randomStr(16)
let { authType } = formData
if (formData[authType]) {
let tempKey = randomStr(16)
formData[authType] = AESEncrypt(formData[authType], tempKey)
if (formData[authType]) formData[authType] = AESEncrypt(formData[authType], tempKey)
formData.tempKey = RSAEncrypt(tempKey)
}
if (defaultData.value) {
let { msg } = await $api.updateHost({ ...formData })
let { msg } = await $api.updateHost(Object.assign({}, formData, { oldHost: oldHost.value }))
$message({ type: 'success', center: true, message: msg })
} else {
let { msg } = await $api.addHost({ ...formData })
let { msg } = await $api.addHost(formData)
$message({ type: 'success', center: true, message: msg })
}
}

View File

@ -69,45 +69,20 @@
/>
</el-form-item>
</template>
<!-- Telegram -->
<template v-if="noticeConfig.type === 'tg'">
<el-form-item label="Token" prop="tg.token" class="form_item">
<el-input
v-model.trim="noticeConfig.tg.token"
clearable
placeholder="Telegram Token"
autocomplete="off"
class="input"
/>
</el-form-item>
<el-form-item label="ChatId" prop="tg.chatId" class="form_item">
<el-input
v-model="noticeConfig.tg.chatId"
clearable
placeholder="Telegram ChatId"
autocomplete="off"
class="input"
/>
<span class="tips">Telegram Token/ChatId 获取: <a class="link" href="https://easynode.chaoszhu.com/zh/guide/get-tg-token" target="_blank">查看教程</a> </span>
</el-form-item>
</template>
<el-form-item label="" class="form_item">
<el-button
type="primary"
:loading="loading"
@click="handleSave"
>
<el-button type="primary" :loading="loading" @click="handleSave">
测试并保存
</el-button>
<!-- <el-tooltip effect="dark" content="重复添加的邮箱将会被覆盖" placement="right">
</el-tooltip> -->
</el-form-item>
</el-form>
</template>
<script setup>
import { ref, reactive, onMounted, getCurrentInstance, computed } from 'vue'
// import PlusSupportTip from '@/components/common/PlusSupportTip.vue'
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
const { proxy: { $api, $notification, $store } } = getCurrentInstance()
const { proxy: { $api, $notification } } = getCurrentInstance()
const loading = ref(false)
const noticeConfig = ref({})
@ -120,28 +95,14 @@ const noticeTypeList = ref([
type: 'sct',
desc: 'Server酱'
},
{
type: 'tg',
desc: 'Telegram'
},
])
const formRef = ref(null)
const isPlusActive = computed(() => $store.isPlusActive)
const rules = reactive({
'sct.sendKey': { required: true, message: '需输入sendKey', trigger: 'change' },
'email.service': { required: true, message: '需输入邮箱提供商', trigger: 'change' },
'email.user': { required: true, type: 'email', message: '需输入邮箱', trigger: 'change' },
'email.pass': { required: true, message: '需输入邮箱SMTP授权码', trigger: 'change' },
'tg.token': { required: true, message: '需输入Telegram Token', trigger: 'change' },
'tg.chatId': [
{ required: true, message: '需输入Telegram ChatId', trigger: 'change' },
{
pattern: /^-?\d+$/,
message: 'ChatId必须为数字',
trigger: ['blur', 'change',]
},
]
'email.pass': { required: true, message: '需输入邮箱SMTP授权码', trigger: 'change' }
})
const handleSave = () => {

View File

@ -1,234 +0,0 @@
<template>
<el-form
ref="formRef"
class="plus-form"
:model="formData"
:rules="rules"
:hide-required-asterisk="true"
label-suffix=""
label-width="86px"
:show-message="false"
@submit.prevent
>
<el-form-item label="Plus Key" prop="key" class="form_item">
<el-input
v-model.trim="formData.key"
clearable
placeholder=""
autocomplete="off"
class="input"
@keyup.enter.prevent="handleUpdate"
/>
</el-form-item>
<el-form-item>
<div class="form_footer">
<el-button type="primary" :loading="loading" @click="handleUpdate">立即激活</el-button>
<el-button type="success" @click="handlePlusSupport">
购买Plus
<el-icon class="el-icon--right"><TopRight /></el-icon>
</el-button>
<span v-if="!isPlusActive && discount" class="discount_wrapper" @click="handlePlusSupport">
<img
class="discount_badge"
src="@/assets/discount.png"
alt="Discount"
>
<span class="discount_content">{{ discountContent }}</span>
</span>
</div>
</el-form-item>
</el-form>
<!-- Plus 激活状态信息 -->
<div v-if="isPlusActive" class="plus_status">
<div class="status_header">
<span>Plus专属功能已激活</span>
</div>
<div class="status_info">
<div class="info_item">
<span class="label">到期时间:</span>
<span class="value holder">{{ plusInfo.expiryDate }}</span>
</div>
<div class="info_item">
<span class="label">授权IP数:</span>
<span class="value">{{ plusInfo.maxIPs }}</span>
</div>
<div class="info_item">
<span class="label">已授权IP数:</span>
<span class="value">{{ plusInfo.usedIPCount }}</span>
</div>
<div class="info_item ip_list">
<span class="label">已授权IP:</span>
<div class="ip_tags">
<el-tag
v-for="ip in plusInfo.usedIPs"
:key="ip"
size="small"
class="ip_tag"
>
{{ ip }}
</el-tag>
</div>
</div>
</div>
</div>
<PlusTable />
</template>
<script setup>
import { ref, reactive, onMounted, getCurrentInstance, computed } from 'vue'
import { ElMessageBox } from 'element-plus'
import { TopRight } from '@element-plus/icons-vue'
import { handlePlusSupport } from '@/utils'
import PlusTable from '@/components/plus-table.vue'
const { proxy: { $api, $message, $store } } = getCurrentInstance()
const errCount = ref(Number(localStorage.getItem('plusErrCount') || 0))
const loading = ref(false)
const formRef = ref(null)
const formData = reactive({
key: ''
})
const rules = reactive({
key: { required: true, message: '输入Plus Key', trigger: 'change' }
})
const discount = ref(false)
const discountContent = ref('')
const plusInfo = computed(() => $store.plusInfo)
const isPlusActive = computed(() => $store.isPlusActive)
const handleUpdate = () => {
formRef.value.validate()
.then(async () => {
try {
loading.value = true
let { key } = formData
await $api.updatePlusKey({ key })
$message({ type: 'success', center: true, message: '激活成功,感谢支持' })
localStorage.setItem('plusErrCount', 0)
} catch (error) {
localStorage.setItem('plusErrCount', ++errCount.value)
if (errCount.value > 3) {
ElMessageBox.confirm(
'激活失败请确认key正确(20位不规则字符串)有疑问请tg联系@chaoszhu。',
'Warning',
{
showCancelButton : false,
confirmButtonText: '确认',
type: 'warning'
}
)
}
}
})
.finally(() => {
loading.value = false
$store.getPlusInfo()
})
}
const getPlusConf = async () => {
try {
loading.value = true
let { data } = await $api.getPlusConf()
formData.key = data
} catch (error) {
$message({ type: 'error', center: true, message: error.message })
} finally {
loading.value = false
}
}
const getPlusDiscount = async () => {
const { data } = await $api.getPlusDiscount()
if (data?.discount) {
discount.value = data.discount
discountContent.value = data.content
}
}
onMounted(() => {
getPlusConf()
getPlusDiscount()
})
</script>
<style lang="scss" scoped>
.form_item {
.input {
width: 450px;
}
}
.form_footer {
height: 100%;
display: flex;
align-items: center;
justify-content: start;
margin-bottom: 15px;
.discount_wrapper {
height: 100%;
display: flex;
align-items: center;
cursor: pointer;
.discount_badge {
margin: 0 5px 0 10px;
width: 22px;
color: white;
font-size: 12px;
}
.discount_content {
font-size: 12px;
line-height: 1.3;
color: #ff4806;
text-decoration: underline;
}
}
}
.plus_status {
margin-bottom: 15px;
.status_header {
display: flex;
align-items: center;
color: #67c23a;
margin-bottom: 10px;
.el-icon {
margin-right: 5px;
}
}
.status_info {
.info_item {
display: flex;
margin: 5px 0;
font-size: 13px;
.label {
color: #909399;
width: 80px;
}
.holder {
color: #EED183;
}
&.ip_list {
flex-direction: column;
.ip_tags {
margin-top: 5px;
.ip_tag {
margin: 2px;
}
}
}
}
}
}
</style>

View File

@ -9,16 +9,15 @@
label-width="86px"
:show-message="false"
>
<el-form-item label="原用户名" prop="oldLoginName" class="form_item">
<el-form-item label="原用户名" prop="oldLoginName">
<el-input
v-model.trim="formData.oldLoginName"
clearable
placeholder=""
autocomplete="off"
class="input"
/>
</el-form-item>
<el-form-item label="原密码" prop="oldPwd" class="form_item">
<el-form-item label="原密码" prop="oldPwd">
<el-input
v-model.trim="formData.oldPwd"
type="password"
@ -26,19 +25,17 @@
show-password
placeholder=""
autocomplete="off"
class="input"
/>
</el-form-item>
<el-form-item label="新用户名" prop="newLoginName" class="form_item">
<el-form-item label="新用户名" prop="newLoginName">
<el-input
v-model.trim="formData.newLoginName"
clearable
placeholder=""
autocomplete="off"
class="input"
/>
</el-form-item>
<el-form-item label="新密码" prop="newPwd" class="form_item">
<el-form-item label="新密码" prop="newPwd">
<el-input
v-model.trim="formData.newPwd"
type="password"
@ -46,7 +43,6 @@
clearable
placeholder=""
autocomplete="off"
class="input"
@keyup.enter="handleUpdate"
/>
</el-form-item>
@ -163,11 +159,7 @@ onMounted(() => {
<style lang="scss" scoped>
.password-form {
.form_item {
.input {
width: 450px;
}
}
width: 500px;
}
.mfa2_title {
font-size: 18px;

View File

@ -1,56 +1,33 @@
<template>
<div class="setting_container">
<el-tabs v-model="tabKey" tab-position="top">
<el-tab-pane label="修改密码" name="user">
<el-tabs tab-position="top">
<el-tab-pane label="修改密码" lazy>
<User />
</el-tab-pane>
<el-tab-pane label="登录日志" name="record" lazy>
<el-tab-pane label="登录日志">
<Record />
</el-tab-pane>
<el-tab-pane label="全局通知" name="notify">
<el-tab-pane label="全局通知" lazy>
<GlobalNotify />
</el-tab-pane>
<el-tab-pane label="通知配置" name="notify-config">
<el-tab-pane label="通知配置" lazy>
<NotifyConfig />
</el-tab-pane>
<el-tab-pane label="Plus激活" name="plus">
<UserPlus />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script setup>
import { watch, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import GlobalNotify from './components/global-notify.vue'
// import EmailList from './components/email-list.vue'
import Record from './components/record.vue'
import User from './components/user.vue'
import NotifyConfig from './components/notify-config.vue'
import UserPlus from './components/user-plus.vue'
const route = useRoute()
const router = useRouter()
const tabKey = computed({
get() {
return route.query.tabKey || 'user'
},
set(newVal) {
router.push({ query: { tabKey: newVal } })
}
})
watch(() => tabKey.value, (newVal) => {
router.push({ query: { tabKey: newVal } })
})
</script>
<style lang="scss" scoped>
.setting_container {
height: 100%;
padding: 20px;
overflow: auto;
}
</style>

View File

@ -168,7 +168,7 @@ import unknowIcon from '@/assets/image/system/unknow.png'
const { io } = socketIo
const props = defineProps({
hostId: {
host: {
required: true,
type: String
}
@ -270,7 +270,7 @@ const connectSftp = () => {
socket.value.on('connect', () => {
console.log('/sftp socket已连接', socket.value.id)
listenSftp()
socket.value.emit('create', { hostId: props.hostId, token: token.value })
socket.value.emit('create', { host: props.host, token: token.value })
socket.value.on('root_ls', (tree) => {
let temp = sortDirTree(tree).filter((item) => isDir(item.type))
temp.unshift({ name: '/', type: 'd' })

View File

@ -190,8 +190,8 @@ const connectIO = () => {
case 'io server disconnect':
reconnectTerminal(true, '服务端主动断开连接')
break
case 'io client disconnect': //
break
// case 'io client disconnect': //
// break
case 'transport close':
reconnectTerminal(true, '本地网络连接异常')
break
@ -208,10 +208,9 @@ const connectIO = () => {
socket.value.on('connect_error', (err) => {
console.error('EasyNode服务端连接错误', err)
curStatus.value = CONNECT_FAIL
term.value.write('\r\n\x1b[91mError: 连接失败,请检查EasyNode服务端是否正常, 回车重新发起连接\x1b[0m \r\n')
term.value.write('\r\n\x1b[91mError: 连接失败,请检查EasyNode服务端是否正常\x1b[0m \r\n')
$notification({
title: '服务端连接失败',
title: '连接失败',
message: '请检查EasyNode服务端是否正常',
type: 'error'
})
@ -222,6 +221,7 @@ const reconnectTerminal = (isCommonTips = false, tips) => {
socket.value.removeAllListeners()
socket.value.close()
socket.value = null
curStatus.value = CONNECT_FAIL
socketConnected.value = false
if (isCommonTips) {
if (isPlusActive.value && autoReconnect.value) {
@ -353,11 +353,12 @@ function extractLastCdPath(text) {
const onData = () => {
term.value.onData((key) => {
if (!socket.value || !socketConnected.value) return
if ('\r' === key && curStatus.value === CONNECT_FAIL) {
reconnectTerminal(false, '重新连接中...')
return
}
if (!socket.value || !socketConnected.value) return
if (isLongPressCtrl.value || isLongPressAlt.value) {
const keyCode = key.toUpperCase().charCodeAt(0)

View File

@ -167,7 +167,7 @@
<Sftp
v-if="showSftp"
ref="sftpRefs"
:host-id="item.id"
:host="item.host"
@resize="resizeTerminal"
/>
</div>

1029
yarn.lock

File diff suppressed because it is too large Load Diff