diff --git a/CodePlay.Web/CodePlay.Web.csproj b/CodePlay.Web/CodePlay.Web.csproj
deleted file mode 100644
index 54cf967..0000000
--- a/CodePlay.Web/CodePlay.Web.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- net8.0
- enable
- enable
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CodePlay.Web/CodePlay.Web.http b/CodePlay.Web/CodePlay.Web.http
deleted file mode 100644
index 831135e..0000000
--- a/CodePlay.Web/CodePlay.Web.http
+++ /dev/null
@@ -1,6 +0,0 @@
-@CodePlay.Web_HostAddress = http://localhost:5014
-
-GET {{CodePlay.Web_HostAddress}}/weatherforecast/
-Accept: application/json
-
-###
diff --git a/CodePlay.Web/Controllers/ConversionController.cs b/CodePlay.Web/Controllers/ConversionController.cs
deleted file mode 100644
index 90fde82..0000000
--- a/CodePlay.Web/Controllers/ConversionController.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CodePlay.Core.Models;
-using CodePlay.Core.Common;
-using CodePlay.Core.Services;
-
-namespace CodePlay.Web.Controllers;
-
-///
-/// 代码转换控制器
-///
-[ApiController]
-[Route("api/[controller]")]
-public class ConversionController : ControllerBase
-{
- private readonly ConversionService _conversionService;
- private readonly ILogger _logger;
-
- public ConversionController(
- ConversionService conversionService,
- ILogger logger)
- {
- _conversionService = conversionService;
- _logger = logger;
- }
-
- ///
- /// 执行代码转换
- ///
- /// 转换请求
- /// 取消令牌
- /// 转换结果
- [HttpPost]
- [ProducesResponseType(typeof(ConversionResult), StatusCodes.Status200OK)]
- [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
- [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
- public async Task> ConvertAsync(
- [FromBody] ConversionRequest request,
- CancellationToken cancellationToken = default)
- {
- try
- {
- // 验证请求
- if (string.IsNullOrWhiteSpace(request.SourceCode))
- {
- return BadRequest(new ProblemDetails
- {
- Title = "Invalid Request",
- Detail = "Source code is required",
- Status = 400
- });
- }
-
- if (request.SourceLanguage == LanguageType.None ||
- request.TargetLanguage == LanguageType.None)
- {
- return BadRequest(new ProblemDetails
- {
- Title = "Invalid Request",
- Detail = "Source and target languages must be specified",
- Status = 400
- });
- }
-
- if (request.SourceLanguage == request.TargetLanguage)
- {
- return BadRequest(new ProblemDetails
- {
- Title = "Invalid Request",
- Detail = "Source and target languages must be different",
- Status = 400
- });
- }
-
- if (request.ValidationRounds < 1 || request.ValidationRounds > 3)
- {
- return BadRequest(new ProblemDetails
- {
- Title = "Invalid Request",
- Detail = "Validation rounds must be between 1 and 3",
- Status = 400
- });
- }
-
- _logger.LogInformation(
- "Starting conversion from {SourceLanguage} to {TargetLanguage}",
- request.SourceLanguage,
- request.TargetLanguage);
-
- // 执行转换
- var result = await _conversionService.ConvertAsync(request, cancellationToken);
-
- if (result.Success)
- {
- _logger.LogInformation(
- "Conversion completed successfully. Lines: {Lines}, Classes: {Classes}, Methods: {Methods}",
- result.Report?.LinesConverted,
- result.Report?.ClassesConverted,
- result.Report?.MethodsConverted);
-
- return Ok(result);
- }
- else
- {
- _logger.LogWarning(
- "Conversion failed: {Error}",
- result.ErrorMessage);
-
- return StatusCode(500, new ProblemDetails
- {
- Title = "Conversion Failed",
- Detail = result.ErrorMessage,
- Status = 500
- });
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Unexpected error during conversion");
-
- return StatusCode(500, new ProblemDetails
- {
- Title = "Internal Server Error",
- Detail = "An unexpected error occurred during conversion",
- Status = 500
- });
- }
- }
-
- ///
- /// 获取支持的语言转换列表
- ///
- /// 支持的语言对列表
- [HttpGet("supported")]
- [ProducesResponseType(typeof(List), StatusCodes.Status200OK)]
- public ActionResult> GetSupportedConversions()
- {
- var supported = _conversionService.GetSupportedConversions()
- .Select(p => new LanguagePairDto
- {
- SourceLanguage = p.Source.ToString(),
- TargetLanguage = p.Target.ToString(),
- Supported = true
- })
- .ToList();
-
- return Ok(supported);
- }
-
- ///
- /// 检查指定的语言转换是否支持
- ///
- [HttpGet("supported/{source}/{target}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult IsConversionSupported(
- string source,
- string target)
- {
- if (!Enum.TryParse(source, out var sourceLang) ||
- !Enum.TryParse(target, out var targetLang))
- {
- return BadRequest("Invalid language type");
- }
-
- var isSupported = _conversionService.IsConversionSupported(sourceLang, targetLang);
-
- if (isSupported)
- {
- return Ok(true);
- }
- else
- {
- return NotFound("Conversion not supported");
- }
- }
-}
-
-///
-/// 语言对 DTO
-///
-public class LanguagePairDto
-{
- ///
- /// 源语言
- ///
- public string SourceLanguage { get; set; } = string.Empty;
-
- ///
- /// 目标语言
- ///
- public string TargetLanguage { get; set; } = string.Empty;
-
- ///
- /// 是否支持
- ///
- public bool Supported { get; set; }
-}
diff --git a/CodePlay.Web/Controllers/WeatherForecastController.cs b/CodePlay.Web/Controllers/WeatherForecastController.cs
deleted file mode 100644
index dfece4c..0000000
--- a/CodePlay.Web/Controllers/WeatherForecastController.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-
-namespace CodePlay.Web.Controllers;
-
-[ApiController]
-[Route("[controller]")]
-public class WeatherForecastController : ControllerBase
-{
- private static readonly string[] Summaries = new[]
- {
- "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
- };
-
- private readonly ILogger _logger;
-
- public WeatherForecastController(ILogger logger)
- {
- _logger = logger;
- }
-
- [HttpGet(Name = "GetWeatherForecast")]
- public IEnumerable Get()
- {
- return Enumerable.Range(1, 5).Select(index => new WeatherForecast
- {
- Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
- TemperatureC = Random.Shared.Next(-20, 55),
- Summary = Summaries[Random.Shared.Next(Summaries.Length)]
- })
- .ToArray();
- }
-}
diff --git a/CodePlay.Web/Program.cs b/CodePlay.Web/Program.cs
deleted file mode 100644
index fdd216c..0000000
--- a/CodePlay.Web/Program.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using CodePlay.Core.Services;
-
-var builder = WebApplication.CreateBuilder(args);
-
-// Add services to the container.
-
-builder.Services.AddControllers();
-builder.Services.AddSingleton();
-builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen();
-
-var app = builder.Build();
-
-// Configure the HTTP request pipeline.
-if (app.Environment.IsDevelopment())
-{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
-
-app.UseHttpsRedirection();
-
-app.UseAuthorization();
-
-app.MapControllers();
-
-app.Run();
diff --git a/CodePlay.Web/Properties/launchSettings.json b/CodePlay.Web/Properties/launchSettings.json
deleted file mode 100644
index 5c71099..0000000
--- a/CodePlay.Web/Properties/launchSettings.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:26925",
- "sslPort": 44339
- }
- },
- "profiles": {
- "http": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "http://localhost:5014",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "https": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "https://localhost:7184;http://localhost:5014",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- }
- }
-}
diff --git a/CodePlay.Web/WeatherForecast.cs b/CodePlay.Web/WeatherForecast.cs
deleted file mode 100644
index 64b59c6..0000000
--- a/CodePlay.Web/WeatherForecast.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace CodePlay.Web;
-
-public class WeatherForecast
-{
- public DateOnly Date { get; set; }
-
- public int TemperatureC { get; set; }
-
- public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
-
- public string? Summary { get; set; }
-}
diff --git a/CodePlay.Web/appsettings.Development.json b/CodePlay.Web/appsettings.Development.json
deleted file mode 100644
index ff66ba6..0000000
--- a/CodePlay.Web/appsettings.Development.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- }
-}
diff --git a/CodePlay.Web/appsettings.json b/CodePlay.Web/appsettings.json
deleted file mode 100644
index 4d56694..0000000
--- a/CodePlay.Web/appsettings.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- },
- "AllowedHosts": "*"
-}
diff --git a/CodePlay.Web/index.html b/CodePlay.Web/index.html
new file mode 100644
index 0000000..82e41cc
--- /dev/null
+++ b/CodePlay.Web/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ CodePlay - 代码转换平台
+
+
+
+
+
+
diff --git a/CodePlay.Web/package.json b/CodePlay.Web/package.json
new file mode 100644
index 0000000..b393d1d
--- /dev/null
+++ b/CodePlay.Web/package.json
@@ -0,0 +1,25 @@
+{
+ "name": "codeplay-web",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vue-tsc && vite build",
+ "preview": "vite preview"
+ },
+ "dependencies": {
+ "vue": "^3.4.0",
+ "vue-router": "^4.2.0",
+ "pinia": "^2.1.0",
+ "axios": "^1.6.0",
+ "element-plus": "^2.4.0"
+ },
+ "devDependencies": {
+ "@vitejs/plugin-vue": "^5.0.0",
+ "typescript": "^5.3.0",
+ "vite": "^5.0.0",
+ "vue-tsc": "^1.8.0",
+ "@types/node": "^20.10.0"
+ }
+}
diff --git a/CodePlay.Web/src/App.vue b/CodePlay.Web/src/App.vue
new file mode 100644
index 0000000..2e56137
--- /dev/null
+++ b/CodePlay.Web/src/App.vue
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
diff --git a/CodePlay.Web/src/main.ts b/CodePlay.Web/src/main.ts
new file mode 100644
index 0000000..fd1d074
--- /dev/null
+++ b/CodePlay.Web/src/main.ts
@@ -0,0 +1,15 @@
+import { createApp } from 'vue'
+import { createPinia } from 'pinia'
+import ElementPlus from 'element-plus'
+import 'element-plus/dist/index.css'
+import router from './router'
+import App from './App.vue'
+
+const app = createApp(App)
+const pinia = createPinia()
+
+app.use(pinia)
+app.use(router)
+app.use(ElementPlus)
+
+app.mount('#app')
diff --git a/CodePlay.Web/src/router/index.ts b/CodePlay.Web/src/router/index.ts
new file mode 100644
index 0000000..d8f2351
--- /dev/null
+++ b/CodePlay.Web/src/router/index.ts
@@ -0,0 +1,15 @@
+import { createRouter, createWebHistory } from 'vue-router'
+import Converter from '@/views/Converter.vue'
+
+const router = createRouter({
+ history: createWebHistory(),
+ routes: [
+ {
+ path: '/',
+ name: 'Converter',
+ component: Converter
+ }
+ ]
+})
+
+export default router
diff --git a/CodePlay.Web/src/views/Converter.vue b/CodePlay.Web/src/views/Converter.vue
new file mode 100644
index 0000000..9ed8b44
--- /dev/null
+++ b/CodePlay.Web/src/views/Converter.vue
@@ -0,0 +1,318 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 处理中
+
+
+
+
+
+
+
+
+
+ 转换行数:{{ conversionResult.report?.linesConverted }} |
+ 类数量:{{ conversionResult.report?.classesConverted }} |
+ 方法数量:{{ conversionResult.report?.methodsConverted }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 转换
+
+ 清除
+
+ 复制结果
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
TODO 列表
+
+ -
+ {{ todo.description }}
+ 原因:{{ todo.whyNotDirect }}
+ 建议:{{ todo.recommendedAlternative }}
+
+
+
+
+
+
问题列表
+
+ -
+ {{ issue.description }}
+ 建议:{{ issue.suggestion }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CodePlay.Web/tsconfig.json b/CodePlay.Web/tsconfig.json
new file mode 100644
index 0000000..964ccad
--- /dev/null
+++ b/CodePlay.Web/tsconfig.json
@@ -0,0 +1,25 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "module": "ESNext",
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "skipLibCheck": true,
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "preserve",
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true,
+ "baseUrl": ".",
+ "paths": {
+ "@/*": ["src/*"]
+ }
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
+ "references": [{ "path": "./tsconfig.node.json" }]
+}
diff --git a/CodePlay.Web/tsconfig.node.json b/CodePlay.Web/tsconfig.node.json
new file mode 100644
index 0000000..42872c5
--- /dev/null
+++ b/CodePlay.Web/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "compilerOptions": {
+ "composite": true,
+ "skipLibCheck": true,
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "allowSyntheticDefaultImports": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/CodePlay.Web/vite.config.ts b/CodePlay.Web/vite.config.ts
new file mode 100644
index 0000000..04cfb15
--- /dev/null
+++ b/CodePlay.Web/vite.config.ts
@@ -0,0 +1,21 @@
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import path from 'path'
+
+export default defineConfig({
+ plugins: [vue()],
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src')
+ }
+ },
+ server: {
+ port: 3000,
+ proxy: {
+ '/api': {
+ target: 'http://localhost:5000',
+ changeOrigin: true
+ }
+ }
+ }
+})
diff --git a/CodePlay.WebUI/CodePlay.WebUI.csproj b/CodePlay.WebUI/CodePlay.WebUI.csproj
index 8e1816f..79a95f7 100644
--- a/CodePlay.WebUI/CodePlay.WebUI.csproj
+++ b/CodePlay.WebUI/CodePlay.WebUI.csproj
@@ -4,6 +4,10 @@
+
+
+
+
net8.0
enable
diff --git a/CodePlay.WebUI/Program.cs b/CodePlay.WebUI/Program.cs
index c40593f..97080a0 100644
--- a/CodePlay.WebUI/Program.cs
+++ b/CodePlay.WebUI/Program.cs
@@ -1,5 +1,6 @@
using CodePlay.WebUI.Components;
using CodePlay.Core.Services;
+using Known.Extensions;
var builder = WebApplication.CreateBuilder(args);
@@ -10,6 +11,9 @@ builder.Services.AddRazorComponents()
// 注册核心转换服务
builder.Services.AddSingleton();
+// 添加 Known 服务
+builder.Services.AddKnown();
+
var app = builder.Build();
// Configure the HTTP request pipeline.
diff --git a/TestFile.cs b/TestFile.cs
deleted file mode 100644
index e605130..0000000
--- a/TestFile.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace TestApp
-{
- public class Person
- {
- public string Name { get; set; }
- public int Age { get; set; }
-
- public void SayHello()
- {
- Console.WriteLine($"Hello, my name is {Name}");
- }
- }
-}
diff --git a/TestFile.java b/TestFile.java
deleted file mode 100644
index d8830db..0000000
--- a/TestFile.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package TestApp
-;
-
-TestApp
-public class Person
- {
- private string Name;
- public string getName() { return Name; }
- public void setName(string value) { this.Name = value; }
- private int Age;
- public int getAge() { return Age; }
- public void setAge(int value) { this.Age = value; }
-
- public void SayHello()
- {
- Console.WriteLine($"Hello, my name is {Name}");
- }
- }
-{
- private string Name;
- public string getName() { return Name; }
- public void setName(string value) { this.Name = value; }
- private int Age;
- public int getAge() { return Age; }
- public void setAge(int value) { this.Age = value; }
- public void SayHello()
- {
- Console.WriteLine($"Hello, my name is {Name}");
- }
-
-}
-