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
10 changes: 5 additions & 5 deletions .github/workflows/build-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ jobs:
with:
name: tauri-build-${{ matrix.platform }}-${{ matrix.args == '' && 'default' || matrix.args }}
path: |
${{ matrix.platform == 'macos-latest' && 'src-tauri/target/**/release/bundle/**/*.dmg' || '' }}
${{ matrix.platform == 'windows-latest' && 'src-tauri/target/**/release/bundle/**/*.exe' || '' }}
${{ matrix.platform == 'windows-latest' && 'src-tauri/target/**/release/bundle/**/*.msi' || '' }}
${{ matrix.platform == 'ubuntu-22.04' && 'src-tauri/target/**/release/bundle/**/*.deb' || '' }}
${{ matrix.platform == 'ubuntu-22.04' && 'src-tauri/target/**/release/bundle/**/*.rpm' || '' }}
${{ matrix.platform == 'macos-latest' && 'target/**/release/bundle/**/*.dmg' || '' }}
${{ matrix.platform == 'windows-latest' && 'target/**/release/bundle/**/*.exe' || '' }}
${{ matrix.platform == 'windows-latest' && 'target/**/release/bundle/**/*.msi' || '' }}
${{ matrix.platform == 'ubuntu-22.04' && 'target/**/release/bundle/**/*.deb' || '' }}
${{ matrix.platform == 'ubuntu-22.04' && 'target/**/release/bundle/**/*.rpm' || '' }}
if-no-files-found: error
retention-days: 7
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "src/locales"]
path = src/locales
url = git@github.com:PCL-Community/PCL-i18n-locales.git
[submodule "src-terracotta"]
path = src-terracotta
url = git@github.com:PCL-Community/Terracotta-lib.git
313 changes: 55 additions & 258 deletions .trae/rules/project_rules.md
Original file line number Diff line number Diff line change
@@ -1,269 +1,66 @@
# AGENTS.md - PCL.Proto Development Guide
# PCL.Proto 开发指南

This document provides essential information for AI agents working on the PCL.Proto project.

## Project Overview

PCL.Proto is a Minecraft launcher prototype built with:

- **Frontend**: Vue 3 + TypeScript + Vite + Pinia + Vue Router
- **Backend**: Rust + Tauri 2
- **UI Framework**: Custom components
- **Package Manager**: pnpm

## Build & Development Commands

### Development

```bash
# Start development server (frontend + Tauri)
pnpm run dev

# Frontend-only development
pnpm run ui:dev
```

### Building

```bash
# Full build (frontend + Tauri)
pnpm run build

# Frontend-only build
pnpm run ui:build

# Type checking
pnpm run type-check
```

### Testing

**Note**: No test framework is currently configured in this project. Primary validation is through:

- Type checking: `pnpm run type-check`
- Manual testing: `pnpm run dev`
- Rust tests can be run with: `cargo test` in `src-tauri/` directory

### Tauri Commands
## 项目技术栈
- **前端**:Vue 3 + TypeScript + Vite + Pinia + Vue Router
- **后端**:Rust + Tauri 2
- **UI**:自定义组件
- **包管理**:pnpm

## 核心开发命令
```bash
# Run any Tauri command
pnpm run tauri [command]

# Generate icons
pnpm run tauri icon
# 开发
pnpm run dev # 全栈开发
pnpm run ui:dev # 仅前端

# 构建
pnpm run build # 全栈构建
pnpm run ui:build # 仅前端构建
pnpm run type-check # 类型检查

# 测试
pnpm run type-check # 主要验证方式
cargo test # Rust测试(在src-tauri目录下)
```

### Deployment

```bash
# Deploy to GitHub Pages
pnpm run deploy
```

## Code Style Guidelines

### TypeScript/JavaScript

**Imports:**

- Use ES modules (`import/export`)
- Group imports: external libraries first, then internal modules
- Use `@/` alias for internal imports (configured in Vite)
- Example from `src/main.ts:12-20`:
```typescript
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import router from '@/router/index'
```

**Naming Conventions:**

- **Variables/Functions**: camelCase (`getAccount`, `username`)
- **Types/Interfaces**: PascalCase (`AccountInner`, `IVersionShow`)
- **Constants**: UPPER_SNAKE_CASE for true constants
- **Store names**: kebab-case (`account-info`)
- **Component files**: PascalCase (`Modal.vue`, `PButton.vue`)

**Formatting:**

- **Semicolons**: No semicolons (Prettier config)
- **Quotes**: Single quotes
- **Line length**: 100 characters (Prettier config)
- **Trailing commas**: Not used in examples
- **Indentation**: 2 spaces (no tabs)

**Prettier Configuration:**

```json
{
"semi": false,
"singleQuote": true,
"printWidth": 100
}
```

**Error Handling:**

- Use try/catch for async operations
- Log errors with `console.error`
- Example from `src/stores/account.ts:31`:
```typescript
} catch (error) {
console.error('Failed to initialize account:', error)
}
```

**TypeScript:**

- Use strict typing
- Define interfaces for complex data structures
- Use `ref` for reactive state in composables
- Prefer composition API with `<script setup>`

### Vue Components

**Component Structure:**

```vue
<script setup lang="ts">
// Imports first
import { useModal } from '@/composables/useModal'
import PButton from './widget/PButton.vue'

// Type definitions
import type { ModalButtonOption } from '@/types/modal'

// Logic
const { isOpen, options, close, inputValue } = useModal()
</script>

<template lang="pug">
// Pug template syntax
</template>

<style scoped>
// Scoped styles
</style>
```

**Template Language:**

- Use **Pug** for templates (`lang="pug"`)
- Use kebab-case for template attributes and events
- Use Vue directives (`v-if`, `v-for`, `v-model`)

**State Management:**

- Use **Pinia** stores for global state
- Use `ref` and `computed` for component state
- Store naming: `useStoreName()` pattern

### Rust (Backend)

**File Structure:**

- Backend code in `src-tauri/src/`
- Core logic in `src-tauri/src/core/`
- Utilities in `src-tauri/src/util/`

**Naming:**

- **Modules**: snake_case (`api_client`, `game_launcher`)
- **Structs/Enums**: PascalCase (`GameInstance`, `GameJava`)
- **Functions**: snake_case (`from_version_folder`)
- **Variables**: snake_case (`version_folder`, `json_files`)

**Error Handling:**

- Use `thiserror` crate for custom error types
- Use `Result<T, E>` for fallible operations
- Use `?` operator for error propagation

**Imports:**

- Group standard library imports first
- Then external crate imports
- Then internal module imports
- Example from `src-tauri/src/core/game.rs:1-6`:

```rust
use std::{fs, path::PathBuf, sync::Arc};

use crate::core::{
api_client::game::VersionDetails, java::JavaRuntime, launcher::GameLaunchError,
mcmod::PluginType, repository::GameRepository,
};
```

## Project Structure

## 代码风格要点

### TypeScript/Vue
- **导入**:使用 `@/` 别名,外部库在前
- **命名**:
- 变量/函数:camelCase
- 类型/接口:PascalCase
- 组件文件:PascalCase(如 `Modal.vue`)
- Store命名:kebab-case(如 `account-info`)
- **格式化**:无分号、单引号、100字符行宽
- **错误处理**:async操作必须用 try/catch
- **组件**:使用 `<script setup>` + Pug模板 + 组合式API

### Rust
- **命名**:模块/函数/变量用 snake_case,结构体/枚举用 PascalCase
- **错误**:使用 `thiserror` + `Result<T, E>` + `?` 传播
- **导入**:标准库 → 外部crate → 内部模块

## 项目结构
```
src/
├── api/ # API clients and data fetching
├── assets/ # Static assets (fonts, icons, images)
├── components/ # Vue components
│ ├── icons/ # Icon components
│ └── widget/ # Reusable UI widgets
├── composables/ # Vue composables
├── layout/ # Layout components
├── locales/ # Internationalization
├── router/ # Vue Router configuration
├── stores/ # Pinia stores
├── types/ # TypeScript type definitions
├── util/ # Utility functions
└── views/ # Page components
├── components/ # Vue组件
├── composables/ # 组合式函数
├── stores/ # Pinia仓库
├── types/ # TS类型定义
└── views/ # 页面

src-tauri/
├── src/
│ ├── core/ # Core Rust logic
│ └── util/ # Rust utilities
└── Cargo.toml # Rust dependencies
└── src/
├── core/ # Rust核心逻辑
└── util/ # 工具函数
```

## Testing Notes

- No test framework detected in package.json
- Type checking serves as primary validation: `pnpm run type-check`
- Manual testing through development server: `pnpm run dev`
- Rust tests can be run with: `cargo test` in `src-tauri/` directory

## Git & Workflow

**Submodules:**

- Project uses git submodules (locales directory)
- Initialize with: `git submodule update --init --recursive`

**Commit Messages:**

- Follow conventional commits style
- Use present tense ("Add feature" not "Added feature")
- Reference issues when applicable

## Important Notes for Agents

1. **Always run type checking** after making changes: `pnpm run type-check`
2. **Format code** before committing: `pnpm run format`
3. **Check for submodule updates** when cloning
4. **Tauri requires platform-specific toolchains** (MSVC for Windows, Xcode for macOS)
5. **Use pnpm** not npm or yarn for package management
6. **Component naming**: Use PascalCase for Vue component files
7. **Store pattern**: Use `useStoreName()` pattern for Pinia stores
8. **Error handling**: Always handle async errors with try/catch
9. **Type safety**: Define interfaces for all complex data structures
10. **Internationalization**: Support both English (en-US) and Chinese (zh-CN) locales

## Performance Considerations

- Use `ref` for reactive primitives, `reactive` for objects
- Implement proper cleanup in composables
- Use `v-memo` for expensive template computations when needed
- Consider lazy loading for large components

## Security Notes

- Never commit secrets or API keys
- Validate all user input in Rust backend
- Use Tauri's secure IPC for frontend-backend communication
- Follow Rust's memory safety guarantees for backend code
## 关键提醒
1. 始终在修改后运行 `pnpm run type-check`
2. 提交前格式化代码:`pnpm run format`
3. 使用 `pnpm`,勿用 npm/yarn
4. Vue组件文件使用 **PascalCase**
5. Pinia仓库使用 `useStoreName()` 模式
6. 支持中英文国际化(en-US / zh-CN)
7. 子模块初始化:`git submodule update --init --recursive`
8. 后端验证用户输入,利用Tauri安全IPC
Loading