mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-20 23:28:40 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3725193e72 | ||
|
|
62c9fb46ae | ||
|
|
9b1890f57c | ||
|
|
68a8b67931 | ||
|
|
d0bda60b9f | ||
|
|
d71b0de056 | ||
|
|
8c7d4f5b72 | ||
|
|
d8793a89a2 | ||
|
|
178670fdab | ||
|
|
715b657153 | ||
|
|
c0353bb050 | ||
|
|
0c1907d868 | ||
|
|
edbf2c6001 | ||
|
|
fa319d0898 | ||
|
|
b0a595fe9c | ||
|
|
b7d250dbac |
@@ -1,3 +1,4 @@
|
||||
#syntax=docker/dockerfile:1.7-labs
|
||||
# Stage 1: Builder
|
||||
FROM oven/bun:1 AS builder
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://shumai.one/">Website</a> | <a target="_blank" href="https://docs.shumai.one/introduction">Docs</a> | <a target="_blank" href="https://staging.shumai.one">Demo</a>
|
||||
<a target="_blank" href="https://shumai.one/">Website</a> | <a target="_blank" href="https://docs.shumai.one/introduction">Docs</a> | <a target="_blank" href="https://staging.shumai.one">Demo</a> | <a target="_blank" href="README_CN.md">中文</a>
|
||||
</p>
|
||||
|
||||

|
||||
@@ -25,11 +25,16 @@
|
||||
|
||||
#### Shumai Agent
|
||||
|
||||
- **Collaborative AI Chat**: Converse with a context-aware AI agent directly within your project workspace.
|
||||
- **Collaborative AI Chat**: Converse with a context-aware AI agent by using `@mentions` directly within the file's comments area.
|
||||
- **Custom Skills & Tools**: Extend the agent's capabilities by registering custom scripts, tools, and automation skills.
|
||||
- **Isolated Sandbox Execution**: Run agent-submitted scripts securely within a sandboxed environment.
|
||||
- **AI-Powered Metadata Autofill**: Automatically generate tags, descriptions, and custom metadata for new assets using Google Gemini.
|
||||
- **Semantic Search**: Locate assets instantly based on visual or conceptual search queries using vector embeddings.
|
||||
- **AI Metadata Autofill**: Automatically autofill custom metadata for new assets.
|
||||
- **Semantic Search**: Find assets based on visual or conceptual search queries using vector embeddings(Gemini Embedding 2).
|
||||
|
||||
> [!NOTE]
|
||||
> **Media Processing & Storage:** When uploading media, Shumai always preserves and stores your original raw file. For all media types (both images and videos), Shumai creates a 480p WebP poster image to serve as the preview in the file list view. Additionally:
|
||||
> * **For Images:** Shumai generates a high-quality WebP proxy at the exact same resolution as your original file for optimized viewing.
|
||||
> * **For Videos:** It generates at least one proxy video (depending on your transcoding settings), alongside a sprite image and a small preview video (capped at 1600 frames) to enable fast timeline scrubbing and lightning-quick previews.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
<p align="center">
|
||||
<img src="docs/logo-rounded.png" alt="Shumai Logo" width="65" />
|
||||
</p>
|
||||
|
||||
<h1 align="center">Shumai</h1>
|
||||
|
||||
<p align="center">
|
||||
<strong>为创意工作打造的开源协作平台。</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://shumai.one/">官方网站</a> | <a target="_blank" href="https://docs.shumai.one/introduction">文档</a> | <a target="_blank" href="https://staging.shumai.one">在线演示</a> | <a target="_blank" href="README.md">English</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||

|
||||
|
||||
## 功能特性
|
||||
|
||||
- **兼容 S3 与本地存储**:使用本地文件系统或任何兼容 S3 的云存储(AWS S3、Cloudflare R2、阿里云 OSS 等)安全地存储和提供您的创意资产。
|
||||
- **逐帧批注与评论**:直接在视频和图像资产上使用特定帧的绘图工具和带时间戳的评论,提供精确的反馈。
|
||||
- **安全分享与合集**:创建安全的公开分享链接和媒体合集,以便与客户和团队进行协作。
|
||||
- **细粒度访问控制**:使用团队级别和项目级别的基于角色的访问控制来管理访问权限。
|
||||
- **基于 Temporal 的分布式转码**:将占用大量资源的视频转码任务部署到 Temporal Worker上。
|
||||
- **自定义资产元数据**:为媒体文件添加可搜索/编辑的自定义元数据字段。
|
||||
|
||||
#### Shumai 智能体 (Agent)
|
||||
|
||||
- **AI Agent 协作**:通过评论区和 AI 智能体进行交流。
|
||||
- **自定义技能**:通过添加自定义技能来扩展智能体的能力。
|
||||
- **隔离的沙箱执行**:在沙箱环境中安全地运行智能体提交的脚本。
|
||||
- **AI 元数据自动填充**:使用AI为资产自动生填充元数据字段。
|
||||
- **语义搜索**:基于 Gemini Embedding 2 的图片/视频内容搜索。
|
||||
|
||||
> [!NOTE]
|
||||
> **媒体处理与存储说明:** 在上传媒体文件时,Shumai 会始终完整保留并存储您的原始文件。对于所有媒体类型(图片与视频),Shumai 都会统一生成一张 480p 的 WebP 预览图,用作文件列表页预览。此外:
|
||||
> * **图片文件:** Shumai 会额外生成一个与原图分辨率完全一致的 WebP 优化版本。
|
||||
> * **视频文件:** 系统会根据您的转码设置生成至少一个预览版本mp4,同时还会生成一张雪碧图(Sprite)和一个轻量级预览视频(上限 1600 帧),以实现流畅的文件列表页面预览和文件查看页面时间轴快速预览。
|
||||
|
||||
---
|
||||
|
||||
## 安装指南
|
||||
|
||||
以下是使用本地存储运行 Shumai 的快速上手指南。如需了解高级配置(包括 S3 兼容存储配置、Temporal 工作流编排等),请参阅我们的[官方文档](https://docs.shumai.one/getting-started/overview)。
|
||||
|
||||
### 方案一:使用 Docker Compose(推荐)
|
||||
|
||||
使用 Docker Compose 是运行 Shumai 最快的方式。您无需克隆仓库,也不需要手动安装依赖包。请确保电脑上已安装 [Docker](https://docs.docker.com/get-docker/) 和 [Docker Compose](https://docs.docker.com/compose/install/),然后按照以下步骤操作:
|
||||
|
||||
1. 创建并进入一个新目录,用于存放配置文件和数据卷:
|
||||
```bash
|
||||
mkdir shumai && cd shumai
|
||||
|
||||
```
|
||||
|
||||
2. 下载 `docker-compose.yaml` 配置文件:
|
||||
```bash
|
||||
curl -o docker-compose.yaml [https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose-aliyun.yaml](https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml)
|
||||
|
||||
```
|
||||
|
||||
|
||||
3. 配置环境变量(可选):
|
||||
* `SHUMAI_SERVER_PORT` 用于控制 Shumai 服务监听的端口,默认值为 `3000`。
|
||||
* 默认情况下,该 Docker Compose 部署会自动启用集成的本地存储。若想切换至外部 S3 兼容存储,请将 `AWS_ENDPOINT_URL_S3` 设置为对应云厂商的 Endpoint URL,并根据需要配置相应的 AWS 凭证和存储桶(Bucket)参数:
|
||||
```
|
||||
AWS_ENDPOINT_URL_S3: S3_ENDPOINT_URL
|
||||
S3_REGION: S3_REGION
|
||||
S3_BUCKET: BUCKET_NAME
|
||||
S3_ACCESS_KEY_ID: ID
|
||||
S3_SECRET_ACCESS_KEY: KEY
|
||||
|
||||
```
|
||||
|
||||
|
||||
* 默认情况下 `AWS_ENDPOINT_URL_S3` 指向 `http://localhost:{SHUMAI_SERVER_PORT}`。如果您使用本地存储,但希望在自定义的主机名或端口上公开访问 Shumai,请务必将 `AWS_ENDPOINT_URL_S3` 修改为浏览器访问该服务时所使用的外部 URL。
|
||||
例如,如果您将 `docker-compose.yaml` 中的端口映射从 `3000:3000` 修改为了 `12345:3000`,且服务部署在 IP 为 `12.34.56.78` 的服务器上,请进行如下设置:
|
||||
```
|
||||
AWS_ENDPOINT_URL_S3: [http://12.34.56.78:12345](http://12.34.56.78:12345)
|
||||
|
||||
```
|
||||
|
||||
|
||||
此地址必须能够从客户端浏览器正常访问,且必须包含对外暴露的实际端口号。
|
||||
|
||||
|
||||
4. 在后台启动所有服务:
|
||||
```bash
|
||||
docker compose up -d
|
||||
|
||||
```
|
||||
|
||||
|
||||
5. 打开浏览器,访问 `http://localhost:3000` 即可开始使用(若是远程部署,请访问 `http://<您的服务器IP>:3000`)。
|
||||
|
||||
### 方案二:通过 NPM / 包管理器安装
|
||||
|
||||
通过 NPM 上的 `@shumai-one/shumai` 进行安装。
|
||||
|
||||
#### 第一步:启动带 pgvector 支持的 PostgreSQL
|
||||
|
||||
Shumai 依赖支持 `pgvector` 扩展的 PostgreSQL 数据库。您可以使用 Docker 快速启动一个预配置好的数据库容器:
|
||||
|
||||
```bash
|
||||
docker run --name shumai_postgres \
|
||||
-e POSTGRES_USER=shumai \
|
||||
-e POSTGRES_PASSWORD=shumai_password \
|
||||
-e POSTGRES_DB=shumai_db \
|
||||
-p 5432:5432 \
|
||||
-d docker.m.daocloud.io/pgvector/pgvector:pg18
|
||||
|
||||
```
|
||||
|
||||
#### 第二步:创建工作区目录
|
||||
|
||||
创建一个专属目录用来存放环境配置和媒体文件(媒体文件默认会保存在 `./data` 目录下):
|
||||
|
||||
```bash
|
||||
mkdir shumai && cd shumai
|
||||
|
||||
```
|
||||
|
||||
#### 第三步:安装平台特定系统依赖
|
||||
|
||||
在安装 Shumai 之前,请确保您的宿主机上已经安装了以下系统依赖项:
|
||||
|
||||
| 依赖包 | 功能描述 | Ubuntu/Debian | Fedora | Arch | macOS |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| **ffmpeg** | 媒体转码及元数据提取 | `sudo apt install -y ffmpeg` | `sudo dnf install -y ffmpeg` | `sudo pacman -S --noconfirm ffmpeg` | `brew install ffmpeg` |
|
||||
| **bubblewrap** | 用于安全执行 AI 助手脚本的隔离沙箱环境 | `sudo apt install -y bubblewrap` | `sudo dnf install -y bubblewrap` | `sudo pacman -S --noconfirm bubblewrap` | *无需安装* |
|
||||
| **socat** | 用于沙箱网络桥接的双向套接字中继 | `sudo apt install -y socat` | `sudo dnf install -y socat` | `sudo pacman -S --noconfirm socat` | `brew install socat` |
|
||||
| **ripgrep** | 用于工作区安全策略的高效文本搜索工具 | `sudo apt install -y ripgrep` | `sudo dnf install -y ripgrep` | `sudo pacman -S --noconfirm ripgrep` | `brew install ripgrep` |
|
||||
|
||||
> [!NOTE]
|
||||
> **Ubuntu 24.04+ 用户请注意:** 这些系统版本默认限制了非特权用户命名空间(unprivileged user namespaces)。为了让 `bubblewrap` 和沙箱隔离层正常工作,需要关闭此限制:
|
||||
> ```bash
|
||||
> sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
>
|
||||
> ```
|
||||
>
|
||||
>
|
||||
> 或者,您也可以专门配置一个 AppArmor 配置文件,为相关二进制文件授予用户命名空间创建(`userns`)权限。
|
||||
|
||||
#### 第四步:全局安装 Shumai
|
||||
|
||||
使用您常用的包管理器进行全局安装:
|
||||
|
||||
```bash
|
||||
# 使用 NPM
|
||||
npm install -g @shumai-one/shumai
|
||||
|
||||
# 使用 PNPM
|
||||
pnpm add -g @shumai-one/shumai
|
||||
|
||||
# 使用 Bun
|
||||
bun add -g @shumai-one/shumai
|
||||
|
||||
```
|
||||
|
||||
#### 第五步:配置环境配置
|
||||
|
||||
在刚才创建的工作区目录(`shumai/`)下新建一个 `.env` 文件,并填入以下配置:
|
||||
|
||||
```env
|
||||
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
|
||||
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
|
||||
STORAGE_BACKEND=local
|
||||
SHUMAI_SERVER_PORT=3000
|
||||
AWS_ENDPOINT_URL_S3=http://localhost:3000
|
||||
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> `SHUMAI_SERVER_PORT` 用于设置 Web 服务的启动端口,而 `AWS_ENDPOINT_URL_S3` 供浏览器端构建文件上传链接。
|
||||
> 如果您部署在远程服务器(如 `http://123.456.7.8`)并且做了端口映射(如 Docker 中的 `12345:3000`),请将 `AWS_ENDPOINT_URL_S3` 设置为 `http://123.456.7.8:12345`。
|
||||
|
||||
#### 第六步:启动 Shumai
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Bun 用户特别提示:** 由于发布的包二进制文件包含 `#!/usr/bin/env node` 头部声明(Shebang),直接在终端执行全局命令(例如 `shumai`)默认会通过 Node.js 运行。如果您是用 Bun 安装的并且希望调用 Bun 运行时,请在所有命令前加上 `bun run --bun` 前缀(例如:`bun run --bun shumai`、`bun run --bun shumai -d`、`bun run --bun shumai stop`)。
|
||||
|
||||
在您的工作区目录下执行以下命令启动应用:
|
||||
|
||||
```bash
|
||||
shumai
|
||||
|
||||
```
|
||||
|
||||
您也可以让 Shumai 在后台以守护进程(Daemon)模式运行和管理:
|
||||
|
||||
* **后台模式启动**:
|
||||
```bash
|
||||
shumai -d
|
||||
|
||||
```
|
||||
|
||||
|
||||
* **停止服务**:
|
||||
```bash
|
||||
shumai stop
|
||||
|
||||
```
|
||||
|
||||
|
||||
* **重启服务**:
|
||||
```bash
|
||||
shumai restart
|
||||
|
||||
```
|
||||
|
||||
|
||||
* **查看并跟踪实时日志**:
|
||||
```bash
|
||||
shumai logs
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
启动时,Shumai 会自动执行数据库迁移(Migration)并在 `http://localhost:3000` 拉起 Web 服务。
|
||||
|
||||
---
|
||||
|
||||
### 方案三:源码编译运行(开发环境)
|
||||
|
||||
如果您希望在本地参与 Shumai 的开发,请按以下步骤配置开发环境:
|
||||
|
||||
1. 克隆代码仓库并安装依赖项:
|
||||
```bash
|
||||
git clone [https://github.com/shumaiOne/shumai.git](https://github.com/shumaiOne/shumai.git)
|
||||
cd shumai
|
||||
bun install
|
||||
|
||||
```
|
||||
|
||||
|
||||
2. 启动 `pgvector` 数据库容器(参考**方案二中的第一步**)。
|
||||
3. 参照**方案二中的第五步**,在项目根目录下创建一个 `.env` 文件。
|
||||
4. 执行数据库结构迁移:
|
||||
```bash
|
||||
bun run db:migrate
|
||||
|
||||
```
|
||||
|
||||
|
||||
5. 启动本地开发服务器:
|
||||
```bash
|
||||
bun run dev
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 命令行工具 (CLI)
|
||||
|
||||
Shumai 自带一个功能完备的命令行工具(CLI),支持您直接在终端里高效管理项目、文件夹、资产,批量上传文件/目录,以及快速创建新版本。
|
||||
|
||||
关于 CLI 的安装与详细使用指南,请参阅 [CLI Readme](https://www.google.com/search?q=apps/cli/README.md)。
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/agent-app",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/cli",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/transcode-app",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/web-app",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
services:
|
||||
postgres:
|
||||
image: docker.m.daocloud.io/pgvector/pgvector:pg18
|
||||
container_name: shumai_postgres
|
||||
environment:
|
||||
POSTGRES_USER: shumai
|
||||
POSTGRES_PASSWORD: shumai_password
|
||||
POSTGRES_DB: shumai_db
|
||||
ports:
|
||||
- '5432:5432'
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/18/docker
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U shumai -d shumai_db']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
shumai:
|
||||
image: crpi-gd059yeolk1as59f.cn-shanghai.personal.cr.aliyuncs.com/shumaione/shumai:latest
|
||||
container_name: shumai_app
|
||||
ports:
|
||||
- '3000:3000'
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
environment:
|
||||
# Database Configuration
|
||||
DATABASE_URL: postgres://shumai:shumai_password@shumai_postgres:5432/shumai_db?search_path=public&sslmode=disable
|
||||
|
||||
# Server Configuration
|
||||
SHUMAI_SERVER_PORT: 3000
|
||||
|
||||
# S3 Configuration
|
||||
STORAGE_BACKEND: local
|
||||
AWS_ENDPOINT_URL_S3: http://localhost:3000
|
||||
|
||||
# Better Auth
|
||||
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
|
||||
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shumai",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/agent",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/api",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/core",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { auth } from './auth'
|
||||
import { userMetadataService } from '../user-metadata/user-metadata'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
|
||||
describe('Auth Signup Locale Hook', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(teamService, 'getSignupInfo').mockResolvedValue({
|
||||
initialized: false,
|
||||
demoMode: false,
|
||||
userCount: 1,
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('should save locale metadata for the user upon signup', async () => {
|
||||
const email = `signup-locale-${Date.now()}@example.com`
|
||||
|
||||
// We must use any here because 'locale' is a custom property we extract in
|
||||
// our auth hooks, but better-auth's signUpEmail typescript interface does
|
||||
// not recognize it.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await (auth.api.signUpEmail as any)({
|
||||
headers: new Headers(),
|
||||
body: {
|
||||
email,
|
||||
password: 'testpassword',
|
||||
name: 'Locale Tester',
|
||||
locale: 'zh',
|
||||
},
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
console.error('SIGNUP ERROR:', res.error)
|
||||
}
|
||||
|
||||
expect(res).toBeDefined()
|
||||
expect(res.user).toBeDefined()
|
||||
expect(res.user.email).toBe(email)
|
||||
|
||||
// Check that the userMetadata record was created with key 'locale' and value 'zh'
|
||||
const teamMembers = await prisma.teamMember.findMany({
|
||||
where: { userId: res.user.id },
|
||||
})
|
||||
expect(teamMembers.length).toBeGreaterThan(0)
|
||||
|
||||
for (const member of teamMembers) {
|
||||
const meta = await userMetadataService.getMetadata(res.user.id, member.teamId, 'locale')
|
||||
expect(meta).toBeDefined()
|
||||
expect(meta?.value).toBe('zh')
|
||||
}
|
||||
})
|
||||
|
||||
it('should not save locale metadata if locale is invalid or missing', async () => {
|
||||
const email = `signup-no-locale-${Date.now()}@example.com`
|
||||
|
||||
// We must use any here because 'locale' is a custom property we extract in
|
||||
// our auth hooks, but better-auth's signUpEmail typescript interface does
|
||||
// not recognize it.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await (auth.api.signUpEmail as any)({
|
||||
headers: new Headers(),
|
||||
body: {
|
||||
email,
|
||||
password: 'testpassword',
|
||||
name: 'No Locale Tester',
|
||||
locale: 'fr', // invalid locale
|
||||
},
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
console.error('SIGNUP ERROR 2:', res.error)
|
||||
}
|
||||
|
||||
expect(res).toBeDefined()
|
||||
expect(res.user).toBeDefined()
|
||||
|
||||
const teamMembers = await prisma.teamMember.findMany({
|
||||
where: { userId: res.user.id },
|
||||
})
|
||||
expect(teamMembers.length).toBeGreaterThan(0)
|
||||
|
||||
for (const member of teamMembers) {
|
||||
const meta = await userMetadataService.getMetadata(res.user.id, member.teamId, 'locale')
|
||||
expect(meta).toBeNull()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -4,6 +4,7 @@ import { prisma } from '@shumai/db'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
import { inviteService } from '@shumai/core/src/invite/invite'
|
||||
import { createAuthMiddleware } from 'better-auth/api'
|
||||
import { userMetadataService } from '@shumai/core/src/user-metadata/user-metadata'
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: prismaAdapter(prisma, {
|
||||
@@ -102,6 +103,17 @@ export const auth = betterAuth({
|
||||
if (inviteCode) {
|
||||
await inviteService.consumeInvite(inviteCode, user.id)
|
||||
}
|
||||
|
||||
const locale = body?.locale
|
||||
if (locale === 'en' || locale === 'zh') {
|
||||
const joinedTeams = await prisma.teamMember.findMany({
|
||||
where: { userId: user.id },
|
||||
select: { teamId: true },
|
||||
})
|
||||
for (const member of joinedTeams) {
|
||||
await userMetadataService.upsertMetadata(user.id, member.teamId, 'locale', locale)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`[Better Auth Hook] Error in after hook: ${err}`)
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ export class TranscodeService {
|
||||
duration: number,
|
||||
): Promise<void> {
|
||||
const spriteFps = 100 / duration
|
||||
const filterComplex = `[0:v]fps=${spriteFps},scale=w=480:h=-2,tile=10x10[sprite_out];[0:v]scale=-2:720:force_original_aspect_ratio=decrease,select='eq(n\\,0)'[thumb_out]`
|
||||
const filterComplex = `[0:v]fps=${spriteFps},scale=w=480:h=-2,tile=10x10[sprite_out];[0:v]scale=-2:480:force_original_aspect_ratio=decrease,select='eq(n\\,0)'[thumb_out]`
|
||||
|
||||
const args = [
|
||||
'-i',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/db",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/dtos",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/tableprinter",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/transcode",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -74,13 +74,6 @@ export function useFramePlayer(
|
||||
const stallThreshold = Math.max(100, 3000 / frameRate)
|
||||
const isVfcStalled = Date.now() - lastVfcTime > stallThreshold
|
||||
|
||||
// Print debug log roughly once per second during playback
|
||||
if (Math.floor(video.currentTime * frameRate + 0.45) % 30 === 0) {
|
||||
console.log(
|
||||
`[useFramePlayer] currentTime: ${video.currentTime}, isVfcStalled: ${isVfcStalled}, stallThreshold: ${stallThreshold}, totalFrames: ${totalFrames}`,
|
||||
)
|
||||
}
|
||||
|
||||
// Only update playhead via currentTime (RAF) if rVFC has stalled or isn't supported
|
||||
if (!videoWithCallback.requestVideoFrameCallback || isVfcStalled) {
|
||||
const frame = Math.floor(video.currentTime * frameRate + 0.45)
|
||||
@@ -133,8 +126,11 @@ export function useFramePlayer(
|
||||
setCurrentFrame(clamped)
|
||||
|
||||
// Snap the playhead to the center of the paused frame to align browser compositor
|
||||
const safeCenterTime = calculateFrameCenterTime(clamped, frameRate)
|
||||
video.currentTime = safeCenterTime
|
||||
// Skip snapping if the video has ended to preserve the native ended state and allow native replay
|
||||
if (!video.ended) {
|
||||
const safeCenterTime = calculateFrameCenterTime(clamped, frameRate)
|
||||
video.currentTime = safeCenterTime
|
||||
}
|
||||
}
|
||||
|
||||
video.addEventListener('play', handlePlay)
|
||||
|
||||
@@ -424,8 +424,8 @@
|
||||
"avatar_source": "头像来源",
|
||||
"saving": "保存中",
|
||||
|
||||
"auth_tagline": "一个工作区,管理所有创意资产。",
|
||||
"auth_description": "上传并索引您的文件,使用自定义元数据模式丰富它们,直接在媒体上绘制标注,并收集即时反馈——这一切都在一个为创作者打造的现代工作区中完成。",
|
||||
"auth_tagline": "一站式创意资产管理协作平台。",
|
||||
"auth_description": "上传您的创意资产,添加各种类型的自定义元数据,直接在图片或视频上绘制标注和添加评论,——这一切都在Shumai,一个为创作者打造的一站式平台上完成。",
|
||||
"auth_feature_uploads": "即时资产上传 & 高保真媒体播放器",
|
||||
"auth_feature_metadata": "自定义元数据模式 & 画布标注审阅",
|
||||
"auth_feature_teams": "无缝团队工作区 & 安全分享",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/webui",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./index.html",
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ const en_auth_description = /** @type {(inputs: Auth_DescriptionInputs) => Local
|
||||
};
|
||||
|
||||
const zh_auth_description = /** @type {(inputs: Auth_DescriptionInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`上传并索引您的文件,使用自定义元数据模式丰富它们,直接在媒体上绘制标注,并收集即时反馈——这一切都在一个为创作者打造的现代工作区中完成。`)
|
||||
return /** @type {LocalizedString} */ (`上传您的创意资产,添加各种类型的自定义元数据,直接在图片或视频上绘制标注和添加评论,——这一切都在Shumai,一个为创作者打造的一站式平台上完成。`)
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ const en_auth_tagline = /** @type {(inputs: Auth_TaglineInputs) => LocalizedStri
|
||||
};
|
||||
|
||||
const zh_auth_tagline = /** @type {(inputs: Auth_TaglineInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`一个工作区,管理所有创意资产。`)
|
||||
return /** @type {LocalizedString} */ (`一站式创意资产管理协作平台。`)
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
import { Label } from '@/ui/components/ui/label'
|
||||
import { Loader2, Mail, Lock, ArrowRight, UserPlus } from 'lucide-react'
|
||||
import { signUp } from '@/ui/lib/auth-client'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { getLocale, setLocale } from '@/ui/paraglide/runtime.js'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router'
|
||||
import { ArrowRight, Loader2, Lock, Mail, UserPlus } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { signUp } from '@/ui/lib/auth-client'
|
||||
import { useState } from 'react'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
const signupSchema = z.object({
|
||||
email: z.string().email(m.invalid_email_address()),
|
||||
@@ -30,6 +31,15 @@ function SignupPage() {
|
||||
const inviteCode = (search as { inviteCode?: string }).inviteCode
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [locale, setLocaleState] = useState<'en' | 'zh'>(() => {
|
||||
const activeLocale = getLocale()
|
||||
return activeLocale === 'zh' ? 'zh' : 'en'
|
||||
})
|
||||
|
||||
const handleLocaleChange = (newLocale: 'en' | 'zh') => {
|
||||
setLocaleState(newLocale)
|
||||
setLocale(newLocale)
|
||||
}
|
||||
|
||||
const { data: inviteInfo } = useQuery({
|
||||
queryKey: ['invite', inviteCode],
|
||||
@@ -71,6 +81,7 @@ function SignupPage() {
|
||||
password: data.password,
|
||||
name: data.email, // Use email as the username
|
||||
inviteCode: data.inviteCode,
|
||||
locale,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
|
||||
@@ -238,14 +249,38 @@ function SignupPage() {
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm">
|
||||
<span className="text-zinc-500 dark:text-zinc-400">{m.already_have_account()}</span>
|
||||
<a
|
||||
href="/login"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
{m.login()} <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
<div className="mt-12 pt-10 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm flex flex justify-between gap-4">
|
||||
<div>
|
||||
<span className="text-zinc-500 dark:text-zinc-400">{m.already_have_account()} </span>
|
||||
<a
|
||||
href="/login"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
{m.login()} <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-400 dark:text-zinc-500">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('en')}
|
||||
className={`cursor-pointer hover:text-zinc-800 dark:hover:text-zinc-200 transition-colors ${
|
||||
locale === 'en' ? 'font-bold text-rose-500 dark:text-rose-400' : ''
|
||||
}`}
|
||||
>
|
||||
English
|
||||
</button>
|
||||
<span className="text-zinc-300 dark:text-zinc-850">/</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('zh')}
|
||||
className={`cursor-pointer hover:text-zinc-800 dark:hover:text-zinc-200 transition-colors ${
|
||||
locale === 'zh' ? 'font-bold text-rose-500 dark:text-rose-400' : ''
|
||||
}`}
|
||||
>
|
||||
中文
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
)
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const APP_VERSION = '0.1.3'
|
||||
export const APP_VERSION = '0.1.4'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/workflow-core",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
Reference in New Issue
Block a user