Skip to content

Conversation

@xiaoland
Copy link
Owner

@xiaoland xiaoland commented Oct 14, 2025

现在的操作逻辑太蠢太繁琐了…我需要重新设计:

  • 上传配置文件并解析出对应的 Outbound, DNS 等
  • 核心是Sing-Box配置文件,保存就是直接写到JSON文件中
    • Outbound, RuleSet 会保存到数据库中,其它都保存在 JSON 中
    • 可以发布 Profile Template,模板包括除了 Outbound 的内容
    • 文件保存在 R2 中
    • Outbound, RuleSet 更新会引起引用他们的配置文件的更新
  • 没有角色之分
  • 改进 Outbound 数据模型
  • 改进 RuleSet 数据模型
  • Outbound, RuleSet 等保存在数据库中的配置项可以分享给特定的用户 (谁可写、谁可读)

其它:

  • 简化后端逻辑
    • 通过复用,特别是 writeableBy, readableBy 检查
    • 分离路由和业务逻辑,方便复用

xiaoland and others added 13 commits October 14, 2025 03:57
This commit introduces the `routeEditor` and its sub-editors (`routeRuleEditor` and `ruleSetsSelector`) to manage the route configuration for a sing-box profile.

- Implemented API endpoints to retrieve tags for outbounds and rule sets.
- Defined Zod schemas for route, routeRule, and ruleSet objects.
- Created selector components for outbounds and rule sets.
- Implemented editor components for route rules and rule sets.
- Integrated the `routeEditor` into the main `profileEditor`.
- Fixed bugs related to permission checks, N+1 queries, and component state management.
Added a default value for the `modelValue` prop in the `routeEditor` component.
- Replaced `axios` with native `fetch` for all API requests.
- Implemented `authorizedFetch` from the `user` store for authenticated requests.
- Created new Pinia stores for `Profile`, `Outbound`, and `RuleSet` modules to encapsulate API logic.
- Refactored components to use the new stores, improving code organization and maintainability.
- Replaced `axios` with native `fetch` for all API requests.
- Implemented `authorizedFetch` from the `user` store for authenticated requests.
- Created new Pinia stores for `Profile`, `Outbound`, and `RuleSet` modules to encapsulate API logic.
- Refactored components to use the new stores, improving code organization and maintainability.
- Corrected the API endpoint for the RuleSet service.
- Replaced `axios` with native `fetch` for all API requests.
- Implemented `authorizedFetch` from the `user` store for authenticated requests.
- Created new Pinia stores for `Profile`, `Outbound`, and `RuleSet` modules to encapsulate API logic.
- Refactored components to use the new stores, improving code organization and maintainability.
- Corrected the API endpoint for the RuleSet service.
- Updated the RuleSet schema and editor based on feedback.
- Replaced `axios` with native `fetch` for all API requests.
- Implemented `authorizedFetch` from the `user` store for authenticated requests.
- Created new Pinia stores for `Profile`, `Outbound`, and `RuleSet` modules to encapsulate API logic.
- Refactored components to use the new stores, improving code organization and maintainability.
- Corrected the API endpoint for the RuleSet service.
- Updated the RuleSet schema and editor based on feedback.
- Refactored `ruleSetEditor` and `routeRuleEditor` to use the common `Editor` component.
- Replaced `axios` with native `fetch` for all API requests.
- Implemented `authorizedFetch` from the `user` store for authenticated requests.
- Created new Pinia stores for `Profile`, `Outbound`, and `RuleSet` modules to encapsulate API logic.
- Refactored components to use the new stores, improving code organization and maintainability.
- Corrected the API endpoint for the RuleSet service.
- Updated the RuleSet schema and editor based on feedback.
- Refactored `ruleSetEditor` and `routeRuleEditor` to use the common `Editor` component.
- Fixed a bug in the backend that prevented RuleSets from being created.
@xiaoland xiaoland self-assigned this Oct 14, 2025
@xiaoland xiaoland added the enhancement New feature or request label Oct 14, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 14, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
a-cup 8bbca69 Commit Preview URL

Branch Preview URL
Oct 24 2025, 05:59 AM

xiaoland and others added 14 commits October 14, 2025 08:54
This commit refactors the `routeEditor` component to use the `outboundsSelector` for the `final` field, instead of a plain text input. This ensures that only valid outbound tags can be selected.
This commit updates the `routeRuleEditor` to include "Rule Sets" as a conditional field in the "Add Condition" dropdown menu. This makes the UI consistent for all condition-like fields.
This commit updates the `addRule` function in `routeEditor.vue` to set default values for new route rules. The `action` is set to 'route' and `outbound` is initialized as an empty string. The `rule_set` field is not included by default.
This commit adds the ability to remove condition fields from the `routeRuleEditor`. A 'remove' icon button has been added next to each conditional field, which, when clicked, will hide the field and clear its data.
This commit addresses several styling and layout issues in the route editor components:

- **ruleSetsSelector**: The select field and 'Create New' button are now on the same line.
- **routeRuleEditor**: The `ruleSetsSelector` now correctly expands to fill available width, and consistent vertical margins have been added to all conditional fields.
- **routeEditor**: Consistent spacing has been applied to improve the overall layout.
This commit adds the ability to create a new outbound directly from the `outboundsSelector` component. This is achieved by adding a 'Create New' button that opens a dialog containing the `outboundEditor`.
This commit updates the 'Create New' buttons in the `outboundsSelector` and `ruleSetsSelector` to be icon buttons. This makes them more visually integrated with the select fields and provides a more consistent user experience.
This commit fixes several alignment issues:

- In `outboundsSelector` and `ruleSetsSelector`, the 'Create New' icon button is now vertically centered with the select field.
- In `routeRuleEditor`, the 'remove' icon buttons are now vertically centered with their corresponding conditional fields.
xiaoland and others added 9 commits October 19, 2025 08:23
…s from R2

The `getProfiles` method in `ProfileService` has been updated to fetch the complete profile configuration from Cloudflare R2, in addition to the profile data from the database. This ensures that the response body is an array of `SingBoxProfileRequestSchema`, including fields like `ntp` and `dns` that are not stored in the database.

The implementation now:
- Fetches all user profiles from the database.
- For each profile, it retrieves the corresponding configuration file from Cloudflare R2.
- It then merges the database fields with the R2 configuration to construct the final profile objects.
Refactored API route handlers in `outbound.ts`, `profile.ts`, and `rule-set.ts` to correctly access the JWT payload using `c.get('jwtPayload')` instead of the incorrect `c.get('token_payload')`. This change ensures that user authentication details are properly retrieved and utilized in the application's backend logic.
…e. getProfileById should returns like getProfiles (includes fields from r2Object)
…e. getProfileById should returns like getProfiles (includes fields from r2Object)
Refactor Backend: use Hono, separate business logic from route handler
@xiaoland
Copy link
Owner Author

前端重构

  • 折叠面板隐藏高级选项
  • 通用编辑器(可隐藏标题)
  • 非可持久化 Outbound

google-labs-jules bot and others added 20 commits October 20, 2025 05:08
This commit refactors the outbound schema to distinguish between normal and special outbounds.

Special outbounds (selector, urltest, direct) are no longer persisted in the database. Instead, they are stored directly in the profile configuration in R2.

The backend has been updated to handle the new `special_outbounds` field in the profile creation and update requests.

The frontend has been updated to:
- Conditionally render the outbound editor form based on the outbound type.
- Use a `tag` field instead of `name`, `region`, and `provider` for special outbounds.
- Manage the `special_outbounds` array in the profile editor.
The `outboundsSelector` component was using the `Select` component from PrimeVue, which is intended for single-item selection. This has been corrected to use the `MultiSelect` component, which allows for the selection of multiple items.
This commit corrects the implementation of the `outboundsPicker` component. The PrimeVue `Select` component was being incorrectly used for multiple selections.

This has been replaced with the `MultiSelect` component, which is the correct component for this purpose. This ensures that the UI for selecting multiple outbounds in the special outbound forms now functions as expected.
This commit corrects the implementation of the `outboundsPicker` component. The PrimeVue `Select` component was being incorrectly used for multiple selections.

This has been replaced with the `MultiSelect` component, which is the correct component for this purpose. This ensures that the UI for selecting multiple outbounds in the special outbound forms now functions as expected.
…orrectly.

- The `getProfileById` service method has been updated to filter the outbounds from the R2 configuration.
- A new `special_outbounds` field has been added to the response, containing the full objects for special outbounds (`selector`, `urltest`, `direct`).
- The existing `outbounds` field now correctly contains only the numeric IDs of the database-persisted outbounds.
Refactored the backend Outbound service to improve code structure and maintainability.

- Introduced `zod-class` and `drizzle-zod` to create domain model classes and generate Zod schemas from Drizzle table definitions.
- Created an `Outbound` class to encapsulate business logic related to outbounds.
- Created a `ServiceBase` class to share `db` and `env` dependencies across services.
- Refactored `OutboundService` to inherit from `ServiceBase` and return instances of the `Outbound` class.
- Moved the `Outbounds` table schema to a separate file.
Added a try...catch block to the GET /api/outbounds endpoint to return a detailed error message upon failure. This will help in diagnosing the cause of the internal server error.
- region, provider allows null
- use `loose` instead of `passthourgh`
Refactored the rule-set module to align with the new architectural pattern.

- Moved the RuleSets table definition to server/db/rule-set.ts.
- Created a RuleSet business object in server/business/rule-set.ts.
- Updated RuleSetService to use the new business object and extend ServiceBase.
- Updated the ruleSetRouter to use the refactored service and implement standardized error handling.
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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants