diff --git a/BililiveRecorder.Web.Schemas/RecorderMutation.cs b/BililiveRecorder.Web.Schemas/RecorderMutation.cs index 1815cbf..243105e 100644 --- a/BililiveRecorder.Web.Schemas/RecorderMutation.cs +++ b/BililiveRecorder.Web.Schemas/RecorderMutation.cs @@ -30,6 +30,15 @@ namespace BililiveRecorder.Web.Schemas var roomid = context.GetArgument("roomId"); var enabled = context.GetArgument("autoRecord"); + if (roomid <= 0) + { + context.Errors.Add(new ExecutionError("Roomid out of range") + { + Code = "BREC_ROOMID_OUT_OF_RANGE" + }); + return null; + } + var room = this.recorder.Rooms.FirstOrDefault(x => x.RoomConfig.RoomId == roomid || x.ShortId == roomid); if (room is not null) diff --git a/BililiveRecorder.Web.Schemas/RecorderQuery.cs b/BililiveRecorder.Web.Schemas/RecorderQuery.cs index 1e26d54..f0fb7c8 100644 --- a/BililiveRecorder.Web.Schemas/RecorderQuery.cs +++ b/BililiveRecorder.Web.Schemas/RecorderQuery.cs @@ -21,6 +21,8 @@ namespace BililiveRecorder.Web.Schemas private void SetupFields() { + this.Field("version", resolve: context => RecorderVersion.Instance); + this.Field("config", resolve: context => this.recorder.Config.Global); this.Field("defaultConfig", resolve: context => DefaultConfig.Instance); diff --git a/BililiveRecorder.Web.Schemas/Types/RecorderVersion.cs b/BililiveRecorder.Web.Schemas/Types/RecorderVersion.cs new file mode 100644 index 0000000..db03a7c --- /dev/null +++ b/BililiveRecorder.Web.Schemas/Types/RecorderVersion.cs @@ -0,0 +1,41 @@ +namespace BililiveRecorder.Web.Schemas.Types +{ + public class RecorderVersion + { + internal static readonly RecorderVersion Instance = new(); + + public string Major { get; } = GitVersionInformation.Major; + public string Minor { get; } = GitVersionInformation.Minor; + public string Patch { get; } = GitVersionInformation.Patch; + public string PreReleaseTag { get; } = GitVersionInformation.PreReleaseTag; + public string PreReleaseTagWithDash { get; } = GitVersionInformation.PreReleaseTagWithDash; + public string PreReleaseLabel { get; } = GitVersionInformation.PreReleaseLabel; + public string PreReleaseLabelWithDash { get; } = GitVersionInformation.PreReleaseLabelWithDash; + public string PreReleaseNumber { get; } = GitVersionInformation.PreReleaseNumber; + public string WeightedPreReleaseNumber { get; } = GitVersionInformation.WeightedPreReleaseNumber; + public string BuildMetaData { get; } = GitVersionInformation.BuildMetaData; + public string BuildMetaDataPadded { get; } = GitVersionInformation.BuildMetaDataPadded; + public string FullBuildMetaData { get; } = GitVersionInformation.FullBuildMetaData; + public string MajorMinorPatch { get; } = GitVersionInformation.MajorMinorPatch; + public string SemVer { get; } = GitVersionInformation.SemVer; + public string LegacySemVer { get; } = GitVersionInformation.LegacySemVer; + public string LegacySemVerPadded { get; } = GitVersionInformation.LegacySemVerPadded; + public string AssemblySemVer { get; } = GitVersionInformation.AssemblySemVer; + public string AssemblySemFileVer { get; } = GitVersionInformation.AssemblySemFileVer; + public string FullSemVer { get; } = GitVersionInformation.FullSemVer; + public string InformationalVersion { get; } = GitVersionInformation.InformationalVersion; + public string BranchName { get; } = GitVersionInformation.BranchName; + public string EscapedBranchName { get; } = GitVersionInformation.EscapedBranchName; + public string Sha { get; } = GitVersionInformation.Sha; + public string ShortSha { get; } = GitVersionInformation.ShortSha; + public string NuGetVersionV2 { get; } = GitVersionInformation.NuGetVersionV2; + public string NuGetVersion { get; } = GitVersionInformation.NuGetVersion; + public string NuGetPreReleaseTagV2 { get; } = GitVersionInformation.NuGetPreReleaseTagV2; + public string NuGetPreReleaseTag { get; } = GitVersionInformation.NuGetPreReleaseTag; + public string VersionSourceSha { get; } = GitVersionInformation.VersionSourceSha; + public string CommitsSinceVersionSource { get; } = GitVersionInformation.CommitsSinceVersionSource; + public string CommitsSinceVersionSourcePadded { get; } = GitVersionInformation.CommitsSinceVersionSourcePadded; + public string UncommittedChanges { get; } = GitVersionInformation.UncommittedChanges; + public string CommitDate { get; } = GitVersionInformation.CommitDate; + } +} diff --git a/BililiveRecorder.Web.Schemas/Types/RecorderVersionType.cs b/BililiveRecorder.Web.Schemas/Types/RecorderVersionType.cs new file mode 100644 index 0000000..65cfc14 --- /dev/null +++ b/BililiveRecorder.Web.Schemas/Types/RecorderVersionType.cs @@ -0,0 +1,44 @@ +using GraphQL.Types; + +namespace BililiveRecorder.Web.Schemas.Types +{ + public class RecorderVersionType : ObjectGraphType + { + public RecorderVersionType() + { + this.Field(x => x.Major); + this.Field(x => x.Minor); + this.Field(x => x.Patch); + this.Field(x => x.PreReleaseTag); + this.Field(x => x.PreReleaseTagWithDash); + this.Field(x => x.PreReleaseLabel); + this.Field(x => x.PreReleaseLabelWithDash); + this.Field(x => x.PreReleaseNumber); + this.Field(x => x.WeightedPreReleaseNumber); + this.Field(x => x.BuildMetaData); + this.Field(x => x.BuildMetaDataPadded); + this.Field(x => x.FullBuildMetaData); + this.Field(x => x.MajorMinorPatch); + this.Field(x => x.SemVer); + this.Field(x => x.LegacySemVer); + this.Field(x => x.LegacySemVerPadded); + this.Field(x => x.AssemblySemVer); + this.Field(x => x.AssemblySemFileVer); + this.Field(x => x.FullSemVer); + this.Field(x => x.InformationalVersion); + this.Field(x => x.BranchName); + this.Field(x => x.EscapedBranchName); + this.Field(x => x.Sha); + this.Field(x => x.ShortSha); + this.Field(x => x.NuGetVersionV2); + this.Field(x => x.NuGetVersion); + this.Field(x => x.NuGetPreReleaseTagV2); + this.Field(x => x.NuGetPreReleaseTag); + this.Field(x => x.VersionSourceSha); + this.Field(x => x.CommitsSinceVersionSource); + this.Field(x => x.CommitsSinceVersionSourcePadded); + this.Field(x => x.UncommittedChanges); + this.Field(x => x.CommitDate); + } + } +} diff --git a/BililiveRecorder.Web/ConstStrings.cs b/BililiveRecorder.Web/ConstStrings.cs new file mode 100644 index 0000000..07972a2 --- /dev/null +++ b/BililiveRecorder.Web/ConstStrings.cs @@ -0,0 +1,120 @@ +namespace BililiveRecorder.Web +{ + internal static class ConstStrings + { + internal const string HOME_PAGE_HTML = @"录播姬

录播姬,以后再写管理界面

API 界面GraphiQL Playground Altair Voyager

说明:录播姬 API 里的 objectId 在重启后会重新生成,是不保存到配置文件里的

API 用法示例

graphql 的语法请查看官方文档 https://graphql.org/learn/ ,或中文翻译镜像 https://graphql.cn/learn/

列出所有直播间和基本信息

列出所有直播间的所有信息(截至编写此页面时,具体最新属性见API界面的文档)

添加一个房间

添加一个房间,用变量传参版

启用自动录制

开始录制、结束录制、手动切分,都是 mutation,在 graphql 文档页面里可以看到
"; + } +} diff --git a/BililiveRecorder.Web/Startup.cs b/BililiveRecorder.Web/Startup.cs index 9132ea5..c075738 100644 --- a/BililiveRecorder.Web/Startup.cs +++ b/BililiveRecorder.Web/Startup.cs @@ -70,7 +70,8 @@ namespace BililiveRecorder.Web { if (context.Request.Path == "/") { - await context.Response.WriteAsync(@"

to be done

PlaygroundGraphiQLAltairVoyager").ConfigureAwait(false); + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync(ConstStrings.HOME_PAGE_HTML, encoding: System.Text.Encoding.UTF8).ConfigureAwait(false); } else {