Skip to content

feat: 支持 linux 下的 uri#1711

Draft
IsHPDuwu wants to merge 6 commits intoClassIsland:masterfrom
IsHPDuwu:chore/linux.uri
Draft

feat: 支持 linux 下的 uri#1711
IsHPDuwu wants to merge 6 commits intoClassIsland:masterfrom
IsHPDuwu:chore/linux.uri

Conversation

@IsHPDuwu
Copy link
Copy Markdown
Contributor

@IsHPDuwu IsHPDuwu commented Mar 15, 2026

这个 Pull Request 做了什么?

支持 linux 下的 uri

完成了 linux 下的 2 种实现方式

相关 Issue

fix #1710

检查清单

  • 我已经在本地测试过这个 PR,确保欲实现的功能或修复的问题能正常工作。

好吧是被 P 薅过来写着玩的()

手上没 Linux 环境只能看着写了)

code with github-copilot gpt-5.3-codex (实话实说 belike)

@IsHPDuwu IsHPDuwu requested review from a team and HelloWRC as code owners March 15, 2026 07:55
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown
Contributor

@pizeroLOL pizeroLOL left a comment

Choose a reason for hiding this comment

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

难评,有在linux下测试过吗(

Comment thread ClassIsland.Desktop/ClassIsland.Desktop.csproj Outdated
Comment thread ClassIsland/Helpers/ShortcutHelpers.cs
@IsHPDuwu IsHPDuwu requested a review from pizeroLOL March 15, 2026 09:21
@IsHPDuwu
Copy link
Copy Markdown
Contributor Author

难评,有在linux下测试过吗(

手上没 linux 环境,要不你测一下(?

@pizeroLOL
Copy link
Copy Markdown
Contributor

难评,有在linux下测试过吗(

手上没 linux 环境,要不你测一下(? )

等下周末(

@HelloWRC
Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@HelloWRC
Copy link
Copy Markdown
Member

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread platforms/ClassIsland.Platforms.Linux/Services/DesktopService.cs
Comment thread platforms/ClassIsland.Platforms.Linux/Services/DesktopService.cs Outdated
Comment thread platforms/ClassIsland.Platforms.Linux/Services/DesktopService.cs
Comment on lines +156 to +164
private static string? TryGetDefaultDesktopFileFromXdgMime()
{
if (!TryRunProcess("xdg-mime", $"query default {MimeType}", out var output))
{
return null;
}

return output?.Trim();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

为什么要动 xdg-mime,这东西不是应该用户自己改的吗

Copy link
Copy Markdown
Member

@HelloWRC HelloWRC left a comment

Choose a reason for hiding this comment

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

经过测试功能没有问题,但别忘了在应用设置和 oobe 页面中恢复被屏蔽的 Uri 相关选项的显示。

  • Image

    <!-- 注册 Url 协议 -->
    <controls3:SettingsExpander IconSource="{ci:FluentIconSource &#xEAB0;}"
    Header="注册 Url 协议"
    Description="允许第三方应用或网页通过 Url 协议 classisland:// 调用本应用的部分功能,详见帮助文档。">
    <controls3:SettingsExpander.IsVisible>
    <OnPlatform Default="False">
    <On Options="Windows" Content="True"/>
    </OnPlatform>
    </controls3:SettingsExpander.IsVisible>
    <controls3:SettingsExpander.Footer>
    <ToggleSwitch IsChecked="{Binding IsUrlSchemeRegistered, Source={x:Static abstraction:PlatformServices.DesktopService}, Mode=TwoWay}"/>
    </controls3:SettingsExpander.Footer>
    </controls3:SettingsExpander>

  • Image

    <MenuItem Icon="{controls:FluentIcon &#xE15F;}"
    Header="创建快捷换课图标"
    Click="MenuItemAddClassSwapShortcut_OnClick">
    <MenuItem.IsVisible>
    <OnPlatform Default="False">
    <On Options="Windows" Content="True" />
    </OnPlatform>
    </MenuItem.IsVisible>
    </MenuItem>

  • Image

    <CheckBox IsChecked="{Binding ViewModel.RegisterUrlScheme}">
    <CheckBox.IsVisible>
    <OnPlatform Default="False">
    <On Options="Windows" Content="True"/>
    </OnPlatform>
    </CheckBox.IsVisible>
    <ci:Thing IconSource="{ci:FluentIconSource &#xEAB0;}"
    Header="注册 Url 协议"
    Description="允许第三方应用或网页通过 Url 协议 classisland:// 调用本应用的部分功能,详见帮助文档。" />
    </CheckBox>


public static async Task CreateUriHandlerDesktopShortcutAsync(string path = "")
{
if (AppBase.Current.PackagingType == "deb")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

为什么这里的逻辑要绕过 deb 打包

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

deb 打包已经有系统级的注册流程了啊

这个 handler 是专门给不用 deb 安装的时候用的

@IsHPDuwu
Copy link
Copy Markdown
Contributor Author

已然恢复被屏蔽的 Uri 相关选项的显示在 ab5a42b /v

@IsHPDuwu IsHPDuwu marked this pull request as draft April 1, 2026 22:44
Copy link
Copy Markdown
Contributor Author

@IsHPDuwu IsHPDuwu left a comment

Choose a reason for hiding this comment

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

2026/04/02 06:41:10 | fail | ClassIsland.Views.WelcomeWindow | 无法创建快捷方式。
System.ArgumentException: The value cannot be an empty string. (Parameter 'path')
   at System.ArgumentException.ThrowNullOrEmptyException(String argument, String paramName)
   at System.IO.Directory.CreateDirectory(String path)
   at ClassIsland.Helpers.ShortcutHelpers.CreateFreedesktopShortcutAsync(String path)
   at ClassIsland.Views.WelcomeWindow.CreateShortcutsFreedesktop()
   at ClassIsland.Views.WelcomeWindow.CommandBindingFinishWizard_OnExecuted(Object sender, ExecutedRoutedEventArgs e)

貌似还存在一些问题,我周末看看

使用如下配置在 windows 平台下完成了 linux 平台的编译

PS D:\Documents\GitHub\ClassIsland> .\build.cmd PublishApp
PowerShell Desktop version 5.1.26100.7920
Microsoft (R) .NET SDK version 9.0.312

███╗   ██╗██╗   ██╗██╗  ██╗███████╗
████╗  ██║██║   ██║██║ ██╔╝██╔════╝
██╔██╗ ██║██║   ██║█████╔╝ █████╗  
██║╚██╗██║██║   ██║██╔═██╗ ██╔══╝  
██║ ╚████║╚██████╔╝██║  ██╗███████╗
╚═╝  ╚═══╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝

NUKE Execution Engine version 9.0.4 (Windows,.NETCoreApp,Version=v8.0)

OsName:
¬ linux
Arch:
¬ x64
Package:
¬ folder
BuildType:
¬ full
BuildName:
¬ chore_linux_uri_build_02

测试用 linux 环境为

        .-/+oossssoo+/-.               root@ishpduwu-VMware20-1
    `:+ssssssssssssssssss+:`           ------------------------
  -+ssssssssssssssssssyyssss+-         OS: Ubuntu 24.04.4 LTS x86_64
.ossssssssssssssssssdMMMNysssso.       Host: VMware20,1 None

/ssssssssssshdmmNNmmyNMMMMhssssss/ Kernel: 6.17.0-19-generic
+ssssssssshmydMMMMMMMNddddyssssssss+ Uptime: 1 hour, 42 mins
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Packages: 1676 (dpkg), 10 (snap)
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Shell: bash 5.2.21
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Resolution: 1280x800
ossyNMMMNyMMhsssssssssssssshmmmhssssssso DE: GNOME 46.0
ossyNMMMNyMMhsssssssssssssshmmmhssssssso WM: Mutter
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ WM Theme: Adwaita
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Theme: Yaru [GTK2/3]
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Icons: Yaru [GTK2/3]
+sssssssssdmydMMMMMMMMddddyssssssss+ Terminal: gnome-terminal
/ssssssssssshdmNNNNmyNMMMMhssssss/ CPU: Intel i7-8565U (4) @ 1.992GHz
.ossssssssssssssssssdMMMNysssso. GPU: 00:0f.0 VMware SVGA II Adapter
-+sssssssssssssssssyyyssss+- Memory: 1456MiB / 3867MiB
:+ssssssssssssssssss+:
.-/+oossssoo+/-.

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.

feat: 支持 linux 下的 uri

4 participants