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

support tauri-v2 #5518

Merged
merged 12 commits into from
Sep 24, 2024
Merged

support tauri-v2 #5518

merged 12 commits into from
Sep 24, 2024

Conversation

WtecHtec
Copy link

@WtecHtec WtecHtec commented Sep 24, 2024

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

Modify tauri to v2 version

📝 补充信息 | Additional Information

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced iOS support scripts for initialization and development.
    • Added a new configuration file for defining application capabilities.
    • Implemented an event-driven communication system with a greeting command.
  • Improvements

    • Updated versioning strategy for better clarity.
    • Streamlined configuration for easier management.
    • Enhanced logging and event handling capabilities.
  • Bug Fixes

    • Resolved issues with dependency management in the configuration files.
  • Chores

    • Updated various dependencies to their latest versions.
    • Improved .gitignore to exclude generated files.

Copy link

vercel bot commented Sep 24, 2024

@WtecHtec is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request includes updates across several files, primarily focusing on versioning, dependency management, and configuration for a Tauri application. Key changes involve modifying how the version string is constructed, adding new scripts for iOS support, upgrading dependencies, and introducing a new JSON file for application capabilities. Additionally, it restructures the Cargo.toml file with new dependencies and optimizations, while the tauri.conf.json file has been simplified to streamline configuration settings.

Changes

File(s) Change Summary
app/config/build.ts Updated version string construction from tauriConfig.package.version to tauriConfig.version.
package.json Added new scripts: "ios:init" and "ios:dev"; updated @tauri-apps/cli dependency from 1.5.11 to ^2.0.0-rc.0; moved mermaid dependency within the list, version unchanged.
src-tauri/.gitignore Added /gen/ directory to the ignored paths in .gitignore.
src-tauri/Cargo.toml Upgraded tauri-build from 1.5.1 to 2.0.0-rc and tauri from 1.5.4 to 2.0.0-rc; added several new dependencies for plugins and specified library settings; introduced new profile settings for release.
src-tauri/capabilities/main.json Introduced a new JSON file defining application capabilities, including permissions for dialogs and updates.
src-tauri/src/lib.rs Added a new command greet and defined DemoEvent struct for event-driven communication within the Tauri application.
src-tauri/src/main.rs Replaced the original main function implementation to call nextchat::run() instead of the previous Tauri builder pattern.
src-tauri/tauri.conf.json Updated application configuration with new product name, identifier, version, build commands, simplified sections, and window settings.

Possibly related PRs

Suggested reviewers

  • lloydzhou

🐰 In the meadow, changes bloom,
With scripts and plugins, there's plenty of room.
Tauri's bright future, we hop with delight,
Versioning and features, all feeling just right!
Let's greet the new dawn, with a cheer and a hop,
For NextChat is here, and we’ll never stop! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Your build has completed!

Preview deployment

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Outside diff range and nitpick comments (2)
src-tauri/tauri.conf.json (1)

3-5: LGTM! Consider updating the identifier.

The product information looks good. The name "NextChat" is appropriate, and the version follows semantic versioning.

Consider updating the identifier from "NextChat.template.dev" to a more production-ready value, such as "com.yourcompany.NextChat", especially if this configuration is intended for release builds.

src-tauri/Cargo.toml (1)

47-48: Minor: Remove extra empty line

There's an extra empty line at the end of the file. While this doesn't affect functionality, it's generally good practice to end files with a single newline character for consistency.

Consider removing the extra empty line at the end of the file.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 649c5be and b9e6dce.

Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json
  • src-tauri/Cargo.lock is excluded by !**/*.lock
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (8)
  • app/config/build.ts (1 hunks)
  • package.json (4 hunks)
  • src-tauri/.gitignore (1 hunks)
  • src-tauri/Cargo.toml (1 hunks)
  • src-tauri/capabilities/main.json (1 hunks)
  • src-tauri/src/lib.rs (1 hunks)
  • src-tauri/src/main.rs (1 hunks)
  • src-tauri/tauri.conf.json (1 hunks)
Additional comments not posted (20)
src-tauri/.gitignore (1)

4-4: LGTM: Addition of /gen/ to .gitignore is appropriate.

The addition of /gen/ to the .gitignore file is a good practice. This likely excludes generated files specific to Tauri v2 from version control, which is consistent with the existing pattern of ignoring compiled files and executables in the /target/ directory.

src-tauri/capabilities/main.json (4)

2-3: LGTM: Identifier and description are clear and appropriate.

The identifier "main" and the description "permissions for desktop app" accurately represent the purpose of this capability set for the desktop application.


1-16: Overall, the capabilities file is well-structured and appropriate for a desktop application.

The main.json file provides a clear and concise definition of capabilities for the desktop application. It includes necessary permissions for dialogs, updates, and core events, which are typical requirements for desktop apps.

To ensure the configuration is optimal:

  1. Verify that "main" is the only window requiring these capabilities.
  2. Confirm that all listed permissions are actually used in the application.

These verifications will help maintain the principle of least privilege, ensuring the app has all necessary permissions without granting unnecessary access.


6-15: Verify that all listed permissions are necessary for the application.

The permissions listed cover dialog interactions, app updates, and core event listening, which are common requirements for desktop applications. However, it's crucial to ensure that each permission is necessary for the app's functionality.

To verify the usage of these permissions in the application, run the following script:

#!/bin/bash
# Description: Search for usage of dialog, updater, and core event APIs in the codebase

# Test: Look for dialog API usage
echo "Searching for dialog API usage:"
rg --type rust -e 'dialog::' -e 'ask' -e 'message'

# Test: Look for updater API usage
echo "Searching for updater API usage:"
rg --type rust -e 'updater::' -e 'check' -e 'download_and_install'

# Test: Look for core event API usage
echo "Searching for core event API usage:"
rg --type rust -e 'event::' -e 'listen'

Please review the script output to confirm that each permission is utilized in the codebase.


4-5: Verify if "main" is the only window requiring these capabilities.

The "local" setting and "windows" array look good. However, it's worth confirming that "main" is indeed the only window that requires these capabilities. If there are other windows in the application, consider whether they need the same permissions.

To verify the window names used in the application, run the following script:

Verification successful

Verified that "main" is the only window requiring these capabilities.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for window creation or references in the codebase

# Test: Look for window creation or references
rg --type rust -e 'create_window' -e 'window\..*\(' -e '"window": ".*"'

Length of output: 651

src-tauri/src/main.rs (2)

1-16: Clarify how these changes support Tauri v2 and affect application features.

The changes in this file represent a significant shift in how the application is initialized. However, it's not immediately clear how these changes relate to supporting Tauri v2 as mentioned in the PR objectives. Please provide clarification on:

  1. How does this new implementation support Tauri v2?
  2. Is the window state management plugin (tauri_plugin_window_state) still being used? If so, where is it configured?
  3. Are there any changes to the application's feature set or behavior as a result of this new implementation?
  4. How are Tauri-specific configurations (like the ones previously in the builder pattern) now being managed?

Additionally, consider adding comments to explain the rationale behind these changes and how they relate to Tauri v2 support. This will help future maintainers understand the context of this implementation.

Let's search for any Tauri v2 related configurations or dependencies:

#!/bin/bash
# Search for Tauri v2 related configurations or dependencies
rg --type toml -g 'Cargo.toml' 'tauri.*=.*2' -A 5

14-16: Provide more context for the new nextchat::run() implementation.

The new implementation is significantly simpler, but it's unclear what nextchat::run() does or where it's defined. This change might affect how the application is initialized and configured.

Could you please provide more information about:

  1. The nextchat module: Where is it defined? What does it contain?
  2. The run() function: What does it do? How does it compare to the previous Tauri builder implementation?
  3. Error handling: The previous implementation had explicit error handling. How are errors managed in the new implementation?

To help understand the context, let's search for the nextchat module:

src-tauri/tauri.conf.json (1)

1-40: Overall configuration review summary.

The Tauri configuration file has been significantly updated and streamlined. While most changes are appropriate, there are a few areas that require attention:

  1. Ensure consistency between the product name and window title.
  2. Implement a proper Content Security Policy.
  3. Review the macOS signing identity for distribution purposes.
  4. Optimize target platforms to include only necessary ones.
  5. Verify the frontend distribution path.

Please address these points to improve the configuration's robustness and security.

app/config/build.ts (1)

13-13: Verify the structure of tauriConfig and update documentation if needed.

The change from tauriConfig.package.version to tauriConfig.version suggests a structural change in the tauri.conf.json file. This modification appears to simplify the version retrieval, which is good for maintainability.

However, to ensure this change doesn't introduce any issues:

  1. Confirm that tauriConfig.version exists and contains the correct version string.
  2. Update any documentation or comments that might reference the old package.version structure.
  3. Ensure this change is consistent across the entire project where version information is used.

Let's verify the structure of the tauriConfig object:

These commands will help confirm the new structure and identify any places where the old structure might still be in use.

Verification successful

tauriConfig structure verified successfully.

  • tauriConfig.version is correctly set to "0.1.0".
  • The package.version property no longer exists.
  • No remaining references to tauriConfig.package.version found in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the structure of tauriConfig in tauri.conf.json

# Test: Check if 'version' exists directly under the root of tauri.conf.json
jq '.version' src-tauri/tauri.conf.json

# Test: Check if 'package.version' still exists (it shouldn't if the structure has changed)
jq '.package.version' src-tauri/tauri.conf.json

# Test: Search for any remaining uses of 'package.version' in the codebase
rg --type typescript --type javascript 'tauriConfig\.package\.version'

Length of output: 208


Script:

#!/bin/bash
# Description: Re-verify the structure of tauriConfig in tauri.conf.json and search for any residual 'package.version' usage

# Check if 'version' exists directly under the root of tauri.conf.json
jq '.version' src-tauri/tauri.conf.json

# Confirm 'package.version' does not exist
jq 'has("package") and .package | has("version")' src-tauri/tauri.conf.json

# Search for any remaining uses of 'package.version' in the codebase without specifying file types
rg 'tauriConfig\.package\.version'

Length of output: 253


Script:

#!/bin/bash
# Description: Correctly verify the structure of tauriConfig in tauri.conf.json and search for any residual 'package.version' usage

# Check if 'version' exists directly under the root of tauri.conf.json
jq '.version' src-tauri/tauri.conf.json

# Confirm 'package.version' does not exist, handling cases where 'package' might not exist
jq 'has("package") and (.package | has("version"))' src-tauri/tauri.conf.json

# Search for any remaining uses of 'package.version' in the codebase without specifying file types
rg 'tauriConfig\.package\.version'

Length of output: 170

src-tauri/Cargo.toml (4)

12-14: LGTM: New library configuration added

The addition of the [lib] section with multiple crate types is a good change. It allows the project to be used flexibly:

  • As a static library (staticlib)
  • As a dynamic library for FFI (cdylib)
  • As a Rust library (rlib)

This change enhances the project's versatility, allowing it to be integrated into various types of projects.


35-40: Approved: Release profile optimizations added

The addition of the [profile.release] section with various optimizations is a good practice for reducing binary size and potentially improving performance. Here's a breakdown of the changes:

  1. panic = "abort": This removes expensive panic clean-up logic, reducing binary size but also limiting error recovery capabilities.
  2. codegen-units = 1: This allows for better optimization but may increase compile times.
  3. lto = true: Link Time Optimization can significantly reduce binary size and improve performance.
  4. opt-level = "s": This optimizes for binary size rather than speed.
  5. strip = true: Removing debug symbols further reduces binary size but makes debugging release builds more difficult.

These are generally good choices for a release build focused on minimal binary size. However, it's important to document these choices and their implications, especially regarding error handling and debugging capabilities in production.

Consider adding comments in the Cargo.toml file or updating the project documentation to explain these optimization choices and their trade-offs.


19-19: Approved: Tauri-build dependency updated to v2 RC

The update of tauri-build to version "2.0.0-rc" aligns with the PR objective of supporting Tauri v2. This is a significant version jump from the previous 1.x version.

However, please note that this is a release candidate version. While it's generally fine for development, ensure thorough testing before deploying to production. Also, keep an eye out for the stable 2.0.0 release and plan to update when it becomes available.

To ensure consistency across the project, let's check if other Tauri-related dependencies are also updated to v2:

#!/bin/bash
# Check for Tauri-related dependencies versions
grep -E "tauri.*version" src-tauri/Cargo.toml

22-32: Approved with suggestions: Dependencies updated for Tauri v2

The updates to the dependencies section are comprehensive and align with the move to Tauri v2. Here are some observations and suggestions:

  1. The tauri dependency is updated to "2.0.0-rc", which is good. However, all previously specified features have been removed. Please clarify if this is intentional and ensure it doesn't unintentionally remove required functionality.

  2. New Tauri plugins have been added (shell, devtools, updater, dialog), which likely expand the application's capabilities. It would be beneficial to document these new features in the project documentation.

  3. The addition of specta and related dependencies with specific versions (e.g., "=2.0.0-rc.20") indicates a need for precise version control. This is good for consistency but may require more frequent updates.

  4. The log dependency has been added, which is great for improving the project's logging capabilities.

Consider adding comments in the Cargo.toml file or updating the project documentation to explain the purpose of each new dependency, especially the Tauri plugins.

Let's verify if the removal of tauri features is intentional:

Verification successful

Verified: Removal of tauri features is intentional

The features for the tauri dependency were already set to an empty array in the previous commit, confirming that their removal was intentional and does not affect the project's functionality. No additional actions are required regarding this change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for previous tauri features
git show HEAD^:src-tauri/Cargo.toml | grep -A5 'tauri.*version'

Length of output: 537

src-tauri/src/lib.rs (4)

13-15: DemoEvent struct definition looks good

The DemoEvent struct is well-defined with appropriate derive macros for serialization, deserialization, and Tauri event handling.


17-28: Run function initialization and logging setup look good

The conditional compilation for mobile and debug builds, along with the logging setup, is well-implemented. This ensures appropriate behavior across different build configurations.


30-46: Specta builder setup and TypeScript bindings export look good

The Specta builder is correctly configured with the greet command and DemoEvent. The conditional export of TypeScript bindings for non-mobile debug builds is a good practice, enhancing development experience without affecting production builds.


50-50: Consider the updater plugin configuration

The updater plugin is currently commented out. If auto-updates are intended for this application, consider uncommenting and properly configuring this plugin. If it's intentionally disabled, it might be clearer to remove the line entirely or add a comment explaining why it's disabled.

Verification successful

Updater Plugin Configuration Verified

The updater plugin is not used elsewhere in the project. If auto-updates are intended, uncomment and properly configure the plugin. If not needed, consider removing the commented-out line for clarity.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the updater plugin is used elsewhere in the project
rg --type rust "tauri_plugin_updater"

Length of output: 123

package.json (3)

16-17: LGTM: New iOS scripts added for Tauri v2 support

The addition of ios:init and ios:dev scripts is a good enhancement for iOS development support with Tauri v2. These scripts will streamline the initialization and development process for iOS.


37-37: Acknowledge mermaid dependency relocation

The mermaid dependency has been moved within the dependencies list. This is a minor change that doesn't affect functionality, as the version remains unchanged at ^10.6.1.


58-58: Approve @tauri-apps/cli update with a note of caution

The update of @tauri-apps/cli to version ^2.0.0-rc.0 aligns with the goal of supporting Tauri v2. However, be cautious about using a release candidate version in production, as it may introduce instability. Consider pinning to a specific rc version (e.g., "2.0.0-rc.0" without the caret) to avoid automatic updates to newer rc versions, which could introduce breaking changes.

To ensure compatibility, let's check for any Tauri-related warnings or errors:

Comment on lines 2 to 9
// #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

// fn main() {
// tauri::Builder::default()
// .plugin(tauri_plugin_window_state::Builder::default().build())
// .run(tauri::generate_context!())
// .expect("error while running tauri application");
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove commented-out code and consider Windows subsystem configuration.

  1. The cfg_attr directive for Windows subsystem configuration is commented out. This might cause a console window to appear in release mode on Windows. Consider uncommenting this line if you want to suppress the console window.

  2. The commented-out Tauri builder code should be removed. Keeping unused code in the main file can lead to confusion and maintenance issues. If this code is kept for reference, consider moving it to documentation or a separate file.

Suggested changes:

-// #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

-// fn main() {
-//   tauri::Builder::default()
-//     .plugin(tauri_plugin_window_state::Builder::default().build())
-//     .run(tauri::generate_context!())
-//     .expect("error while running tauri application");
-// }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// fn main() {
// tauri::Builder::default()
// .plugin(tauri_plugin_window_state::Builder::default().build())
// .run(tauri::generate_context!())
// .expect("error while running tauri application");
// }
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

Comment on lines 12 to 25
"plugins": {},
"app": {
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "NextChat",
"width": 960,
"hiddenTitle": true,
"titleBarStyle": "Overlay"
"title": "quantum",
"width": 800,
"height": 600
}
]
}
],
"security": {
"csp": null
},
"withGlobalTauri": false
},
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 24, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review window title and Content Security Policy settings.

The app configuration looks generally good, but there are two points to consider:

  1. The window title "quantum" doesn't match the product name "NextChat". Consider aligning these for consistency.

  2. The Content Security Policy (CSP) is set to null, which might have security implications.

Please review and update the following:

  1. Update the window title to match the product name:
-        "title": "quantum",
+        "title": "NextChat",
  1. Implement a proper Content Security Policy instead of setting it to null. A basic example might be:
-      "csp": null
+      "csp": "default-src 'self'; script-src 'self'"

Adjust the CSP as needed based on your application's requirements and security needs.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"plugins": {},
"app": {
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "NextChat",
"width": 960,
"hiddenTitle": true,
"titleBarStyle": "Overlay"
"title": "quantum",
"width": 800,
"height": 600
}
]
}
],
"security": {
"csp": null
},
"withGlobalTauri": false
},
"plugins": {},
"app": {
"windows": [
{
"title": "NextChat",
"width": 800,
"height": 600
}
],
"security": {
"csp": "default-src 'self'; script-src 'self'"
},
"withGlobalTauri": false
},

Copy link
Member

Choose a reason for hiding this comment

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

quantum 这个是其他项目的名称,,window 配置尽量保持和原来一致

Copy link
Contributor

Choose a reason for hiding this comment

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

@Leizhenpeng,明白了,谢谢您的澄清。我会在未来的评审中注意保持窗口配置与原始项目一致。

(・∧・)?


Learnings added
Learnt from: Leizhenpeng
PR: ChatGPTNextWeb/ChatGPT-Next-Web#5518
File: src-tauri/tauri.conf.json:12-25
Timestamp: 2024-09-24T11:44:10.517Z
Learning: Quantum 是其他项目的名称,窗口配置应保持与原始项目一致。

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines 26 to 39
"bundle": {
"macOS": {
"signingIdentity": "-"
},
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review macOS signing identity and target platforms.

The bundle configuration looks generally good, but there are two points to consider:

  1. The macOS signing identity is set to "-", which might cause issues when distributing the app.

  2. The targets are set to "all", which might include unnecessary platforms and increase build times.

Please review and consider updating the following:

  1. Set a proper macOS signing identity for distribution. If you're not distributing on macOS, you can remove this section.

  2. Specify only the necessary target platforms instead of "all". For example:

-   "targets": "all",
+   "targets": ["app", "deb", "msi", "dmg", "updater"]

Adjust the targets based on your actual distribution needs.

Committable suggestion was skipped due to low confidence.

src-tauri/tauri.conf.json Show resolved Hide resolved
Comment on lines 6 to 11
fn greet(app: tauri::AppHandle, name: &str) -> String {
DemoEvent("Demo event fired from Rust 🦀".to_string())
.emit(&app)
.ok();
format!("Hello, {}! You've been greeted from Rust!", name)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improve error handling in the greet function

The greet function emits a DemoEvent but ignores any potential errors. Consider handling or at least logging the error for better debugging and reliability.

Here's a suggested improvement:

 fn greet(app: tauri::AppHandle, name: &str) -> String {
-    DemoEvent("Demo event fired from Rust 🦀".to_string())
-        .emit(&app)
-        .ok();
+    if let Err(e) = DemoEvent("Demo event fired from Rust 🦀".to_string()).emit(&app) {
+        log::error!("Failed to emit DemoEvent: {:?}", e);
+    }
     format!("Hello, {}! You've been greeted from Rust!", name)
 }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn greet(app: tauri::AppHandle, name: &str) -> String {
DemoEvent("Demo event fired from Rust 🦀".to_string())
.emit(&app)
.ok();
format!("Hello, {}! You've been greeted from Rust!", name)
}
fn greet(app: tauri::AppHandle, name: &str) -> String {
if let Err(e) = DemoEvent("Demo event fired from Rust 🦀".to_string()).emit(&app) {
log::error!("Failed to emit DemoEvent: {:?}", e);
}
format!("Hello, {}! You've been greeted from Rust!", name)
}

src-tauri/src/lib.rs Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
src-tauri/src/lib.rs Outdated Show resolved Hide resolved
src-tauri/src/lib.rs Outdated Show resolved Hide resolved
src-tauri/src/main.rs Outdated Show resolved Hide resolved
src-tauri/tauri.conf.json Outdated Show resolved Hide resolved
src-tauri/tauri.conf.json Outdated Show resolved Hide resolved
"security": {
"csp": null
},
"withGlobalTauri": false
Copy link
Member

Choose a reason for hiding this comment

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

这里应该和之前的保持一致,改为true

Copy link
Member

Choose a reason for hiding this comment

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

否则,代码逻辑中有挺多地方直接从window对象上读取tauri对象的时候会失败

"width": 960,
"hiddenTitle": true,
"titleBarStyle": "Overlay"
"title": "quantum",
Copy link
Member

Choose a reason for hiding this comment

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

这里title应该和旧版保持一致
宽度高度,以及是否支持全屏等属性,也要保持一致

Copy link
Author

Choose a reason for hiding this comment

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

🫡

yarn.lock Outdated
@@ -4,40 +4,40 @@

"@aashutoshrathi/word-wrap@^1.2.3":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
resolved "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz"
Copy link
Member

Choose a reason for hiding this comment

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

尽量不要更改yarn.lock中的 这个域名。
这样,对原来的开发者来说会造成困惑,例如之前的开发者环境里面的yarn有一套缓存的东西,都可能失效,需要全部重新安装...

Copy link
Member

Choose a reason for hiding this comment

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

按道理讲,这个文件应该只出现版本更新或者新的依赖包,而不出现域名和hash的更改

也就是说,这个文件不应该出现2000+行的更改,这会给代码review增加困难

Copy link
Author

Choose a reason for hiding this comment

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

🫡

Copy link
Author

Choose a reason for hiding this comment

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

这块像是 版本更新

Copy link
Member

Choose a reason for hiding this comment

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

现在新的代码,看起来应该都是依赖库自己更新的了,应该没问题了

"window-unminimize",
] }
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri = { version = "2.0.0-rc", features = [] }
Copy link
Member

Choose a reason for hiding this comment

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

从L23 - L32这里的每一项依赖,都是必须的吗?

@lloydzhou lloydzhou changed the base branch from main to feat-tauir-v2 September 24, 2024 12:21
"csp": null,
"dangerousUseHttpScheme": true
},
"updater": {
Copy link
Member

Choose a reason for hiding this comment

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

updater不应该移除

@lloydzhou
Copy link
Member

这个分支先合并到 feat-tauir-v2分支,后续会在这个分支处理打包以及迁移http-api的逻辑。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


This branch is first merged into the feat-tauir-v2 branch, and the logic of packaging and migrating http-api will be processed in this branch later.

@lloydzhou lloydzhou merged commit 9ba1b39 into ChatGPTNextWeb:feat-tauir-v2 Sep 24, 2024
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 29, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants