-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathApp.xaml.cs
64 lines (61 loc) · 2.1 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Native.Tool.IniConfig;
using Native.Tool.IniConfig.Linq;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using WeMusic.Model;
using WeMusic.Model.DbModel;
using WeMusic.ViewModel;
namespace WeMusic
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
Init();
base.OnStartup(e);
}
public static void Init()
{
if (!File.Exists("data.db"))
{
SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\data.db;",
DbType = SqlSugar.DbType.Sqlite,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
});
conn.CodeFirst.InitTables<CustomListModel>();
conn.CodeFirst.InitTables<CustomTitleModel>();
conn.CodeFirst.InitTables<DefaultListModel>();
conn.CodeFirst.InitTables<MusicInfoModel>();
conn.CodeFirst.InitTables<LocalListModel>();
conn.CodeFirst.InitTables<SearchHistoryModel>();
conn.CodeFirst.InitTables<PlatformListModel>();
conn.CodeFirst.InitTables<PlatformInfoModel>();
conn.Dispose();
}
IniConfig ini = new IniConfig("Config.ini");
ini.Load();
bool result = ini.Object["System"].TryGetValue("DownloadPath", out IValue v);
if (!result || v?.ToString() == string.Empty)
{
DownloadManager.MusicDownloadPath = AppDomain.CurrentDomain.BaseDirectory + "Download\\";
}
else
{
DownloadManager.MusicDownloadPath = v.ObjToString();
}
}
}
}