Skip to content

Commit 4691627

Browse files
authored
Merge pull request #1 from Senparc/Developer
Developer
2 parents b8581e9 + 3a34485 commit 4691627

26 files changed

+2441
-2
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
33
################################################################################
44

5-
/.vs
5+
/bin
6+
/src/Senparc.TouTiao/.vs/Senparc.TouTiao
7+
/**/obj/
8+
/**/bin/
9+
/**/.vs/

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

22
<img src="https://sdk.weixin.senparc.com/images/senparc-logo-500.jpg" />
33

4-
# TouTiaoSDK
4+
## Senparc.Toutiao SDK
55
头条小程序/小游戏 SDK,基于 NeuChar 标准实现,具备跨平台能力。
66

7+
## 头条官方文档
8+
9+
* [服务端](https://microapp.bytedance.com/dev/cn/mini-app/develop/server/server-api-introduction)
10+
* [客户端 API](https://developer.toutiao.com/dev/cn/mini-app/develop/api/foundation/tt.caniuse)
11+
* [开发者工具](https://developer.toutiao.com/dev/cn/mini-app/develop/developer-instrument/development-assistance/developer-instrument-introduction)
12+

src/Senparc.TouTiao/Config.cs

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#region Apache License Version 2.0
2+
/*----------------------------------------------------------------
3+
4+
Copyright 2020 Suzhou Senparc Network Technology Co.,Ltd.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7+
except in compliance with the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software distributed under the
12+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
either express or implied. See the License for the specific language governing permissions
14+
and limitations under the License.
15+
16+
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
17+
18+
----------------------------------------------------------------*/
19+
#endregion Apache License Version 2.0
20+
21+
/*----------------------------------------------------------------
22+
Copyright (C) 2020 Senparc
23+
24+
文件名:Config.cs
25+
文件功能描述:全局设置
26+
27+
28+
创建标识:Senparc - 20200505
29+
30+
----------------------------------------------------------------*/
31+
using Senparc.Toutiao.Entities;
32+
using System;
33+
34+
namespace Senparc.Toutiao
35+
{
36+
public static class Config
37+
{
38+
/// <summary>
39+
/// <para>指定是否是Debug状态,如果是,系统会自动输出日志。</para>
40+
/// <para>如果 CO2NET.Config.IsDebug 为 true,则此参数也会为 true,否则以此参数为准。</para>
41+
/// </summary>
42+
public static bool IsDebug
43+
{
44+
get => CO2NET.Config.IsDebug || SenparcToutiaoSetting.IsDebug;
45+
46+
set => SenparcToutiaoSetting.IsDebug = value;
47+
}
48+
49+
50+
/// <summary>
51+
/// <para>头条全局配置</para>
52+
/// <para>注意:在程序运行过程中修改 SenparcWeixinSetting.Items 中的头条配置值,并不能修改 Container 中的对应信息(如AppSecret),</para>
53+
/// <para>如果需要修改头条信息(如AppSecret)应该使用 xxContainer.Register() 修改,这里的值也会随之更新。</para>
54+
/// </summary>
55+
public static SenparcToutiaoSetting SenparcToutiaoSetting { get; set; }
56+
57+
/// <summary>
58+
/// 请求超时设置(以毫秒为单位),默认为10秒。
59+
/// 说明:此处常量专为提供给方法的参数的默认值,不是方法内所有请求的默认超时时间。
60+
/// </summary>
61+
public const int TIME_OUT = CO2NET.Config.TIME_OUT;
62+
63+
/// <summary>
64+
/// 网站根目录绝对路径
65+
/// </summary>
66+
public static string RootDictionaryPath
67+
{
68+
get => CO2NET.Config.RootDictionaryPath;
69+
set => CO2NET.Config.RootDictionaryPath = value;
70+
}
71+
72+
/// <summary>
73+
/// 默认缓存键的第一级命名空间,默认值:DefaultCache
74+
/// </summary>
75+
public static string DefaultCacheNamespace
76+
{
77+
get => CO2NET.Config.DefaultCacheNamespace;
78+
set => CO2NET.Config.DefaultCacheNamespace = value;
79+
}
80+
81+
/// <summary>
82+
/// 当 JsonResult 不为“成功”状态时,是否抛出异常,默认为 true
83+
/// </summary>
84+
public static bool ThrownWhenJsonResultFaild { get; set; }
85+
86+
#region API地址(前缀)设置
87+
88+
#region 小程序 API 的服务器地址(默认为:https://developer.toutiao.com)
89+
90+
/// <summary>
91+
/// 小程序 API 的服务器地址(默认为:https://developer.toutiao.com)
92+
/// </summary>
93+
public static string ApiAppsHost { get; set; } = "https://developer.toutiao.com";
94+
95+
#endregion
96+
97+
#endregion
98+
99+
/// <summary>
100+
/// 默认的AppId检查规则
101+
/// </summary>
102+
public static Func<string, PlatformType, bool> DefaultAppIdCheckFunc = (accessTokenOrAppId, platFormType) =>
103+
{
104+
if (platFormType == PlatformType.Apps)
105+
{
106+
/*
107+
* AppId:xxx
108+
* AccessToken:xxx
109+
*/
110+
return accessTokenOrAppId != null && accessTokenOrAppId.Length <= 32 /* xxx */
111+
;
112+
}
113+
else
114+
{
115+
throw new Exception("未知的平台类型");
116+
}
117+
};
118+
119+
static Config()
120+
{
121+
SenparcToutiaoSetting = new SenparcToutiaoSetting();//提供默认实例
122+
ThrownWhenJsonResultFaild = true;//默认接口返回不正确结果时抛出异常
123+
}
124+
}
125+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5+
<Version>0.1.0-preview1</Version>
6+
<AssemblyName>Senparc.Toutiao</AssemblyName>
7+
<RootNamespace>Senparc.Toutiao</RootNamespace>
8+
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
9+
<Description>
10+
头条 SDK - Senparc.TouTiao SDK 基础模块
11+
12+
Senparc.TouTiao SDK 开源项目:
13+
https://github.com/Senparc/TouTiaoSDK
14+
</Description>
15+
<Copyright>Senparc Copyright © 2004~2020</Copyright>
16+
<PackageTags>头条,TouTiao,Senparc,盛派,SDK,C#,小程序,小游戏,Cache,Redis</PackageTags>
17+
<Authors>Senparc</Authors>
18+
<Owners>Senparc</Owners>
19+
<PackageLicenseUrl>https://github.com/Senparc/TouTiaoSDK/blob/master/license.md</PackageLicenseUrl>
20+
<ProjectUrl>https://github.com/Senparc/TouTiaoSDK</ProjectUrl>
21+
<Title>Senparc.Toutiao.dll</Title>
22+
<Summary>头条 SDK for C#</Summary>
23+
<PackageProjectUrl>https://github.com/Senparc/TouTiaoSDK</PackageProjectUrl>
24+
<PackageIconUrl>http://sdk.weixin.senparc.com/Images/Logo.jpg</PackageIconUrl>
25+
<RepositoryUrl>https://github.com/Senparc/TouTiaoSDK</RepositoryUrl>
26+
<PackageReleaseNotes>
27+
28+
29+
</PackageReleaseNotes>
30+
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
34+
<OutputPath>..\BuildOutPut</OutputPath>
35+
<DefineConstants>TRACE;RELEASE</DefineConstants>
36+
</PropertyGroup>
37+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
38+
<OutputPath>..\BuildOutPut</OutputPath>
39+
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
40+
<DocumentationFile>..\BuildOutPut\Senparc.Toutiao.XML</DocumentationFile>
41+
<Optimize>true</Optimize>
42+
<DebugType>pdbonly</DebugType>
43+
<ErrorReport>prompt</ErrorReport>
44+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
45+
</PropertyGroup>
46+
47+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
48+
<OutputPath>..\BuildOutPut\</OutputPath>
49+
<DocumentationFile>..\BuildOutPut\netstandard2.0\Senparc.Toutiao.xml</DocumentationFile>
50+
</PropertyGroup>
51+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
52+
<OutputPath>..\BuildOutPut\</OutputPath>
53+
<DocumentationFile>..\BuildOutPut\netstandard2.1\Senparc.Toutiao.xml</DocumentationFile>
54+
</PropertyGroup>
55+
56+
<ItemGroup>
57+
<PackageReference Include="Senparc.NeuChar" Version="1.2.108" />
58+
</ItemGroup>
59+
60+
61+
</Project>

src/Senparc.Toutiao.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29806.167
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.TouTiao", "Senparc.Toutiao\Senparc.Toutiao.csproj", "{C487A8F4-942D-40F0-B0A6-AFE463EE06FE}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{13A80253-3238-457D-B273-6A7519EDC07A}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{C487A8F4-942D-40F0-B0A6-AFE463EE06FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{C487A8F4-942D-40F0-B0A6-AFE463EE06FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{C487A8F4-942D-40F0-B0A6-AFE463EE06FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{C487A8F4-942D-40F0-B0A6-AFE463EE06FE}.Release|Any CPU.Build.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(NestedProjects) = preSolution
25+
{C487A8F4-942D-40F0-B0A6-AFE463EE06FE} = {13A80253-3238-457D-B273-6A7519EDC07A}
26+
EndGlobalSection
27+
GlobalSection(ExtensibilityGlobals) = postSolution
28+
SolutionGuid = {C6FAF905-0059-47C8-A156-0D87B124176B}
29+
EndGlobalSection
30+
EndGlobal

0 commit comments

Comments
 (0)