Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Build Linux arm64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o tgState main.go
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o tgState main.go

- name: Zip Linux amd64
run: |
Expand Down
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,14 @@ mk.txt
.idea/*
.vscode/*
tmp/*
.air.toml
.vercel
.air.toml
.vercel
/.env
/files.db
/tgState.zip

__debug_bin.exe*

node_modules/

.env
113 changes: 113 additions & 0 deletions FRONTEND_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# TGState 前端重构

使用 Vite + Vue 3 + Shadcn UI 重构的现代化前端界面。

## 功能特性

- 🎨 现代化的UI设计,基于Shadcn UI组件库
- 📱 完全响应式设计,支持移动端
- 🚀 使用Vite构建,开发体验更佳
- ⚡ Vue 3 Composition API,性能更优
- 📤 支持拖拽上传和多文件上传
- 📊 实时上传进度显示
- 🔄 大文件分片上传支持
- 📋 一键复制链接功能
- 🖼️ 图片文件支持HTML和Markdown格式复制

## 开发环境

### 前端开发
```bash
cd frontend
npm install
npm run dev
```

### 后端开发
```bash
go run main.go
```

### 同时启动前后端(Windows)
```bash
dev-frontend.bat
```

## 生产构建

### 构建前端并编译Go程序(Windows)
```bash
build-frontend.bat
```

### 构建前端并编译Go程序(Linux/Mac)
```bash
chmod +x build-frontend.sh
./build-frontend.sh
```

### 手动构建
```bash
# 构建前端
cd frontend
npm install
npm run build
cd ..

# 构建Go程序
go build -o tgstate
```

## 项目结构

```
frontend/
├── src/
│ ├── components/
│ │ ├── ui/ # Shadcn UI组件
│ │ └── FileUpload.vue # 主上传组件
│ ├── lib/
│ │ └── utils.ts # 工具函数
│ ├── services/
│ │ └── api.ts # API服务
│ ├── App.vue # 主应用组件
│ ├── main.ts # 应用入口
│ └── style.css # 全局样式
├── package.json
├── vite.config.ts
├── tailwind.config.js
└── tsconfig.json
```

## 技术栈

- **Vue 3** - 渐进式JavaScript框架
- **TypeScript** - 类型安全的JavaScript
- **Vite** - 下一代前端构建工具
- **Tailwind CSS** - 实用优先的CSS框架
- **Shadcn UI** - 高质量的Vue组件库
- **Axios** - HTTP客户端
- **Lucide Vue** - 图标库

## API兼容性

新前端完全兼容现有的Go后端API:
- `/api` - 文件上传
- `/api/chunk` - 分片上传
- `/api/merge` - 分片合并
- `/d/` - 文件下载
- `/s/` - 短链重定向

## 浏览器支持

- Chrome >= 87
- Firefox >= 78
- Safari >= 14
- Edge >= 88

## 注意事项

1. 构建后的文件会输出到 `assets/dist/` 目录
2. Go程序会优先使用构建后的前端,如果不存在则回退到原始模板
3. 开发时前端运行在3000端口,通过代理访问后端8088端口
4. 生产环境下前端文件会被嵌入到Go二进制文件中
112 changes: 112 additions & 0 deletions GISCUS_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Giscus 评论系统配置指南

Giscus 是基于 GitHub Discussions 的评论系统,功能强大且易于配置。

## 配置步骤

### 1. 准备 GitHub 仓库
- 确保你有一个公开的 GitHub 仓库
- 在仓库设置中启用 Discussions 功能:
- 进入仓库 → Settings → General
- 在 Features 部分勾选 "Discussions"

### 2. 安装 Giscus GitHub App
- 访问 [Giscus GitHub App](https://github.com/apps/giscus)
- 点击 "Install" 安装到你的 GitHub 账户
- 选择要安装的仓库(建议选择 "All repositories" 或选择特定仓库)

### 3. 获取配置参数
- 访问 [giscus.app](https://giscus.app/zh-CN)
- 按照页面指引填写你的仓库信息
- 选择合适的配置选项
- 复制生成的配置参数

### 4. 修改配置文件
编辑 `frontend/src/config/giscus.ts` 文件:

```typescript
export const giscusConfig = {
// 你的 GitHub 仓库
repo: 'your-username/your-repo', // 例如:'octocat/Hello-World'

// 从 giscus.app 获取的仓库 ID
repoId: 'R_kgDOH...',

// Discussion 分类
category: 'General',

// 从 giscus.app 获取的分类 ID
categoryId: 'DIC_kwDOH...',

// 其他配置可根据需要调整
mapping: 'pathname',
strict: false,
reactionsEnabled: true,
emitMetadata: false,
inputPosition: 'top',
theme: 'light',
lang: 'zh-CN',
enabled: true,
}
```

### 5. 主题选项
可选的主题包括:
- `light` - 浅色主题(默认)
- `dark` - 深色主题
- `preferred_color_scheme` - 跟随系统主题
- `transparent_dark` - 透明深色主题
- `dark_dimmed` - 暗淡深色主题
- `dark_high_contrast` - 高对比度深色主题
- `light_high_contrast` - 高对比度浅色主题
- `dark_protanopia` - 深色红绿色盲友好主题
- `light_protanopia` - 浅色红绿色盲友好主题
- `dark_tritanopia` - 深色蓝黄色盲友好主题
- `light_tritanopia` - 浅色蓝黄色盲友好主题

### 6. 页面映射选项
- `pathname` - 使用页面路径作为 discussion 标题(推荐)
- `url` - 使用页面完整 URL 作为 discussion 标题
- `title` - 使用页面标题作为 discussion 标题
- `og:title` - 使用页面 og:title 作为 discussion 标题
- `specific` - 使用特定术语
- `number` - 使用特定 discussion 编号

## Giscus 的优势

1. **基于 Discussions** - 比 Issues 更适合评论讨论
2. **功能丰富** - 支持 reactions、回复、编辑等
3. **无需数据库** - 所有数据存储在 GitHub
4. **SEO 友好** - 评论内容可被搜索引擎索引
5. **多主题支持** - 包括无障碍友好主题
6. **实时更新** - 支持实时评论更新

## 注意事项

1. **仓库必须是公开的** - Giscus 需要访问公开仓库的 Discussions
2. **启用 Discussions 功能** - 确保仓库的 Discussions 功能已启用
3. **GitHub App 权限** - 确保 Giscus App 有权限访问你的仓库
4. **首次加载** - 第一次访问时可能需要几秒钟加载评论系统

## 禁用评论系统

如果不需要评论功能,可以在配置文件中设置:
```typescript
enabled: false
```

## 故障排除

如果评论系统无法正常显示:
1. 检查仓库名称和 ID 是否正确
2. 确认仓库是公开的且启用了 Discussions
3. 确认已安装 Giscus GitHub App
4. 检查分类和分类 ID 是否正确
5. 检查浏览器控制台是否有错误信息
6. 确认网络可以访问 giscus.app

## 更多信息

- [Giscus 官网](https://giscus.app/zh-CN)
- [Giscus GitHub 仓库](https://github.com/giscus/giscus)
- [GitHub Discussions 文档](https://docs.github.com/en/discussions)
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
tgState
==

[preview.webm](https://github.com/user-attachments/assets/58c398d6-bfa0-4879-b9fe-407ca4050c68)

[English](https://github.com/csznet/tgState/blob/main/README_en.md)

Expand All @@ -24,8 +25,12 @@ https://tgstate.vercel.app / https://tgstate.ikun123.com/
不限制大小demo(临时) http://tgstate-cdn.ikun123.com/

演示图片:
<details>
<summary>NSFW</summary>

![tgState](https://tgstate.vercel.app/d/BQACAgUAAx0EcyK3ugACByxlOR-Nfl4esavoO4zdaYIP_k1KYQACDAsAAkf4yFVpf_awaEkS8jAE)
</details>


# 参数说明

Expand Down
27 changes: 16 additions & 11 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# tgState
==

[preview.webm](https://github.com/user-attachments/assets/58c398d6-bfa0-4879-b9fe-407ca4050c68)

[中文](https://github.com/csznet/tgState/blob/main/README.md)

Expand All @@ -23,8 +24,13 @@ Hosted on Vercel, resource limitations - files larger than 5MB are not supported

Demo image:

<details>
<summary>NSFW</summary>

![tgState](https://tgstate.vercel.app/d/BQACAgUAAx0EcyK3ugACByxlOR-Nfl4esavoO4zdaYIP_k1KYQACDAsAAkf4yFVpf_awaEkS8jAE)

</details>

# Parameter Description

Mandatory parameters:
Expand Down Expand Up @@ -55,12 +61,12 @@ Fill in your bot token.

## pass

Fill in the access password. If not needed, fill in ```none``` directly.
Fill in the access password. If not needed, fill in `none` directly.

## mode

- ```p``` represents running in cloud drive mode, with no restriction on uploaded suffixes.
- ```m``` On top of the p mode, web upload is disabled, and upload can be done via private chat (if the target is an individual, only specified users can upload via private chat).
- `p` represents running in cloud drive mode, with no restriction on uploaded suffixes.
- `m` On top of the p mode, web upload is disabled, and upload can be done via private chat (if the target is an individual, only specified users can upload via private chat).

## url

Expand All @@ -74,7 +80,7 @@ Customize the running port.

## Get FIleID

Replying with ```get``` to the file reference in the bot's chat can get the FileID. Access the resource by combining the built address and the obtained path.
Replying with `get` to the file reference in the bot's chat can get the FileID. Access the resource by combining the built address and the obtained path.

If the url parameter is configured, the complete address will be returned directly.

Expand All @@ -98,22 +104,21 @@ wget https://github.com/csznet/tgState/releases/latest/download/tgState_arm64.zi

**Usage**

```./tgState parameters```
`./tgState parameters`

**Example**

```./tgState -token xxxx -target @xxxx```
`./tgState -token xxxx -target @xxxx`

**Run in the background**

```nohup ./tgState parameters &```
`nohup ./tgState parameters &`

## Docker

Pull the image

```docker pull csznet/tgstate:latest```

`docker pull csznet/tgstate:latest`

Start

Expand All @@ -137,6 +142,6 @@ Does not support files larger than 5MB and does not support Telegram in getting

# API Description

POST method to the path ```/api```
POST method to the path `/api`

Form transmission, field name is image, content is binary data.
4 changes: 2 additions & 2 deletions api/vercel.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func Vercel(w http.ResponseWriter, r *http.Request) {
}
switch path {
case "/api":
// 调用 control 包中的 UploadImageAPI 处理函数
control.Middleware(control.UploadImageAPI)(w, r)
// 调用 control 包中的 UploadAPI 处理函数
control.Middleware(control.UploadAPI)(w, r)
case "/pwd":
control.Pwd(w, r)
default:
Expand Down
3 changes: 3 additions & 0 deletions assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ import "embed"
var (
//go:embed templates
Templates embed.FS

//go:embed dist
Dist embed.FS
)
Loading