Browse Source

webtest支持配置文件

liangku_skuoptimazation
shanji 1 year ago
parent
commit
ee927c9da7
  1. 8
      WebTest/App.xaml.cs
  2. 3
      WebTest/MainWindow.xaml
  3. 1
      WebTest/MainWindow.xaml.cs
  4. 3
      WebTest/appSettings.json

8
WebTest/App.xaml.cs

@ -22,18 +22,18 @@ namespace WebTest
protected override void OnStartup(StartupEventArgs e)
{
var gl = new GlobalContext();
string userToken = string.Empty;
//string userToken = string.Empty;
//齐越山鸡
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTc2MDk3MTY4ODk2NDUyNjA4MCIsInNvblRlYW1JZHMiOiIiLCJleHAiOjE3NDIxOTYxMDF9.pt1onwf4f4QKyuT1kFWtcRw8LZo9s64CmHqrdI4fD5k";
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTc2MDk3MTY4ODk2NDUyNjA4MCIsInNvblRlYW1JZHMiOiIiLCJleHAiOjE3NDIxOTYxMDF9.pt1onwf4f4QKyuT1kFWtcRw8LZo9s64CmHqrdI4fD5k";
gl.UserToken = userToken;
var applicationPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var builder = new ConfigurationBuilder().SetBasePath(applicationPath).AddJsonFile("appSettings.json", false, true);
Configuration = builder.Build();
gl.UserToken = Configuration.GetSection("UserToken").Value;
gl.BBYWApiHost = Configuration.GetSection("BBWYApiHost").Value;
gl.MDSApiHost = Configuration.GetSection("MDSApiHost").Value;
IServiceCollection serviceCollection = new ServiceCollection();

3
WebTest/MainWindow.xaml

@ -10,13 +10,14 @@
CloseButtonColor="Black"
MinButtonColor="Black"
MaxButtonColor="Black"
Title="WebTest" Height="768" Width="1024">
Title="AAA" Height="768" Width="1024" x:Name="w">
<Grid x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Title,ElementName=w}" VerticalAlignment="Center" Margin="10,0,0,0"/>
<Grid Grid.Row="1" Margin="5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>

1
WebTest/MainWindow.xaml.cs

@ -121,6 +121,7 @@ private string registerName = "webContext";
throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}");
globalContext.User = mdsUserResponse.Data.Map<User>();
this.Title = globalContext.User.Name;
globalContext.User.Token = globalContext.UserToken;
globalContext.User.SonDepartmentNames = string.Empty;
if (mdsUserResponse.Data.SonDepartmentList != null && mdsUserResponse.Data.SonDepartmentList.Count > 0)

3
WebTest/appSettings.json

@ -1,4 +1,5 @@
{
"BBWYApiHost": "http://bbwytest.qiyue666.com",
"MDSApiHost": "http://mdsapi.qiyue666.com"
"MDSApiHost": "http://mdsapi.qiyue666.com",
"UserToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTc2MDk3MTY4ODk2NDUyNjA4MCIsInNvblRlYW1JZHMiOiIiLCJleHAiOjE3NDIxOTYxMDF9.pt1onwf4f4QKyuT1kFWtcRw8LZo9s64CmHqrdI4fD5k"
}
Loading…
Cancel
Save