Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit aa48395

Browse files
authored
feat(TUpload): 新增 TUpload 组件 (#309)
2 parents 8d174c5 + 48434e5 commit aa48395

22 files changed

Lines changed: 1539 additions & 28 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ "master" ]
16+
branches: [ "main" ]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ "master" ]
19+
branches: [ "main" ]
2020
schedule:
2121
- cron: '44 21 * * 5'
2222

.github/workflows/deploy-webassembl-artifact.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy to Artifact
33
# Run workflow on every push to the master branch
44
on:
55
push:
6-
branches: [ master ]
6+
branches: [ main ]
77

88
jobs:
99
Deploy-Artifact:

.github/workflows/draft-release-note.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
# branches to consider in the event; optional, defaults to all
66
branches:
7-
- master
7+
- [main]
88
# pull_request event is required only for autolabeler
99
pull_request:
1010
# Only following types are handled by the action, but one can default to all as well

.github/workflows/git-pages-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy to GitHub Pages
33
# Run workflow on every push to the master branch
44
on:
55
push:
6-
branches: [ master ]
6+
branches: [ main ]
77

88
jobs:
99
deploy-to-github-pages:

.github/workflows/git-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Git Version
44
on:
55
push:
66
branches:
7-
- master
7+
- [main]
88

99
jobs:
1010
lint:

.github/workflows/pr-commit-label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: PR conventional labeled
22

33
on:
44
pull_request:
5-
branches: [master]
5+
branches: [main]
66
types:
77
[opened, reopened, labeled, unlabeled]
88

.github/workflows/pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ env:
66

77
on:
88
push:
9-
branches: [ "master" ]
9+
branches: [ "main" ]
1010
pull_request:
11-
branches: [ "master" ]
11+
branches: [ "main" ]
1212
jobs:
1313
Codacy:
1414
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.user
1010
*.userosscache
1111
*.sln.docstates
12+
[Uu]pload
1213

1314
# User-specific files (MonoDevelop/Xamarin Studio)
1415
*.userprefs
@@ -362,4 +363,4 @@ MigrationBackup/
362363
FodyWeavers.xsd
363364
*.pptx
364365
*.vsdx
365-
node_modules
366+
node_modules
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Microsoft.AspNetCore.Components.Forms;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace TDesign.Docs.ServerSide.Controllers;
5+
[ApiController]
6+
[Route("api/[controller]")]
7+
public class UploadController : ControllerBase
8+
{
9+
[HttpPost("file")]
10+
public async Task<IActionResult> PostAsync([FromForm] IFormCollection form)
11+
{
12+
var savedPath = Path.Combine(Directory.GetCurrentDirectory(), "upload");
13+
14+
if ( !Directory.Exists(savedPath) )
15+
{
16+
Directory.CreateDirectory(savedPath);
17+
}
18+
19+
foreach ( var file in form.Files )
20+
{
21+
var generateFileName = string.Concat(DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"), Path.GetExtension(file.FileName));
22+
var serverFilePath = Path.Combine(savedPath, generateFileName);
23+
24+
using var fileStream = new FileStream(serverFilePath, FileMode.CreateNew);
25+
await file.OpenReadStream().CopyToAsync(fileStream);
26+
}
27+
28+
return Ok();
29+
}
30+
}

doc/TDesign.Docs.ServerSide/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
builder.Services.AddRazorPages();
77
builder.Services.AddServerSideBlazor();
88
builder.Services.AddTDesign();
9+
builder.Services.AddControllers();
910
builder.Services.AddScoped<HttpClient>(hc => new() { BaseAddress = new("http://localhost:5067") });
1011
var app = builder.Build();
1112

@@ -26,5 +27,5 @@
2627
app.MapRazorPages();
2728
app.MapBlazorHub();
2829
app.MapFallbackToPage("/_Host");
29-
30+
app.MapControllers();
3031
app.Run();

0 commit comments

Comments
 (0)