You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.5 KiB
70 lines
2.5 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using QYMessageCenter.Client.APIServices;
|
|
using QYMessageCenter.Client.Helpers;
|
|
using QYMessageCenter.Client.Models;
|
|
using QYMessageCenter.Common.Extensions;
|
|
using QYMessageCenter.Common.Http;
|
|
using System.Windows;
|
|
|
|
namespace QYMessageCenter.Client
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
public IServiceProvider ServiceProvider { get; private set; }
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
string userToken = string.Empty;
|
|
|
|
#if DEBUG
|
|
//齐越山鸡
|
|
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNzI2MzAwNjY0fQ.hPSbgJEuTt0MLy_7YkSJX4rRG3drJAfso-5IS8ZlOkY";
|
|
//测试
|
|
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTQzNjI4ODUwMDIzNTI0MzUyMCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNzQwMTM3NzY5fQ.Wq7IRvAkrVpn28Bj3ImG_KAg9MZ3C2Ux84vSjXyd0ZY";
|
|
#else
|
|
|
|
var tokenResult = ReadMMF();
|
|
if (tokenResult.isOk)
|
|
userToken = tokenResult.content;
|
|
else
|
|
{
|
|
MessageBox.Show($"读取内存数据失败\r\n{tokenResult.content}", "提示");
|
|
Environment.Exit(0);
|
|
}
|
|
#endif
|
|
|
|
var gl = new GlobalContext();
|
|
gl.UserToken = userToken;
|
|
IServiceCollection serviceCollection = new ServiceCollection();
|
|
serviceCollection.AddHttpClient();
|
|
serviceCollection.AddSingleton<RestApiService>();
|
|
serviceCollection.AddSingleton<MdsApiService>();
|
|
serviceCollection.AddSingleton<ShopService>();
|
|
serviceCollection.AddSingleton(gl);
|
|
serviceCollection.AddMapper(new MappingProfile());
|
|
ServiceProvider = serviceCollection.BuildServiceProvider();
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
public (bool isOk, string content) ReadMMF()
|
|
{
|
|
|
|
try
|
|
{
|
|
var token = MemoryHelper.GetMemoryToken();
|
|
if (string.IsNullOrEmpty(token))
|
|
return (false, "token为空");
|
|
else
|
|
return (true, token);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return (false, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|