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

๐Ÿ’„ style: support multi-window for PWA #4334

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

BrandonStudio
Copy link
Contributor

@BrandonStudio BrandonStudio commented Oct 12, 2024

Support multi-window on desktop devices

๐Ÿ’ป ๅ˜ๆ›ด็ฑปๅž‹ | Change Type

  • โœจ feat
  • ๐Ÿ› fix
  • โ™ป๏ธ refactor
  • ๐Ÿ’„ style
  • ๐Ÿ‘ท build
  • โšก๏ธ perf
  • ๐Ÿ“ docs
  • ๐Ÿ”จ chore

๐Ÿ”€ ๅ˜ๆ›ด่ฏดๆ˜Ž | Description of Change

Support multi-window for PWA on desktop devices.

๐Ÿ“ ่กฅๅ……ไฟกๆฏ | Additional Information

closes #4191 #4206

Support multi-window on desktop devices
Copy link

vercel bot commented Oct 12, 2024

@BrandonStudio is attempting to deploy a commit to the LobeChat Community Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Oct 12, 2024
@lobehubbot
Copy link
Member

๐Ÿ‘ @BrandonStudio

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
้žๅธธๆ„Ÿ่ฐขๆ‚จๆๅ‡บๆ‹‰ๅ–่ฏทๆฑ‚ๅนถไธบๆˆ‘ไปฌ็š„็คพๅŒบๅšๅ‡บ่ดก็Œฎ๏ผŒ่ฏท็กฎไฟๆ‚จๅทฒ็ป้ตๅพชไบ†ๆˆ‘ไปฌ็š„่ดก็ŒฎๆŒ‡ๅ—๏ผŒๆˆ‘ไปฌไผšๅฐฝๅฟซๅฎกๆŸฅๅฎƒใ€‚
ๅฆ‚ๆžœๆ‚จ้‡ๅˆฐไปปไฝ•้—ฎ้ข˜๏ผŒ่ฏท้šๆ—ถไธŽๆˆ‘ไปฌ่”็ณปใ€‚

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests โœ…

Project coverage is 92.26%. Comparing base (6bb6ea6) to head (b5204d9).
Report is 25 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #4334    +/-   ##
========================================
  Coverage   92.26%   92.26%            
========================================
  Files         489      489            
  Lines       35057    35062     +5     
  Branches     2133     2282   +149     
========================================
+ Hits        32346    32351     +5     
  Misses       2711     2711            
Flag Coverage ฮ”
app 92.26% <รธ> (+<0.01%) โฌ†๏ธ
server 97.37% <รธ> (รธ)

Flags with carried forward coverage won't be shown. Click here to find out more.

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

@arvinxx arvinxx changed the title Support multi-window for PWA ๐Ÿ’„ style: support multi-window for PWA Oct 12, 2024
@arvinxx
Copy link
Contributor

arvinxx commented Oct 12, 2024

้—ฎไบ†ไธ‹ Claude๏ผš


่ฟ™ไธช้…็ฝฎๆ˜ฏ PWA (Progressive Web App) ไธญ็š„ Web App Manifest ๆ–‡ไปถไธญ็š„ไธ€ไธชๅฑžๆ€ง๏ผŒ็”จไบŽๆŽงๅˆถ PWA ๅบ”็”จ็š„ๅฏๅŠจ่กŒไธบใ€‚ๅ…ทไฝ“ๆฅ่ฏด๏ผŒlaunch_handler ๅฑžๆ€งๅฎšไน‰ไบ†ๅฝ“็”จๆˆทๅฐ่ฏ•ๆ‰“ๅผ€ๅทฒ็ปๅฎ‰่ฃ…็š„ PWA ๆ—ถ๏ผŒๆต่งˆๅ™จๅบ”่ฏฅๅฆ‚ไฝ•ๅค„็†่ฟ™ไธช่ฏทๆฑ‚ใ€‚

่ฎฉๆˆ‘ไปฌ่ฏฆ็ป†่งฃ้‡Šไธ€ไธ‹่ฟ™ไธช้…็ฝฎ๏ผš

launch_handler: {
  client_mode: ['navigate-existing', 'auto']
}
  1. launch_handler: ่ฟ™ๆ˜ฏไธปๅฑžๆ€ง๏ผŒ็”จไบŽๅฎšไน‰ๅฏๅŠจๅค„็†่กŒไธบใ€‚

  2. client_mode: ่ฟ™ไธชๅญๅฑžๆ€งๆŒ‡ๅฎšไบ†ๅฝ“ PWA ่ขซๅฏๅŠจๆ—ถๅบ”่ฏฅ้‡‡ๅ–็š„ๅ…ทไฝ“่กŒไธบใ€‚ๅฎƒๆ˜ฏไธ€ไธชๆ•ฐ็ป„๏ผŒๅŒ…ๅซไบ†ไผ˜ๅ…ˆ็บงๆŽ’ๅบ็š„ๅค„็†ๆจกๅผใ€‚

  3. ๆ•ฐ็ป„ไธญ็š„ๅ€ผ๏ผš

    • 'navigate-existing': ๅฆ‚ๆžœ PWA ๅทฒ็ปๆœ‰ไธ€ไธชๆ‰“ๅผ€็š„็ช—ๅฃๆˆ–ๆ ‡็ญพ้กต๏ผŒๆต่งˆๅ™จไผšๅฐ่ฏ•ๅฏผ่ˆชๅˆฐ้‚ฃไธชๅทฒๅญ˜ๅœจ็š„ๅฎžไพ‹๏ผŒ่€Œไธๆ˜ฏๅˆ›ๅปบไธ€ไธชๆ–ฐ็š„ใ€‚
    • 'auto': ๅฆ‚ๆžœๆ— ๆณ•ไฝฟ็”จ navigate-existing ๆจกๅผ๏ผˆๆฏ”ๅฆ‚ๆฒกๆœ‰ๅทฒๆ‰“ๅผ€็š„ๅฎžไพ‹๏ผ‰๏ผŒๆต่งˆๅ™จๅฐ†่‡ชๅŠจๅ†ณๅฎšๆœ€ไฝณ็š„ๅฏๅŠจๆ–นๅผ๏ผŒๅฏ่ƒฝๆ˜ฏๅˆ›ๅปบไธ€ไธชๆ–ฐ็š„ PWA ๅฎžไพ‹ใ€‚

่ฟ™ไธช้…็ฝฎ็š„ไธป่ฆ็›ฎ็š„ๆ˜ฏ๏ผš

  1. ๆ้ซ˜็”จๆˆทไฝ“้ชŒ๏ผš้ฟๅ…ไธๅฟ…่ฆๅœฐๆ‰“ๅผ€ๅคšไธช็›ธๅŒ็š„ PWA ๅฎžไพ‹ใ€‚
  2. ่ต„ๆบไผ˜ๅŒ–๏ผš้€š่ฟ‡้‡็”จๅทฒๆ‰“ๅผ€็š„ๅฎžไพ‹๏ผŒๅฏไปฅ่Š‚็œ็ณป็ปŸ่ต„ๆบใ€‚
  3. ็Šถๆ€ไฟๆŒ๏ผšๅฆ‚ๆžœ็”จๆˆทไน‹ๅ‰ๅœจ PWA ไธญๆœ‰ๆœชๅฎŒๆˆ็š„ๆ“ไฝœ๏ผŒๅฏไปฅ็›ดๆŽฅๅ›žๅˆฐ้‚ฃไธช็Šถๆ€ใ€‚

้œ€่ฆๆณจๆ„็š„ๆ˜ฏ๏ผŒlaunch_handler ๆ˜ฏไธ€ไธช็›ธๅฏน่พƒๆ–ฐ็š„็‰นๆ€ง๏ผŒๅฏ่ƒฝๅนถไธๆ˜ฏๆ‰€ๆœ‰็š„ๆต่งˆๅ™จ้ƒฝๅฎŒๅ…จๆ”ฏๆŒใ€‚ๅœจไฝฟ็”จๆ—ถ๏ผŒๅบ”่ฏฅ่€ƒ่™‘ๅˆฐๅ…ผๅฎนๆ€ง้—ฎ้ข˜๏ผŒๅนถๆไพ›้€‚ๅฝ“็š„้™็บง็ญ–็•ฅใ€‚

ๅœจๅฎž้™…ๅบ”็”จไธญ๏ผŒ่ฟ™ไธช็‰นๆ€งๅฏนไบŽ้‚ฃไบ›็”จๆˆทๅฏ่ƒฝ้ข‘็นๆ‰“ๅผ€ๅ…ณ้—ญ็š„ PWA ็‰นๅˆซๆœ‰็”จ๏ผŒๆฏ”ๅฆ‚็คพไบคๅช’ไฝ“ๅบ”็”จใ€้‚ฎไปถๅฎขๆˆท็ซฏๆˆ–่€…ๆ–‡ๆกฃ็ผ–่พ‘ๅ™จ็ญ‰ใ€‚

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


Asked Claude:


This configuration is a property in the Web App Manifest file in PWA (Progressive Web App) and is used to control the startup behavior of the PWA application. Specifically, the launch_handler attribute defines how the browser should handle the request when a user attempts to open an installed PWA.

Let's explain this configuration in detail:

launch_handler: {
  client_mode: ['navigate-existing', 'auto']
}
  1. launch_handler: This is the main attribute used to define launch handling behavior.

  2. client_mode: This sub-property specifies the specific behavior that should be taken when the PWA is launched. It is an array containing prioritized processing modes.

  3. Values โ€‹โ€‹in the array:

    • 'navigate-existing': If the PWA already has an open window or tab, the browser will try to navigate to that existing instance instead of creating a new one.
    • 'auto': If navigate-existing mode is not available (e.g. there is no instance opened), the browser will automatically decide the best way to launch it, possibly by creating a new PWA instance.

The main purpose of this configuration is:

  1. Improve user experience: Avoid opening multiple identical PWA instances unnecessarily.
  2. Resource optimization: System resources can be saved by reusing open instances.
  3. State retention: If the user has unfinished operations in PWA before, they can directly return to that state.

It should be noted that launch_handler is a relatively new feature and may not be fully supported by all browsers. When using, compatibility issues should be taken into consideration and an appropriate downgrade strategy should be provided.

In practical applications, this feature is particularly useful for PWAs that users may frequently open and close, such as social media applications, email clients, or document editors.

Copy link

vercel bot commented Oct 12, 2024

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Comments Updated (UTC)
lobe-chat-preview โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback Oct 12, 2024 7:08am

@BrandonStudio
Copy link
Contributor Author

BrandonStudio commented Oct 12, 2024

I think remove launch_handler is equivalence to set as auto, which requests new window on desktop devices and navigates to existed window on mobile devices

refs: https://developer.mozilla.org/en-US/docs/Web/Manifest/launch_handler

@arvinxx
Copy link
Contributor

arvinxx commented Oct 12, 2024

@BrandonStudio ๆˆ‘่ฏ•ไบ†ไธ‹ๆ€ŽไนˆๆฒกๅŒบๅˆซ้ขโ€ฆ

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


@BrandonStudio I tried it but there is no difference...

@BrandonStudio
Copy link
Contributor Author

@BrandonStudio ๆˆ‘่ฏ•ไบ†ไธ‹ๆ€ŽไนˆๆฒกๅŒบๅˆซ้ขโ€ฆ

ๅบ”่ฏฅๆœ‰ๅŒบๅˆซๅ•Š๏ผŒๅœจWindowsไธŠ๏ผŒ้ป˜่ฎค็š„ๅฎ‰่ฃ…pwaไน‹ๅŽ๏ผŒไปปๅŠกๆ ๆŒ‰้ผ ๆ ‡ไธญ้”ฎๅชไผšๅˆทๆ–ฐๅŽŸๆœ‰็ช—ๅฃ๏ผŒไฟฎๆ”นไน‹ๅŽ็š„ๅฎ‰่ฃ…pwaๆŒ‰้ผ ๆ ‡ไธญ้”ฎไผšๅ‡บไธ€ไธชๆ–ฐ็ช—ๅฃ

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


@BrandonStudio I tried it but there is no difference...

There should be a difference. On Windows, after the default installation of pwa, pressing the middle mouse button on the taskbar will only refresh the original window. After the modified installation of pwa, pressing the middle mouse button will open a new window.

@arvinxx
Copy link
Contributor

arvinxx commented Oct 13, 2024

mac ไธŠๆฒกๅŒบๅˆซโ€ฆ

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


No difference on mac...

Copy link
Contributor

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 13, 2024
@arvinxx arvinxx merged commit 0284606 into lobehub:main Oct 13, 2024
8 of 9 checks passed
@lobehubbot
Copy link
Member

โค๏ธ Great PR @BrandonStudio โค๏ธ

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
้กน็›ฎ็š„ๆˆ้•ฟ็ฆปไธๅผ€็”จๆˆทๅ้ฆˆๅ’Œ่ดก็Œฎ๏ผŒๆ„Ÿ่ฐขๆ‚จ็š„่ดก็Œฎ! ๅฆ‚ๆžœๆ‚จๅฏน LobeHub ๅผ€ๅ‘่€…็คพๅŒบๆ„Ÿๅ…ด่ถฃ๏ผŒ่ฏทๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ discord๏ผŒ็„ถๅŽ็งไฟก @arvinxx ๆˆ– @canisminor1990ใ€‚ไป–ไปฌไผš้‚€่ฏทๆ‚จๅŠ ๅ…ฅๆˆ‘ไปฌ็š„็งๅฏ†ๅผ€ๅ‘่€…้ข‘้“ใ€‚ๆˆ‘ไปฌๅฐ†ไผš่ฎจ่ฎบๅ…ณไบŽ Lobe Chat ็š„ๅผ€ๅ‘๏ผŒๅˆ†ไบซๅ’Œ่ฎจ่ฎบๅ…จ็ƒ่Œƒๅ›ดๅ†…็š„ AI ๆถˆๆฏใ€‚

github-actions bot pushed a commit that referenced this pull request Oct 13, 2024
### [Version&nbsp;1.22.3](v1.22.2...v1.22.3)
<sup>Released on **2024-10-13**</sup>

#### ๐Ÿ’„ Styles

- **misc**: Support multi-windows for PWA.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Styles

* **misc**: Support multi-windows for PWA, closes [#4334](#4334) ([0284606](0284606))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

๐ŸŽ‰ This PR is included in version 1.22.3 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

@BrandonStudio BrandonStudio deleted the pwa-multiwindow branch October 14, 2024 00:43
@BrandonStudio
Copy link
Contributor Author

้‚ฃๆˆ‘่ง‰ๅพ—ๆ˜ฏmac็š„่ฎพ่ฎก๏ผŒไฝ ๅฏไปฅ่ฏ•่ฏ•ๅˆซ็š„pwaๆ˜ฏไธๆ˜ฏไนŸไธ่ƒฝๆ‰“ๅผ€ๅคš็ช—ๅฃ๏ผŒๆฏ”ๅฆ‚claude.ai๏ผŒ่ฟ™ไธชWindowsไธŠไนŸๆ˜ฏๅฏไปฅ็š„

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


Then I think itโ€™s the design of Mac. You can try to see if other pwa canโ€™t open multiple windows, such as claude.ai, which can also be used on Windows.

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Oct 14, 2024
### [Version&nbsp;1.65.2](v1.65.1...v1.65.2)
<sup>Released on **2024-10-14**</sup>

#### โ™ป Code Refactoring

- **misc**: Separate message slice and aiChat slice.

#### ๐Ÿ› Bug Fixes

- **misc**: Fix images not go in to chat context.

#### ๐Ÿ’„ Styles

- **misc**: Reorder github model list & updata info & add new model, support multi-windows for PWA.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Separate message slice and aiChat slice, closes [lobehub#4359](https:/bentwnghk/lobe-chat/issues/4359) ([7d037f6](7d037f6))

#### What's fixed

* **misc**: Fix images not go in to chat context, closes [lobehub#4361](https:/bentwnghk/lobe-chat/issues/4361) ([f17ab49](f17ab49))

#### Styles

* **misc**: Reorder github model list & updata info & add new model, closes [lobehub#4360](https:/bentwnghk/lobe-chat/issues/4360) ([e7767a5](e7767a5))
* **misc**: Support multi-windows for PWA, closes [lobehub#4334](https:/bentwnghk/lobe-chat/issues/4334) ([0284606](0284606))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer released size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
3 participants