Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 支持自定义资源服务器地址 #213

Merged
merged 5 commits into from
Dec 3, 2024
Merged

Conversation

A-kirami
Copy link
Owner

@A-kirami A-kirami commented Dec 2, 2024

这个 PR 带来了什么样的更改?

  • 错误修复
  • 新功能
  • 文档/注释
  • 代码格式
  • 代码重构
  • 测试用例
  • 性能优化
  • 外观样式
  • 项目构建
  • 依赖环境
  • 持续集成/部署
  • 其他,请描述:

这个 PR 是否存在破坏性变更?

  • 是的,并已在 issue #___ 号中获得批准
  • 没有

描述

如题

动机和背景

resolve #203

其他信息

检查工作

  • 我对我的代码进行了注释,特别是在难以理解的部分
  • 我的更改需要更新文档,并且已对文档进行了相应的更改
  • 我添加了测试并且已经在本地通过,以证明我的修复补丁或新功能有效
  • 我已检查并确保更改没有与其他打开的 Pull Requests 重复

@A-kirami A-kirami added the enhancement New feature or request label Dec 2, 2024
Copy link

sourcery-ai bot commented Dec 2, 2024

审核指南由 Sourcery 提供

此 PR 增加了配置自定义资产服务器地址的支持。实现替换了静态文件服务器,改为可配置的服务器,可以通过自定义主机和端口设置启动。更改包括新的服务器状态管理系统、用于配置的 UI 组件以及文件 URL 生成逻辑的更新。

新的 AppState 管理的类图

classDiagram
    class AppState {
        +Option<JoinHandle> server_handle
        +set_handle(JoinHandle handle)
        +stop_server()
    }
    class JoinHandle {
        +abort()
    }
    AppState --> JoinHandle : uses
Loading

文件级更改

更改 详情 文件
实现了具有状态管理的可配置资产服务器
  • 添加了新的 AppState 结构体以管理服务器生命周期
  • 创建了 start_assets_server 命令以使用自定义主机和端口初始化服务器
  • 实现了服务器停止功能以处理服务器重启
  • 移除了静态端口配置和未使用的端口检测
src-tauri/src/command.rs
src-tauri/src/state.rs
src-tauri/src/server.rs
src-tauri/src/utils.rs
添加了用于资产服务器配置的 UI 组件和存储
  • 在通用设置存储中添加了 assetsServerAddress 字段
  • 实现了服务器地址格式的输入验证
  • 添加了服务器地址配置的表单字段
  • 创建了监视处理程序以在地址更改时重启服务器
src/stores/general-settings.ts
src/views/settings/general.vue
更新了应用程序初始化和文件 URL 生成
  • 修改了应用程序初始化以使用配置的地址启动资产服务器
  • 更新了文件 URL 生成以使用自定义服务器地址
  • 在 Tauri 构建器设置中添加了状态初始化
src/App.vue
src/utils/file.ts
src-tauri/src/lib.rs

针对关联问题的评估

问题 目标 是否解决 解释
#203 通过使其监听可配置的 IP 地址而不仅仅是 127.0.0.1,允许对静态文件服务器的远程连接

可能关联的问题


提示和命令

与 Sourcery 互动

  • 触发新审核: 在拉取请求上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审核评论。
  • 从审核评论生成 GitHub 问题: 通过回复审核评论请求 Sourcery 创建问题。
  • 生成拉取请求标题: 在拉取请求标题的任何地方写 @sourcery-ai 以随时生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任何地方写 @sourcery-ai summary 以随时生成 PR 摘要。您也可以使用此命令指定摘要应插入的位置。

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审核功能,例如 Sourcery 生成的拉取请求摘要、审核指南等。
  • 更改审核语言。
  • 添加、删除或编辑自定义审核说明。
  • 调整其他审核设置。

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This PR adds support for configuring a custom assets server address. The implementation replaces the static file server with a configurable one that can be started with custom host and port settings. The changes include a new state management system for the server, UI components for configuration, and updates to the file URL generation logic.

Class diagram for the new AppState management

classDiagram
    class AppState {
        +Option<JoinHandle> server_handle
        +set_handle(JoinHandle handle)
        +stop_server()
    }
    class JoinHandle {
        +abort()
    }
    AppState --> JoinHandle : uses
Loading

File-Level Changes

Change Details Files
Implemented a configurable assets server with state management
  • Added new AppState struct to manage server lifecycle
  • Created start_assets_server command to initialize server with custom host and port
  • Implemented server stop functionality to handle server restarts
  • Removed static port configuration and unused port detection
src-tauri/src/command.rs
src-tauri/src/state.rs
src-tauri/src/server.rs
src-tauri/src/utils.rs
Added UI components and store for assets server configuration
  • Added assetsServerAddress field to general settings store
  • Implemented input validation for server address format
  • Added form field for server address configuration
  • Created watch handler to restart server on address changes
src/stores/general-settings.ts
src/views/settings/general.vue
Updated application initialization and file URL generation
  • Modified app initialization to start assets server with configured address
  • Updated file URL generation to use custom server address
  • Added state initialization in Tauri builder setup
src/App.vue
src/utils/file.ts
src-tauri/src/lib.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#203 Allow remote connections to the static file server by making it listen on a configurable IP address instead of just 127.0.0.1

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@A-kirami - 我已经审查了你的更改 - 这里有一些反馈:

总体评论

  • 考虑用适当的错误处理替换 unwrap() 调用,以便为用户提供更好的错误信息,特别是在 IP 地址解析逻辑中
  • 在启动资产服务器之前的 500ms setTimeout 延迟似乎不太可靠。考虑实现一个适当的初始化序列或基于事件的方法
这是我在审查期间查看的内容
  • 🟡 一般问题:发现 3 个问题
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我变得更有用!请点击每条评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English

Hey @A-kirami - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider replacing unwrap() calls with proper error handling to provide better error messages to users, particularly in the IP address parsing logic
  • The 500ms setTimeout delay before starting the assets server seems fragile. Consider implementing a proper initialization sequence or event-based approach
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

src-tauri/src/command.rs Outdated Show resolved Hide resolved
src-tauri/src/command.rs Outdated Show resolved Hide resolved
src/App.vue Outdated Show resolved Hide resolved
src/stores/general-settings.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Dec 2, 2024

📦️ 此 PR 构建的应用已经准备就绪

平台 文件 大小
🐧 linux-amd64 matcha_0.4.5_linux-amd64 112.8 MB
🍎 macos-amd64 matcha_0.4.5_macos-amd64 24.34 MB
🍎 macos-arm64 matcha_0.4.5_macos-arm64 23.96 MB
🪟 windows-amd64 matcha_0.4.5_windows-amd64 22.01 MB

*从提交 034560a 构建

@A-kirami A-kirami merged commit 5875145 into main Dec 3, 2024
8 checks passed
@A-kirami A-kirami deleted the feat/custom-assets-server branch December 3, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Feature: 静态文件服务器允许远程连接
1 participant