Skip to content

Commit 39f3fad

Browse files
committed
增加docker环境参数和针对update差异化处理
1 parent 4d6eef1 commit 39f3fad

File tree

8 files changed

+211
-7
lines changed

8 files changed

+211
-7
lines changed

Client/App.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected override void OnStartup(StartupEventArgs e)
2020
Host.CreateDefaultBuilder()
2121
.ConfigureWebHostDefaults(webBuilder =>
2222
{
23-
Task.Run(() => Service.CreateHostBuilder(new string[] { "--StartMode=Desktop" }).Build().Run());
23+
Task.Run(() => Service.CreateHostBuilder(new string[] { "--StartMode=Client" }).Build().Run());
2424
webBuilder.UseStartup<Server.Startup>();
2525
string rurl = $"http://0.0.0.0:{Config.Core_RunConfig._Port}";
2626
webBuilder.UseUrls(rurl);

Core/Init.cs

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public static void Start(string[] args)
7575
/// </summary>
7676
private static void StartParameterInitialization(string[] args)
7777
{
78+
string? DockerEnvironment = Environment.GetEnvironmentVariable("DDTV_Docker_Project");
79+
if (!string.IsNullOrEmpty(DockerEnvironment))
80+
{
81+
if (DockerEnvironment =="DDTV_Server")
82+
{
83+
Init.Mode = Mode.Docker;
84+
}
85+
}
7886
foreach (var arg in args)
7987
{
8088
if (arg.StartsWith("--"))

Desktop/Desktop.csproj

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
</ItemGroup>
5353

5454
<ItemGroup>
55+
<Compile Update="Properties\Resources.Designer.cs">
56+
<DesignTime>True</DesignTime>
57+
<AutoGen>True</AutoGen>
58+
<DependentUpon>Resources.resx</DependentUpon>
59+
</Compile>
5560
<Compile Update="Views\Control\CardControl.xaml.cs">
5661
<SubType>Code</SubType>
5762
</Compile>
@@ -64,6 +69,13 @@
6469
<Folder Include="Resource\" />
6570
</ItemGroup>
6671

72+
<ItemGroup>
73+
<EmbeddedResource Update="Properties\Resources.resx">
74+
<Generator>ResXFileCodeGenerator</Generator>
75+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
76+
</EmbeddedResource>
77+
</ItemGroup>
78+
6779
<ItemGroup>
6880
<None Update="DDTV.ico">
6981
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

Desktop/Properties/Resources.Designer.cs

+63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Desktop/Properties/Resources.resx

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 1.3
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">1.3</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1">this is my long string</data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
[base64 mime encoded serialized .NET Framework object]
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
[base64 mime encoded string representing a byte array form of the .NET Framework object]
27+
</data>
28+
29+
There are any number of "resheader" rows that contain simple
30+
name/value pairs.
31+
32+
Each data row contains a name, and value. The row also contains a
33+
type or mimetype. Type corresponds to a .NET class that support
34+
text/value conversion through the TypeConverter architecture.
35+
Classes that don't support this are serialized and stored with the
36+
mimetype set.
37+
38+
The mimetype is used for serialized objects, and tells the
39+
ResXResourceReader how to depersist the object. This is currently not
40+
extensible. For a given mimetype the value must be set accordingly:
41+
42+
Note - application/x-microsoft.net.object.binary.base64 is the format
43+
that the ResXResourceWriter will generate, however the reader can
44+
read any of the formats listed below.
45+
46+
mimetype: application/x-microsoft.net.object.binary.base64
47+
value : The object must be serialized with
48+
: System.Serialization.Formatters.Binary.BinaryFormatter
49+
: and then encoded with base64 encoding.
50+
51+
mimetype: application/x-microsoft.net.object.soap.base64
52+
value : The object must be serialized with
53+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
54+
: and then encoded with base64 encoding.
55+
56+
mimetype: application/x-microsoft.net.object.bytearray.base64
57+
value : The object must be serialized into a byte array
58+
: using a System.ComponentModel.TypeConverter
59+
: and then encoded with base64 encoding.
60+
-->
61+
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:element name="root" msdata:IsDataSet="true">
64+
<xsd:complexType>
65+
<xsd:choice maxOccurs="unbounded">
66+
<xsd:element name="data">
67+
<xsd:complexType>
68+
<xsd:sequence>
69+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
70+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
73+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
74+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
75+
</xsd:complexType>
76+
</xsd:element>
77+
<xsd:element name="resheader">
78+
<xsd:complexType>
79+
<xsd:sequence>
80+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
81+
</xsd:sequence>
82+
<xsd:attribute name="name" type="xsd:string" use="required" />
83+
</xsd:complexType>
84+
</xsd:element>
85+
</xsd:choice>
86+
</xsd:complexType>
87+
</xsd:element>
88+
</xsd:schema>
89+
<resheader name="resmimetype">
90+
<value>text/microsoft-resx</value>
91+
</resheader>
92+
<resheader name="version">
93+
<value>1.3</value>
94+
</resheader>
95+
<resheader name="reader">
96+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
97+
</resheader>
98+
<resheader name="writer">
99+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
100+
</resheader>
101+
</root>
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"profiles": {
3+
"Desktop": {
4+
"commandName": "Project"
5+
}
6+
}
7+
}

Desktop/Views/Windows/AddRoom.xaml.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,16 @@ private void AddRoomSave_Click(object sender, RoutedEventArgs e)
113113
{
114114
Task.Run(() =>
115115
{
116-
Dictionary<string, string> dic = new Dictionary<string, string>
116+
Dispatcher.Invoke(() =>
117117
{
118-
{"room_id", RoomId_TextBox.Text },
119-
{"auto_rec",_IsAutoRec.ToString() },
120-
{"remind",_IsDanmu.ToString() },
121-
{"rec_danmu",_IsRemind.ToString() },
122-
};
118+
Dictionary<string, string> dic = new Dictionary<string, string>
119+
{
120+
{"room_id", RoomId_TextBox.Text },
121+
{"auto_rec",_IsAutoRec.ToString() },
122+
{"remind",_IsDanmu.ToString() },
123+
{"rec_danmu",_IsRemind.ToString() },
124+
};
125+
});
123126
int State = NetWork.Post.PostBody<int>($"{Config.Core_RunConfig._DesktopIP}:{Config.Core_RunConfig._DesktopPort}/api/set_rooms/add_room", dic).Result;
124127
Dispatcher.Invoke(() =>
125128
{

Server/Program.cs

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ public class Program
2727

2828
public static async Task Main(string[] args)
2929
{
30+
if (!Array.Exists(args, element => element.Contains("--StartMode")))
31+
{
32+
string[] N_args = new string[args.Length + 1];
33+
for (int i = 0; i < args.Length; i++)
34+
{
35+
N_args[i] = args[i];
36+
}
37+
N_args[N_args.Length - 1] = "--StartMode=Server";
38+
}
3039
if (!args.Contains("Desktop") && !args.Contains("Client"))
3140
{
3241
Console.OutputEncoding = System.Text.Encoding.UTF8;
@@ -183,6 +192,7 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
183192
{
184193
try
185194
{
195+
186196
Core.Init.Start(_args);//初始化必须执行的
187197
//_ParentProcessDetection();
188198

0 commit comments

Comments
 (0)