Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/0.3'
- Loading branch information
Showing
50 changed files
with
1,142 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29009.5 | ||
VisualStudioVersion = 16.0.29209.152 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Danmaku", "Danmaku\Danmaku.csproj", "{1FC2FA6B-6D9D-4D77-A175-EF41762512FD}" | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Danmaku", "Danmaku\Danmaku.csproj", "{D15E57FF-E4E0-4252-B862-88517FFB7156}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
Release-Linux32|Any CPU = Release-Linux32|Any CPU | ||
Release-Linux64|Any CPU = Release-Linux64|Any CPU | ||
Release-Win|Any CPU = Release-Win|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1FC2FA6B-6D9D-4D77-A175-EF41762512FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1FC2FA6B-6D9D-4D77-A175-EF41762512FD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1FC2FA6B-6D9D-4D77-A175-EF41762512FD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1FC2FA6B-6D9D-4D77-A175-EF41762512FD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Release-Linux32|Any CPU.ActiveCfg = Release-Linux32|Any CPU | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Release-Linux32|Any CPU.Build.0 = Release-Linux32|Any CPU | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Release-Linux64|Any CPU.ActiveCfg = Release-Linux64|x64 | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Release-Linux64|Any CPU.Build.0 = Release-Linux64|x64 | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Release-Win|Any CPU.ActiveCfg = Release-Win|Any CPU | ||
{D15E57FF-E4E0-4252-B862-88517FFB7156}.Release-Win|Any CPU.Build.0 = Release-Win|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {58C37507-935E-45D9-BAE9-DE527FF5817D} | ||
SolutionGuid = {123045BC-218E-445A-8A75-BB2EC747A128} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections.Generic; | ||
using System.Security.Claims; | ||
using System.Threading.Tasks; | ||
using Danmaku.Model; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authentication.Cookies; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Danmaku.Controllers | ||
{ | ||
|
||
public class AccountController : Controller | ||
{ | ||
private readonly Admin _admin; | ||
|
||
public AccountController() | ||
{ | ||
_admin = AppConfiguration.Config.Admin; | ||
} | ||
|
||
|
||
|
||
public ActionResult Login() | ||
{ | ||
return View(); | ||
} | ||
|
||
[HttpPost] | ||
public async Task<IActionResult> Login(string userName, string password, string returnUrl = null) | ||
{ | ||
ViewData["ReturnUrl"] = returnUrl; | ||
|
||
// Normally Identity handles sign in, but you can do it directly | ||
if (userName == _admin.User && password == _admin.Password) | ||
{ | ||
var claims = new List<Claim> | ||
{ | ||
new Claim("user", userName), | ||
new Claim("role", "Member") | ||
}; | ||
|
||
await HttpContext.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme, "user", "role"))); | ||
|
||
if (Url.IsLocalUrl(returnUrl)) | ||
{ | ||
return Redirect(returnUrl); | ||
} | ||
else | ||
{ | ||
return Redirect("/"); | ||
} | ||
} | ||
|
||
return View(); | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> Logout() | ||
{ | ||
await HttpContext.SignOutAsync(); | ||
return Redirect("/"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Danmaku.Utils.Dao; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Danmaku.Controllers.Base | ||
{ | ||
[ApiController] | ||
public class DanmakuDaoBaseController : Controller | ||
{ | ||
private protected readonly IDanmakuDao Dao; | ||
|
||
public DanmakuDaoBaseController(IDanmakuDao danmakuDao) | ||
{ | ||
Dao = danmakuDao; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Danmaku/Controllers/Dplayer/DanmakuList/DanmakuListController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Danmaku.Controllers.Base; | ||
using Danmaku.Utils.Dao; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Danmaku.Controllers.Dplayer.DanmakuList | ||
{ | ||
[Route("dplayer/danmakulist")] | ||
[Authorize] | ||
public class DanmakuListController : DanmakuDaoBaseController | ||
{ | ||
public DanmakuListController(IDanmakuDao danmakuDao) : base(danmakuDao) | ||
{ | ||
} | ||
|
||
|
||
public ActionResult Index() | ||
{ | ||
return View(Dao.DanmakuBaseQuery(1, 10)); | ||
} | ||
|
||
// [HttpPost] | ||
// public ActionResult Index(int page, int size = 10) | ||
// { | ||
// return View(Dao.DanmakuBaseQuery(page, size)); | ||
// } | ||
|
||
[HttpPost] | ||
public ActionResult Index(string vid) | ||
{ | ||
return View(Dao.DanmakuBasesQueryByVid(vid, 1, 10)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using Danmaku.Model; | ||
using Danmaku.Utils.BiliBili; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Danmaku.Controllers.Dplayer.V3 | ||
{ | ||
[Route("api/dplayer/v3")] | ||
[ApiController] | ||
public class BiliBiliController : ControllerBase | ||
{ | ||
private readonly IBiliBiliHelp _biliBili; | ||
|
||
public BiliBiliController(IBiliBiliHelp biliBiliHelp) | ||
{ | ||
_biliBili = biliBiliHelp; | ||
} | ||
|
||
// GET: api/dplayer/v3/bilibili | ||
[HttpGet("bilibili")] | ||
public string Get() | ||
{ | ||
var request = Request.Query; | ||
|
||
string[] date = request["date"]; | ||
var cid = request["cid"].ToString(); | ||
if (string.IsNullOrEmpty(cid)) | ||
{ | ||
var aid = request["aid"]; | ||
string p = request["p"]; | ||
p = string.IsNullOrEmpty(p) ? "1" : p; | ||
if (!int.TryParse(p, out var page)) return new DanmakuWebResult(1); | ||
cid = _biliBili.GetCid(aid, page).ToString(); | ||
} | ||
|
||
return String.IsNullOrWhiteSpace(cid) | ||
? new DanmakuWebResult(1) | ||
: date.Length == 0 | ||
? new DanmakuWebResult(_biliBili.GetBiDanmaku(cid)) | ||
: new DanmakuWebResult(_biliBili.GetBiDanmaku(cid, date)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Linq; | ||
using System.Net; | ||
using Danmaku.Controllers.Base; | ||
using Danmaku.Model; | ||
using Danmaku.Utils.Dao; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Danmaku.Controllers.Dplayer.V3 | ||
{ | ||
[Route("api/dplayer/v3")] | ||
[ApiController] | ||
public class DplayerController : DanmakuDaoBaseController | ||
{ | ||
public DplayerController(IDanmakuDao danmakuDao) : base(danmakuDao) | ||
{ | ||
} | ||
|
||
// GET: api/dplayer/v3/ | ||
[HttpGet] | ||
public string Get() | ||
{ | ||
string id = Request.Query["id"]; | ||
return string.IsNullOrEmpty(id) ? new DanmakuWebResult(1) : new DanmakuWebResult(Dao.DanmakuQuery(id)); | ||
} | ||
|
||
// POST: api/dplayer/v3/ | ||
[HttpPost] | ||
public string Post([FromBody] DanmakuDataInsert data) | ||
{ | ||
if (string.IsNullOrWhiteSpace(data.Id) || string.IsNullOrWhiteSpace(data.Text)) | ||
return new DanmakuWebResult(1); | ||
data.Ip = IPAddress.TryParse(Request.Headers["X-Real-IP"], out var ip) | ||
? ip | ||
: Request.HttpContext.Connection.RemoteIpAddress; | ||
data.Referer = Request.Headers["Referer"].FirstOrDefault(); | ||
|
||
var result = Dao.DanmakuInsert(data); | ||
return result == 0 ? new DanmakuWebResult(1) : new DanmakuWebResult(0); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.