更新客户端渲染,更新了壳
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace YMhut.Box.Mobile;
|
||||
|
||||
public sealed class App : Application
|
||||
{
|
||||
public App(IServiceProvider services)
|
||||
{
|
||||
UserAppTheme = AppTheme.Unspecified;
|
||||
MainPage = new AppShell(services);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using YMhut.Box.Mobile.Views;
|
||||
|
||||
namespace YMhut.Box.Mobile;
|
||||
|
||||
public sealed class AppShell : Shell
|
||||
{
|
||||
public AppShell(IServiceProvider services)
|
||||
{
|
||||
Items.Add(new FlyoutItem
|
||||
{
|
||||
Title = "Home",
|
||||
Items = { new ShellContent { Title = "Home", Content = services.GetRequiredService<HomePage>() } }
|
||||
});
|
||||
Items.Add(new FlyoutItem
|
||||
{
|
||||
Title = "Toolbox",
|
||||
Items = { new ShellContent { Title = "Toolbox", Content = services.GetRequiredService<ToolboxPage>() } }
|
||||
});
|
||||
Items.Add(new FlyoutItem
|
||||
{
|
||||
Title = "Plugins",
|
||||
Items = { new ShellContent { Title = "Plugins", Content = services.GetRequiredService<PluginsPage>() } }
|
||||
});
|
||||
Items.Add(new FlyoutItem
|
||||
{
|
||||
Title = "Logs",
|
||||
Items = { new ShellContent { Title = "Logs", Content = services.GetRequiredService<LogsPage>() } }
|
||||
});
|
||||
Items.Add(new FlyoutItem
|
||||
{
|
||||
Title = "Settings",
|
||||
Items = { new ShellContent { Title = "Settings", Content = services.GetRequiredService<SettingsPage>() } }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using YMhut.Box.Core.App;
|
||||
using YMhut.Box.Core.Logging;
|
||||
using YMhut.Box.Core.Platform;
|
||||
using YMhut.Box.Core.Settings;
|
||||
using YMhut.Box.Core.Tools;
|
||||
using YMhut.Box.Mobile.Views;
|
||||
|
||||
namespace YMhut.Box.Mobile;
|
||||
|
||||
public static class MauiProgram
|
||||
{
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.ConfigureFonts(fonts => fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"));
|
||||
|
||||
var paths = AppPaths.ForCurrentUser(Path.Combine(FileSystem.AppDataDirectory, "YMhutBoxMobile"));
|
||||
builder.Services.AddSingleton(paths);
|
||||
builder.Services.AddSingleton(new AppSettingsStore(paths.Root));
|
||||
builder.Services.AddSingleton<ISettingsService, AppSettingsService>();
|
||||
builder.Services.AddSingleton<ILogService>(provider => new ResilientLogService(
|
||||
new JsonFileLogService(provider.GetRequiredService<AppPaths>()),
|
||||
provider.GetRequiredService<AppPaths>()));
|
||||
builder.Services.AddSingleton<IPlatformCapabilities, MobilePlatformCapabilities>();
|
||||
builder.Services.AddSingleton(_ => new ToolCatalog(ToolCatalog.DefaultModules()));
|
||||
builder.Services.AddSingleton<HomePage>();
|
||||
builder.Services.AddSingleton<ToolboxPage>();
|
||||
builder.Services.AddSingleton<PluginsPage>();
|
||||
builder.Services.AddSingleton<LogsPage>();
|
||||
builder.Services.AddSingleton<SettingsPage>();
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using YMhut.Box.Core.Platform;
|
||||
|
||||
namespace YMhut.Box.Mobile;
|
||||
|
||||
public sealed class MobilePlatformCapabilities : IPlatformCapabilities
|
||||
{
|
||||
public string PlatformName => DeviceInfo.Platform.ToString();
|
||||
|
||||
public bool SupportsDesktopProcesses => false;
|
||||
|
||||
public bool SupportsTauriPluginHost => false;
|
||||
|
||||
public bool SupportsShellRuntime => false;
|
||||
|
||||
public bool SupportsTray => false;
|
||||
|
||||
public bool SupportsAdministratorLaunch => false;
|
||||
|
||||
public bool SupportsNativeWebView2 => false;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using YMhut.Box.Core.Platform;
|
||||
|
||||
namespace YMhut.Box.Mobile.Views;
|
||||
|
||||
public sealed class HomePage : ContentPage
|
||||
{
|
||||
public HomePage(IPlatformCapabilities capabilities)
|
||||
{
|
||||
Title = "YMhut Box";
|
||||
Content = new VerticalStackLayout
|
||||
{
|
||||
Padding = 24,
|
||||
Spacing = 12,
|
||||
Children =
|
||||
{
|
||||
new Label { Text = "YMhut Box Mobile", FontSize = 26, FontAttributes = FontAttributes.Bold },
|
||||
new Label { Text = $"Platform: {capabilities.PlatformName}" },
|
||||
new Label { Text = "Core-sync mobile shell for toolbox, plugins, logs, and settings." },
|
||||
new Label { Text = "Windows-only desktop features are shown as unsupported instead of being hidden." }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using YMhut.Box.Core.Logging;
|
||||
|
||||
namespace YMhut.Box.Mobile.Views;
|
||||
|
||||
public sealed class LogsPage : ContentPage
|
||||
{
|
||||
private readonly ILogService _logService;
|
||||
private readonly CollectionView _list = new();
|
||||
|
||||
public LogsPage(ILogService logService)
|
||||
{
|
||||
_logService = logService;
|
||||
Title = "Logs";
|
||||
_list.ItemTemplate = new DataTemplate(() =>
|
||||
{
|
||||
var label = new Label { Margin = new Thickness(16, 8), FontSize = 13 };
|
||||
label.SetBinding(Label.TextProperty, ".");
|
||||
return label;
|
||||
});
|
||||
Content = _list;
|
||||
}
|
||||
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
var logs = await _logService.ReadAsync(take: 100);
|
||||
_list.ItemsSource = logs.Select(item => $"{item.Timestamp:g} [{item.Level}] {item.Category}: {item.Message}").ToArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using YMhut.Box.Core.Platform;
|
||||
|
||||
namespace YMhut.Box.Mobile.Views;
|
||||
|
||||
public sealed class PluginsPage : ContentPage
|
||||
{
|
||||
public PluginsPage(IPlatformCapabilities capabilities)
|
||||
{
|
||||
Title = "Plugins";
|
||||
Content = new VerticalStackLayout
|
||||
{
|
||||
Padding = 24,
|
||||
Spacing = 12,
|
||||
Children =
|
||||
{
|
||||
new Label { Text = "Plugin Center", FontSize = 22, FontAttributes = FontAttributes.Bold },
|
||||
new Label { Text = capabilities.SupportsTauriPluginHost ? "Tauri plugin host is available." : "Tauri plugin processes are desktop-only in v1." },
|
||||
new Label { Text = "Mobile v1 reads plugin metadata and settings, while script execution remains on desktop." }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using YMhut.Box.Core.Settings;
|
||||
|
||||
namespace YMhut.Box.Mobile.Views;
|
||||
|
||||
public sealed class SettingsPage : ContentPage
|
||||
{
|
||||
public SettingsPage(ISettingsService settingsService)
|
||||
{
|
||||
Title = "Settings";
|
||||
Content = new VerticalStackLayout
|
||||
{
|
||||
Padding = 24,
|
||||
Spacing = 12,
|
||||
Children =
|
||||
{
|
||||
new Label { Text = "Settings", FontSize = 22, FontAttributes = FontAttributes.Bold },
|
||||
new Label { Text = $"Language: {settingsService.Current.Language}" },
|
||||
new Label { Text = $"Plugins enabled: {settingsService.Current.PluginsEnabled}" },
|
||||
new Label { Text = "Mobile v1 keeps settings readable and portable; desktop-only switches remain no-op here." }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using YMhut.Box.Core.Platform;
|
||||
using YMhut.Box.Core.Tools;
|
||||
|
||||
namespace YMhut.Box.Mobile.Views;
|
||||
|
||||
public sealed class ToolboxPage : ContentPage
|
||||
{
|
||||
public ToolboxPage(ToolCatalog catalog, IPlatformCapabilities capabilities)
|
||||
{
|
||||
Title = "Toolbox";
|
||||
var modules = catalog.Modules
|
||||
.OrderBy(module => module.Metadata.Category)
|
||||
.ThenBy(module => module.Metadata.Name)
|
||||
.Select(module => $"{module.Metadata.Name} · {module.Metadata.Category}{(module.Metadata.OfflineCapable ? "" : " · network")}")
|
||||
.ToArray();
|
||||
|
||||
Content = new CollectionView
|
||||
{
|
||||
EmptyView = "No tools available.",
|
||||
ItemsSource = modules,
|
||||
Header = new Label
|
||||
{
|
||||
Text = capabilities.SupportsShellRuntime ? "Tools can execute locally." : "Desktop-only execution is unavailable on this mobile shell.",
|
||||
Margin = new Thickness(16),
|
||||
FontAttributes = FontAttributes.Bold
|
||||
},
|
||||
ItemTemplate = new DataTemplate(() =>
|
||||
{
|
||||
var label = new Label { Margin = new Thickness(16, 10), FontSize = 15 };
|
||||
label.SetBinding(Label.TextProperty, ".");
|
||||
return label;
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst;net10.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>YMhut.Box.Mobile</RootNamespace>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SingleProject>true</SingleProject>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationTitle>YMhut Box Mobile</ApplicationTitle>
|
||||
<ApplicationId>com.ymhut.box.mobile</ApplicationId>
|
||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||
<ApplicationVersion>1</ApplicationVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="10.0.9" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\YMhut.Box.Core\YMhut.Box.Core.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user