diff --git a/.github/workflows/build-only.yml b/.github/workflows/build-only.yml index 7d2bde9..3002620 100644 --- a/.github/workflows/build-only.yml +++ b/.github/workflows/build-only.yml @@ -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 diff --git a/.gitmodules b/.gitmodules index 51f6a76..0077323 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/.trae/rules/project_rules.md b/.trae/rules/project_rules.md index 0449d25..5507ce1 100644 --- a/.trae/rules/project_rules.md +++ b/.trae/rules/project_rules.md @@ -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 ` - - -// Pug template syntax - - - -``` - -**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` 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 +- **组件**:使用 ` - - {{ line }} + + {{ line }} - 清除 + 清除 粘贴 {{ $t('link.lobby.join_lobby') }}{{ $t('tools.link.join_lobby') }} - + 1. 进入世界后,在游戏菜单中选择「对局域网开放」 2. 在下方选择此游戏实例,单击「创建」 3. 成功创建大厅后,复制大厅编号并发送给你的朋友 - + 开始扫描 + 创建 + + + - 刷新 - 创建 + 指定端口创建 + diff --git a/src/views/Tools/LinkLobbyInner.vue b/src/views/Tools/LinkLobbyInner.vue index f8946cc..1495630 100644 --- a/src/views/Tools/LinkLobbyInner.vue +++ b/src/views/Tools/LinkLobbyInner.vue @@ -2,14 +2,39 @@ import CardInfoItem from '@/components/widget/CardInfoItem.vue' import PCard from '@/components/widget/PCard.vue' import router from '@/router' +import useTerracottaStore from '@/stores/terracotta' import { useRouteQuery } from '@vueuse/router' +import IconBtnConnectUserType from '@/assets/icons/IconBtnConnectUserType.svg' +import IconBtnConnectUserName from '@/assets/icons/IconBtnConnectUserName.svg' +import IconBtnFinishQuality from '@/assets/icons/BtnFinishQuality.svg' +import IconBtnFinishId from '@/assets/icons/BtnFinishId.svg' +import { onMounted, onUnmounted } from 'vue' +import sideTip from '@/composables/sideTip' +import { useI18n } from 'vue-i18n' +const terracotta = useTerracottaStore() const roomCode = useRouteQuery('code') +const t = useI18n() const closeLobby = async () => { + terracotta.setWaiting() router.back() console.info('[scaffolding] closed room code', roomCode.value) } + +const copyRoomCode = () => { + navigator.clipboard.writeText(roomCode.value as string) + sideTip.show('复制成功', 'success') +} + +onMounted(() => { + terracotta.update() + terracotta.startAutoUpdate() +}) + +onUnmounted(() => { + terracotta.stopAutoUpdate() +}) @@ -18,27 +43,51 @@ const closeLobby = async () => { - UserName - Creator + + + {{ terracotta.username }} + + + 创建者 + + + 加入者 + - 已连接 - {{ roomCode }} + + + 已连接 + + + + {{ roomCode }} + - 复制大厅编号 + 复制大厅编号 关闭大厅 - - + + @@ -61,15 +110,14 @@ const closeLobby = async () => { display: flex; flex-direction: row; gap: 5px; + flex-wrap: wrap; > div { - flex: 1; + flex: 1 1 auto; + &:nth-child(1) { + border-right: 1px solid #e5e5e5; + } } } - - > div { - display: flex; - flex-direction: column; - } } /* 右侧面板 - 占3/5宽度,高度自动对齐左侧 */ @@ -94,4 +142,20 @@ const closeLobby = async () => { flex: 1; } } + +.icon-text { + display: flex; + flex-direction: row; + gap: 5px; + align-items: center; + justify-content: flex-start; + &.lobby-info:nth-child(1) { + margin-bottom: 5px; + } + > span { + pointer-events: all; + user-select: all; + -webkit-user-select: all; + } +} diff --git a/vite.config.ts b/vite.config.ts index 422a795..b761f10 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,7 +15,7 @@ export default defineConfig({ port: 5173, strictPort: true, watch: { - ignored: ['**/src-tauri/**'], + ignored: ['**/src-tauri/**', '**/src-terracotta/**'], } }, envPrefix: ['VITE_', 'TAURI_ENV_*'],
{{ line }}
1. 进入世界后,在游戏菜单中选择「对局域网开放」
2. 在下方选择此游戏实例,单击「创建」
3. 成功创建大厅后,复制大厅编号并发送给你的朋友