Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Bili.Uwp
提交
dbc11b97
B
Bili.Uwp
项目概览
jobily
/
Bili.Uwp
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Bili.Uwp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dbc11b97
编写于
6月 08, 2021
作者:
A
Anran Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加一些基本的账户登录流程
上级
aee8161d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
168 addition
and
28 deletion
+168
-28
src/Lib/Lib.Interfaces/Properties/AssemblyInfo.cs
src/Lib/Lib.Interfaces/Properties/AssemblyInfo.cs
+5
-14
src/Lib/Lib.Uwp/AuthorizeProvider/AccountManagementPane.xaml
src/Lib/Lib.Uwp/AuthorizeProvider/AccountManagementPane.xaml
+17
-0
src/Lib/Lib.Uwp/AuthorizeProvider/AccountManagementPane.xaml.cs
...b/Lib.Uwp/AuthorizeProvider/AccountManagementPane.xaml.cs
+20
-0
src/Lib/Lib.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs
.../Lib.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs
+10
-1
src/Lib/Lib.Uwp/AuthorizeProvider/AuthorizeProvider.cs
src/Lib/Lib.Uwp/AuthorizeProvider/AuthorizeProvider.cs
+79
-8
src/Lib/Lib.Uwp/HttpProvider/HttpProvider.Extension.cs
src/Lib/Lib.Uwp/HttpProvider/HttpProvider.Extension.cs
+1
-1
src/Lib/Lib.Uwp/Lib.Uwp.csproj
src/Lib/Lib.Uwp/Lib.Uwp.csproj
+18
-2
src/Lib/Lib.Uwp/Themes/Generic.xaml
src/Lib/Lib.Uwp/Themes/Generic.xaml
+5
-0
src/Models/Models.App/Constants/ServiceConstants.cs
src/Models/Models.App/Constants/ServiceConstants.cs
+2
-1
src/Models/Models.Enums/AuthorizeState.cs
src/Models/Models.Enums/AuthorizeState.cs
+1
-1
src/Models/Models.Enums/SettingNames.cs
src/Models/Models.Enums/SettingNames.cs
+2
-0
src/ViewModels/ViewModels.Uwp/ViewModels.Uwp.csproj
src/ViewModels/ViewModels.Uwp/ViewModels.Uwp.csproj
+8
-0
未找到文件。
src/Lib/Lib.Interfaces/Properties/AssemblyInfo.cs
浏览文件 @
dbc11b97
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
// Copyright (c) Richasy. All rights reserved.
using
System.Reflection
;
using
System.Runtime.InteropServices
;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[
assembly
:
AssemblyTitle
(
"Lib.Interfaces"
)]
...
...
@@ -14,16 +15,6 @@ using System.Runtime.InteropServices;
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
[
assembly
:
ComVisible
(
false
)]
\ No newline at end of file
[
assembly
:
ComVisible
(
false
)]
src/Lib/Lib.Uwp/AuthorizeProvider/AccountManagementPane.xaml
0 → 100644
浏览文件 @
dbc11b97
<UserControl
x:Class="Richasy.Bili.Lib.Uwp.AccountManagementPane"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Richasy.Bili.Lib.Uwp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">
<Grid
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}" />
</UserControl>
src/Lib/Lib.Uwp/AuthorizeProvider/AccountManagementPane.xaml.cs
0 → 100644
浏览文件 @
dbc11b97
// Copyright (c) Richasy. All rights reserved.
using
Windows.UI.Xaml.Controls
;
namespace
Richasy.Bili.Lib.Uwp
{
/// <summary>
/// 账户登录管理面板.
/// </summary>
public
sealed
partial
class
AccountManagementPane
:
UserControl
{
/// <summary>
/// Initializes a new instance of the <see cref="AccountManagementPane"/> class.
/// </summary>
public
AccountManagementPane
()
{
this
.
InitializeComponent
();
}
}
}
src/Lib/Lib.Uwp/AuthorizeProvider.Extension.cs
→
src/Lib/Lib.Uwp/AuthorizeProvider
/AuthorizeProvider
.Extension.cs
浏览文件 @
dbc11b97
// Copyright (c) Richasy. All rights reserved.
using
System.Threading.Tasks
;
using
Richasy.Bili.Models.Enums
;
using
Richasy.Bili.Toolkit.Interfaces
;
...
...
@@ -10,8 +11,16 @@ namespace Richasy.Bili.Lib.Uwp
/// </summary>
public
partial
class
AuthorizeProvider
{
private
AuthorizeState
_state
;
private
readonly
IMD5Toolkit
_md5Toolkit
;
private
readonly
ISettingsToolkit
_settingsToolkit
;
private
AuthorizeState
_state
;
private
string
_accessToken
;
private
async
Task
<
string
>
ShowAccountManagementPaneAndGetResultAsync
()
{
var
webAccountProviderTaskCompletionSource
=
new
TaskCompletionSource
<
string
>();
return
await
webAccountProviderTaskCompletionSource
.
Task
;
}
}
}
src/Lib/Lib.Uwp/AuthorizeProvider.cs
→
src/Lib/Lib.Uwp/AuthorizeProvider
/AuthorizeProvider
.cs
浏览文件 @
dbc11b97
...
...
@@ -5,10 +5,11 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Richasy.Bili.Lib.Interfaces
;
using
Richasy.Bili.Locator.Uwp
;
using
Richasy.Bili.Models.App.Args
;
using
Richasy.Bili.Models.App.Constants
;
using
Richasy.Bili.Models.Enums
;
using
Richasy.Bili.Toolkit.Interfaces
;
using
Windows.Networking.Connectivity
;
namespace
Richasy.Bili.Lib.Uwp
{
...
...
@@ -20,10 +21,10 @@ namespace Richasy.Bili.Lib.Uwp
/// <summary>
/// Initializes a new instance of the <see cref="AuthorizeProvider"/> class.
/// </summary>
/// <param name="md5Toolkit">MD5工具.</param>
public
AuthorizeProvider
(
IMD5Toolkit
md5Toolkit
)
public
AuthorizeProvider
()
{
_md5Toolkit
=
md5Toolkit
;
ServiceLocator
.
Instance
.
LoadService
(
out
_md5Toolkit
)
.
LoadService
(
out
_settingsToolkit
);
}
/// <inheritdoc/>
...
...
@@ -83,15 +84,85 @@ namespace Richasy.Bili.Lib.Uwp
}
/// <inheritdoc/>
public
Task
<
string
>
GetTokenAsync
(
bool
silentOnly
=
false
)
=>
throw
new
NotImplementedException
();
public
async
Task
<
string
>
GetTokenAsync
(
bool
silentOnly
=
false
)
{
// TODO: 检查当前Token的时效.
var
internetConnectionProfile
=
NetworkInformation
.
GetInternetConnectionProfile
();
if
(
internetConnectionProfile
==
null
)
{
// 目前不在线.
return
null
;
}
try
{
var
result
=
await
ShowAccountManagementPaneAndGetResultAsync
();
_accessToken
=
result
;
return
result
;
}
catch
(
Exception
)
{
}
await
SignOutAsync
();
return
null
;
}
/// <inheritdoc/>
public
Task
SignInAsync
()
=>
throw
new
NotImplementedException
();
public
async
Task
SignInAsync
()
{
if
(!
string
.
IsNullOrEmpty
(
_accessToken
)
||
State
!=
AuthorizeState
.
SignedOut
)
{
return
;
}
State
=
AuthorizeState
.
Loading
;
var
token
=
await
GetTokenAsync
();
if
(
string
.
IsNullOrEmpty
(
token
))
{
await
SignOutAsync
();
}
}
/// <inheritdoc/>
public
Task
SignOutAsync
()
=>
throw
new
NotImplementedException
();
public
Task
SignOutAsync
()
{
State
=
AuthorizeState
.
Loading
;
_settingsToolkit
.
DeleteLocalSetting
(
SettingNames
.
BiliUserId
);
_settingsToolkit
.
DeleteLocalSetting
(
SettingNames
.
AuthorizeResult
);
if
(!
string
.
IsNullOrEmpty
(
_accessToken
))
{
_accessToken
=
null
;
}
State
=
AuthorizeState
.
SignedOut
;
return
Task
.
CompletedTask
;
}
/// <inheritdoc/>
public
Task
<
bool
>
TrySilentSignInAsync
()
=>
throw
new
NotImplementedException
();
public
async
Task
<
bool
>
TrySilentSignInAsync
()
{
if
(!
string
.
IsNullOrEmpty
(
_accessToken
)
&&
State
==
AuthorizeState
.
SignedIn
)
{
return
true
;
}
State
=
AuthorizeState
.
Loading
;
var
token
=
await
GetTokenAsync
(
true
);
if
(
token
==
null
)
{
State
=
AuthorizeState
.
SignedOut
;
return
false
;
}
return
true
;
}
}
}
src/Lib/Lib.Uwp/HttpProvider/HttpProvider.Extension.cs
浏览文件 @
dbc11b97
...
...
@@ -127,7 +127,7 @@ namespace Richasy.Bili.Lib.Uwp
{
if
(
response
!=
null
&&
response
.
StatusCode
==
HttpStatusCode
.
NotFound
)
{
errorResponse
=
new
ServerResponse
{
Message
=
ServiceConstants
.
Codes
.
Item
NotFound
};
errorResponse
=
new
ServerResponse
{
Message
=
ServiceConstants
.
Messages
.
NotFound
};
}
else
{
...
...
src/Lib/Lib.Uwp/Lib.Uwp.csproj
浏览文件 @
dbc11b97
...
...
@@ -9,8 +9,11 @@
<ProjectTypeGuids>
{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
</ProjectTypeGuids>
</PropertyGroup>
<ItemGroup>
<Compile
Include=
"AuthorizeProvider.cs"
/>
<Compile
Include=
"AuthorizeProvider.Extension.cs"
/>
<Compile
Include=
"AuthorizeProvider\AccountManagementPane.xaml.cs"
>
<DependentUpon>
AccountManagementPane.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"AuthorizeProvider\AuthorizeProvider.cs"
/>
<Compile
Include=
"AuthorizeProvider\AuthorizeProvider.Extension.cs"
/>
<Compile
Include=
"HttpProvider\HttpProvider.cs"
/>
<Compile
Include=
"HttpProvider\HttpProvider.Extension.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
...
...
@@ -23,6 +26,9 @@
<PackageReference
Include=
"Microsoft.NETCore.UniversalWindowsPlatform"
>
<Version>
6.2.12
</Version>
</PackageReference>
<PackageReference
Include=
"Microsoft.UI.Xaml"
>
<Version>
2.6.0-prerelease.210524002
</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\..\Models\Models.App\Models.App.csproj"
>
...
...
@@ -50,5 +56,15 @@
<Name>
Lib.Interfaces
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page
Include=
"AuthorizeProvider\AccountManagementPane.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
<Page
Include=
"Themes\Generic.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
</ItemGroup>
<Import
Project=
"$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets"
/>
</Project>
\ No newline at end of file
src/Lib/Lib.Uwp/Themes/Generic.xaml
0 → 100644
浏览文件 @
dbc11b97
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" ControlsResourcesVersion="Version2" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
src/Models/Models.App/Constants/ServiceConstants.cs
浏览文件 @
dbc11b97
...
...
@@ -5,7 +5,7 @@ namespace Richasy.Bili.Models.App.Constants
/// <summary>
/// 服务相关的常量.
/// </summary>
public
class
ServiceConstants
public
static
class
ServiceConstants
{
#pragma warning disable SA1600 // Elements should be documented
#pragma warning disable SA1401 // Fields should be private
...
...
@@ -34,6 +34,7 @@ namespace Richasy.Bili.Models.App.Constants
public
static
class
Messages
{
public
static
string
NotFound
=
"没有找到你所需要的资源"
;
public
static
string
AuthenticationProviderMissing
=
"Authentication provider is required before sending a request."
;
public
static
string
BaseUrlMissing
=
"Base URL cannot be null or empty."
;
public
static
string
InvalidTypeForDateConverter
=
"DateConverter can only serialize objects of type Date."
;
...
...
src/Models/Models.Enums/AuthorizeState.cs
浏览文件 @
dbc11b97
...
...
@@ -15,7 +15,7 @@ namespace Richasy.Bili.Models.Enums
/// <summary>
/// 用户已退出.
/// </summary>
Si
ng
edOut
,
Si
gn
edOut
,
/// <summary>
/// 用户已登录.
...
...
src/Models/Models.Enums/SettingNames.cs
浏览文件 @
dbc11b97
...
...
@@ -11,5 +11,7 @@ namespace Richasy.Bili.Models.Enums
/// Application theme.
/// </summary>
AppTheme
,
BiliUserId
,
AuthorizeResult
,
}
}
src/ViewModels/ViewModels.Uwp/ViewModels.Uwp.csproj
浏览文件 @
dbc11b97
...
...
@@ -41,6 +41,14 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\..\Lib\Lib.Interfaces\Lib.Interfaces.csproj"
>
<Project>
{cae9b987-6db2-42a8-b3f2-3bb700cc4dd8}
</Project>
<Name>
Lib.Interfaces
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\Lib\Lib.Uwp\Lib.Uwp.csproj"
>
<Project>
{c8ab398f-10c2-4b97-87f0-f09b922947d6}
</Project>
<Name>
Lib.Uwp
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\Models\Models.BiliBili\Models.BiliBili.csproj"
>
<Project>
{8776a0bd-dbd1-4f11-a022-400d044ff618}
</Project>
<Name>
Models.BiliBili
</Name>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录