Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitattributes

This file was deleted.

26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## 🎉 v0.3.0-alpha.1 (2026-02-13)

### ♻️ Refactor

- **pick**: 迁移样式从 SCSS 到 Tailwind CSS
- **slide**: 迁移样式,从 SCSS 到 Tailwind
- **lansend**: 样式从 SCSS 迁移到 Tailwind CSS

### ✨ Features

- **cli**: 初始化默认配置文件
- **lansend**: 重构上传功能并集成到文件列表
- **get**: 新增资源获取命令,支持下载和打开官网
- **cmd**: 添加危险命令执行前的检测和确认机制
- **cmd**: 新增可复用命令管理能力
- **alias**: 改进别名添加和显示功能
- **alias**: 支持为多级命令新建别名

### 🐛 Bug Fixes

- **socket**: 去除前端构建的警告

### 🔧 Chores

- 更新 commitizen 配置和笔记文档

## 🎉 v0.2.2 (2026-01-25)

### ✨ Features
Expand Down
103 changes: 103 additions & 0 deletions docs/LANSend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
## LANSend 子命令

LANSend 用于在局域网内快速共享本地目录,通过浏览器即可浏览、预览、下载文件,并可选开启上传、聊天室和网速测试等功能。

### 基本功能
- 在指定目录上启动一个局域网 Web 文件服务
- 自动列出目录树、预览文本/图片/视频等常见文件
- 支持文件下载(可在前端隐藏下载按钮)
- 可选开启文件上传(支持上传密码)
- 内置简单聊天室功能(可选)
- 内置上传/下载测速接口,方便测试局域网带宽

### 基本用法
```bash
fcbyk lansend [选项]
```

启动后,命令会:
- 检查共享目录是否存在且为目录
- 检查端口是否可用
- 输出当前共享目录与可访问的局域网地址列表
- 自动将其中一个访问地址复制到剪贴板
- 默认自动在浏览器中打开访问页面(可通过参数关闭)

### 参数说明
- `-p, --port INTEGER`
指定 Web 服务端口,默认 `80`。
例如:`-p 8080`

- `-d, --directory PATH`
指定要共享的本地目录,默认当前目录 `.`。
该目录及其子目录中的内容会被前端页面列出与访问。
例如:`-d D:\ShareFolder`

- `-ap, --ask-password`
是否为上传功能设置密码。
- 仅在未禁用上传(即没有使用 `--disable-upload`)时生效
- 启动时会在命令行中交互式询问上传密码
- 直接回车会使用默认密码 `123456`
- 设置后,上传接口会强制校验上传密码

- `-nb, --no-browser`
禁止自动在本机浏览器中打开页面。
使用该参数时,只会在命令行中打印访问 URL,并复制到剪贴板。

- `-nd, --hide-download`
在前端目录页面中隐藏“下载”按钮。
适用于只允许预览、不希望用户便捷下载文件的场景。
注意:底层下载接口仍然存在,主要是前端 UI 级的限制,适合配合受信任用户使用。

- `-nu, --disable-upload`
禁用上传功能。
- 所有上传相关接口不会被注册
- 前端页面不会显示上传入口
适用于只读共享场景,推荐在无需接收文件时开启。

- `--chat`
启用局域网聊天室功能,主要用于在局域网内快速共享文本信息(如链接、命令、临时说明等)。
打开后,前端会显示一个简单的聊天面板,所有连接到该 LANSend 服务的用户都可以通过该面板收发消息,消息只保存在内存中,重启后会清空。

### 常见用法示例

1. 在当前目录启动默认服务(端口 80,自动打开浏览器)
```bash
fcbyk lansend
```

2. 指定端口和目录共享
```bash
fcbyk lansend -p 8080 -d D:\ShareFolder
```

3. 开启上传并设置上传密码
```bash
fcbyk lansend -p 8080 -d D:\ShareFolder -ap
```
启动后会提示输入密码,若直接回车则使用 `123456`。

4. 只读共享目录(禁用上传)
```bash
fcbyk lansend -p 8080 -d D:\ShareFolder --disable-upload
```

5. 只允许在线预览,不鼓励下载
```bash
fcbyk lansend -p 8080 -d D:\ShareFolder --hide-download
```

6. 启用聊天室功能
```bash
fcbyk lansend -p 8080 -d D:\ShareFolder --chat
```

7. 在服务器上启动但不自动打开浏览器
```bash
fcbyk lansend -p 8080 -d /data/share --no-browser
```

### 注意事项
- 请确保共享目录中不包含敏感文件,局域网内任何可以访问该服务的设备都可能浏览到这些文件。
- 如果需要一定的访问控制,建议至少开启上传密码,并搭配只读或隐藏下载按钮等选项使用。
- LANSend 仅面向局域网场景设计,不推荐直接暴露到公网环境。

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ addopts = "-v --cov=fcbyk --cov-report=term-missing"

[tool.commitizen]
name = "cz_customize"
version = "0.2.2"
version = "0.3.0a1"
tag_format = "v$version"
changelog_file = "CHANGELOG.md"
bump_message = "🎉 release: v$new_version"
Expand Down
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = fcbyk-cli
version = 0.2.2
version = 0.3.0a1
description = A CLI tool for fcbyk
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -61,7 +61,9 @@ exclude =

[options.entry_points]
console_scripts =
fcbyk = fcbyk.cli:cli
fcbyk = fcbyk.cli:main
byk = fcbyk.cli:main


[options.package_data]
fcbyk =
Expand Down
19 changes: 13 additions & 6 deletions src/fcbyk/cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python3
import click,random

from fcbyk import commands
import click, random, os
from fcbyk import commands, defaults
from fcbyk.utils import storage
from fcbyk.commands.alias import AliasedGroup
from fcbyk.cli_support import (
version_callback,
print_aliases,
print_commands,
add_gui_options,
banner
)
Expand All @@ -28,19 +29,25 @@
)
@add_gui_options
@click.pass_context
def cli(ctx):
def main(ctx):
# 初始化默认配置
config_path = storage.get_path(defaults.CONFIG_FILE)
if not os.path.exists(config_path):
storage.save_json(config_path, defaults.DEFAULT_CONFIG)

if ctx.invoked_subcommand is None:
banner_text = random.choice(banner)

click.secho(banner_text, fg="white", dim=True)
click.echo(ctx.get_help()) # 帮助信息
print_aliases() # 打印别名,如果有
print_commands(leading_newline=False) # 打印已存脚本,如果有


# 注册子命令
for cmd_name in commands.__all__:
cli.add_command(getattr(commands, cmd_name))
main.add_command(getattr(commands, cmd_name))


if __name__ == "__main__":
cli()
main()
8 changes: 6 additions & 2 deletions src/fcbyk/cli_support/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""CLI 支持模块"""

from .callbacks import version_callback, print_aliases
from .callbacks import (
version_callback,
print_aliases,
print_commands
)
from .gui import add_gui_options
from .helpers import banner

__all__ = ['version_callback', 'print_aliases', 'add_gui_options', 'banner']
__all__ = ['version_callback', 'print_aliases', 'add_gui_options', 'banner', 'print_commands']
29 changes: 29 additions & 0 deletions src/fcbyk/cli_support/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,32 @@ def print_aliases(show_empty=False, leading_newline=True):
click.echo("No aliases configured.")
except Exception:
pass


def print_commands(show_empty=False, leading_newline=True):
"""打印已保存的命令脚本列表"""
try:
from fcbyk.commands.cmd.cli import load_commands
commands = load_commands()
if commands:
if leading_newline:
click.echo()
click.echo("Scripts:")
items = list(commands.items())
max_name_len = max(len(str(name)) for name, _ in items)
for name, cmd_data in items:
if isinstance(cmd_data, str):
command = cmd_data
cwd_str = ""
else:
command = cmd_data.get("command", "")
cwd = cmd_data.get("cwd")
cwd_str = f" [CWD: {cwd}]" if cwd else ""

padding = " " * (max_name_len - len(str(name)) + 2)
click.echo(f" {name}{padding}-> {command}{cwd_str}")
click.echo()
elif show_empty:
click.echo("No scripts saved yet.")
except Exception:
pass
4 changes: 3 additions & 1 deletion src/fcbyk/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
from .pick.cli import pick
from .slide.cli import slide
from .alias import alias
from .cmd.cli import cmd
from .get.cli import get

__all__ = ['lansend', 'ai', 'pick', 'slide', 'alias']
__all__ = ['lansend', 'ai', 'pick', 'slide', 'alias', 'cmd', 'get']
3 changes: 3 additions & 0 deletions src/fcbyk/commands/cmd/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .cli import cmd

__all__ = ['cmd']
Loading