Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions WebTranslator.sln
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator", "WebTranslator\WebTranslator\WebTranslator.csproj", "{9AA65209-2860-4BD1-989A-F4912ABE405D}"
#
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator", "WebTranslator\WebTranslator\WebTranslator.csproj", "{85FE8430-B64C-4A9F-965C-4A79701BE43E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator.Desktop", "WebTranslator\WebTranslator.Desktop\WebTranslator.Desktop.csproj", "{BD7C2129-75F3-4858-9F0D-84916C17C603}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator.Desktop", "WebTranslator\WebTranslator.Desktop\WebTranslator.Desktop.csproj", "{865770DA-1557-48D2-872A-E6962C0260CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator.Browser", "WebTranslator\WebTranslator.Browser\WebTranslator.Browser.csproj", "{7A0F981F-181B-40F9-B388-06319FAF84D2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator.Browser", "WebTranslator\WebTranslator.Browser\WebTranslator.Browser.csproj", "{D5A8ABF2-E3FB-4824-A825-578B2B2C3AA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTranslator.Tests", "WebTranslator\WebTranslator.Tests\WebTranslator.Tests.csproj", "{21A6E867-DD66-4EF6-BAD0-F9B45F733A19}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9AA65209-2860-4BD1-989A-F4912ABE405D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AA65209-2860-4BD1-989A-F4912ABE405D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AA65209-2860-4BD1-989A-F4912ABE405D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AA65209-2860-4BD1-989A-F4912ABE405D}.Release|Any CPU.Build.0 = Release|Any CPU
{BD7C2129-75F3-4858-9F0D-84916C17C603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD7C2129-75F3-4858-9F0D-84916C17C603}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD7C2129-75F3-4858-9F0D-84916C17C603}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD7C2129-75F3-4858-9F0D-84916C17C603}.Release|Any CPU.Build.0 = Release|Any CPU
{7A0F981F-181B-40F9-B388-06319FAF84D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A0F981F-181B-40F9-B388-06319FAF84D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A0F981F-181B-40F9-B388-06319FAF84D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A0F981F-181B-40F9-B388-06319FAF84D2}.Release|Any CPU.Build.0 = Release|Any CPU
{85FE8430-B64C-4A9F-965C-4A79701BE43E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85FE8430-B64C-4A9F-965C-4A79701BE43E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85FE8430-B64C-4A9F-965C-4A79701BE43E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85FE8430-B64C-4A9F-965C-4A79701BE43E}.Release|Any CPU.Build.0 = Release|Any CPU
{865770DA-1557-48D2-872A-E6962C0260CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{865770DA-1557-48D2-872A-E6962C0260CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{865770DA-1557-48D2-872A-E6962C0260CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{865770DA-1557-48D2-872A-E6962C0260CF}.Release|Any CPU.Build.0 = Release|Any CPU
{D5A8ABF2-E3FB-4824-A825-578B2B2C3AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5A8ABF2-E3FB-4824-A825-578B2B2C3AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5A8ABF2-E3FB-4824-A825-578B2B2C3AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5A8ABF2-E3FB-4824-A825-578B2B2C3AA2}.Release|Any CPU.Build.0 = Release|Any CPU
{21A6E867-DD66-4EF6-BAD0-F9B45F733A19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21A6E867-DD66-4EF6-BAD0-F9B45F733A19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21A6E867-DD66-4EF6-BAD0-F9B45F733A19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21A6E867-DD66-4EF6-BAD0-F9B45F733A19}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{85FE8430-B64C-4A9F-965C-4A79701BE43E} = {5A766051-8FB3-4A62-8C9F-51665F674DB2}
{21A6E867-DD66-4EF6-BAD0-F9B45F733A19} = {645D33B6-187A-4668-B87D-4E254956F033}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion WebTranslator/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>11.0.0-rc2.2</AvaloniaVersion>
<AvaloniaVersion>11.1.0-beta1</AvaloniaVersion>
</PropertyGroup>
</Project>
Binary file not shown.
6 changes: 3 additions & 3 deletions WebTranslator/WebTranslator.Browser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

[assembly: SupportedOSPlatform("browser")]

internal partial class Program
internal sealed partial class Program
{
private static async Task Main(string[] args) => await BuildAvaloniaApp()
.UseReactiveUI()
private static Task Main(string[] args) => BuildAvaloniaApp()
.With(new FontManagerOptions
{
FontFallbacks = new[]
Expand All @@ -22,6 +21,7 @@ private static async Task Main(string[] args) => await BuildAvaloniaApp()
}
}
})
.UseReactiveUI()
.StartBrowserAppAsync("out");

public static AppBuilder BuildAvaloniaApp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://0.0.0.0:5000",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/debug?browser={browserInspectUri}"
}
}
Expand Down
25 changes: 5 additions & 20 deletions WebTranslator/WebTranslator.Browser/WebTranslator.Browser.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>AppBundle\main.js</WasmMainJSPath>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-browser</TargetFramework>
<TrimMode>partial</TrimMode>
</PropertyGroup>

<ItemGroup>
<WasmExtraFilesToDeploy Include="AppBundle\**" />
<ProjectReference Include="..\WebTranslator\WebTranslator.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.6" />
<PackageReference Include="Avalonia.Browser" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-beta1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview1" />
<PackageReference Include="FluentIcons.Avalonia.Fluent" Version="1.1.234-ci" />
<PackageReference Include="Json.NET.Aot" Version="9.0.1" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\WebTranslator\WebTranslator.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Assets\" />
<PackageReference Include="Avalonia.Browser" Version="11.1.0-beta2"/>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
display: block;
}

.lowlight {
color: white;
font-size: 1.5rem;
display: block;
}

.purple {
color: #8b44ac;
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
<html>

<head>
<title>WebTranslator</title>
<title>WebTranslator.Browser</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/" />
<link rel="modulepreload" href="./main.js" />
<link rel="modulepreload" href="./dotnet.js" />
<link rel="modulepreload" href="./avalonia.js" />
<link rel="modulepreload" href="./_framework/dotnet.js" />
<link rel="modulepreload" href="./_framework/avalonia.js" />
<link rel="stylesheet" href="./app.css" />
</head>

<body style="margin: 0px; overflow: hidden">
<body style="margin: 0; overflow: hidden">
<div id="out">
<div id="avalonia-splash">
<div class="center">
<!-- <h1 class="center">Loading...</h1>-->
<h2 class="purple">
<span class="highlight">Loading..</span>
<br />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dotnet } from './dotnet.js'
import { dotnet } from './_framework/dotnet.js'

const is_browser = typeof window != "undefined";
if (!is_browser) throw new Error(`Expected to be running in a browser`);
Expand All @@ -10,4 +10,4 @@ const dotnetRuntime = await dotnet

const config = dotnetRuntime.getConfig();

await dotnetRuntime.runMainAndExit(config.mainAssemblyName, [window.location.search]);
await dotnetRuntime.runMain(config.mainAssemblyName, [window.location.search]);
3 changes: 1 addition & 2 deletions WebTranslator/WebTranslator.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace WebTranslator.Desktop;

class Program
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
Expand All @@ -18,7 +18,6 @@ public static void Main(string[] args) => BuildAvaloniaApp()
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
// .WithInterFont()
.With(new FontManagerOptions
{
FontFallbacks = new[]
Expand Down
17 changes: 6 additions & 11 deletions WebTranslator/WebTranslator.Desktop/WebTranslator.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
One for Windows with net8.0-windows TFM, one for MacOS with net8.0-macos and one with net8.0 TFM for Linux.-->
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<!--Public AOT-->
<PublishAot>true</PublishAot>
<ApplicationIcon>..\WebTranslator\Assets\translator.ico</ApplicationIcon>
</PropertyGroup>

<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.6" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-beta1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview1" />
<PackageReference Include="FluentIcons.Avalonia.Fluent" Version="1.1.234-ci" />
<PackageReference Include="Json.NET.Aot" Version="9.0.1" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<ProjectReference Include="..\WebTranslator\WebTranslator.csproj"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\WebTranslator\WebTranslator.csproj" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta2"/>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion WebTranslator/WebTranslator.Desktop/app.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embeded controls.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="WebTranslator.Desktop"/>

Expand Down
1 change: 1 addition & 0 deletions WebTranslator/WebTranslator.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
30 changes: 30 additions & 0 deletions WebTranslator/WebTranslator.Tests/TestFiles/AllFormat.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// 单双引号或无引号
key1: 'value1',
'key2': 'value2',
"key3": "value3",
"key4": 'value4',
'key5': "value5",
/* 多行字符串 */
'key6': 'too\nline',

key7: "really two

lines",

"key8": "three"
"line"
"tests",

"key10": "another \
multi-line \
string",
/*
* 重复键
*/
"key9": "end",
"key9": "conflict",
"key9": "...",
// 注: 上面的注释也属于这个 json 的一部分
// 这就是为什么它们没有报错
}
Loading