Browse Source

修复token设置错误

master
С·æ 4 years ago
parent
commit
c47b19692d
  1. 2
      src/Coldairarrow.Business/HuiYan/itemlabelsBusiness.cs
  2. 24
      客户端/齐越慧眼/齐越慧眼/ApiHelper.cs
  3. 19
      客户端/齐越慧眼/齐越慧眼/MemoryHelper.cs
  4. 4
      客户端/齐越慧眼/齐越慧眼/UserControls/CatControl.xaml
  5. 35
      客户端/齐越慧眼/齐越慧眼/UserControls/CatControl.xaml.cs
  6. 3
      客户端/齐越慧眼/齐越慧眼/UserControls/ItemControl.xaml
  7. 36
      客户端/齐越慧眼/齐越慧眼/UserControls/ItemControl.xaml.cs
  8. 4
      客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/cats/Index.vue
  9. 4
      客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/items/Index.vue
  10. 2
      客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js
  11. 2
      客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js.map

2
src/Coldairarrow.Business/HuiYan/itemlabelsBusiness.cs

@ -333,7 +333,7 @@ namespace Coldairarrow.Business.HuiYan
var where = LinqHelper.True<ItemlabelInfoDto>().And(c => c.Platform == (int)ItemPlatform.Jd && c.TeamId == _operator.TeamId && c.IsCompeting == true);
var list = q.Where(where).ToListAsync();
var list = q.Where(where).ToList();
return Success(list);
}

24
客户端/齐越慧眼/齐越慧眼/ApiHelper.cs

@ -21,7 +21,8 @@ namespace 齐越慧眼
{
if (string.IsNullOrEmpty(jwtToken))
{
jwtToken = GetMemoryToken();
jwtToken = GetMemoryToken().Replace("\r\n","");
}
return jwtToken;
@ -29,6 +30,8 @@ namespace 齐越慧眼
}
static int getTokentCount = 0;
public static string GetMemoryToken()
{
string memoryName=string.Empty;
@ -45,10 +48,27 @@ namespace 齐越慧眼
if (result.isOk)
{
if (string.IsNullOrEmpty(result.content))
{
getTokentCount = getTokentCount + 1;
if (getTokentCount <= 3)
{
Thread.Sleep(300);
return GetMemoryToken();
}
}
return result.content;
}
else {
WpfNoticeMsg.NoticeMessage.Show("小程序登录失败!");
getTokentCount = getTokentCount + 1;
if (getTokentCount <= 3)
{
Thread.Sleep(300);
return GetMemoryToken();
}
// WpfNoticeMsg.NoticeMessage.Show("小程序登录失败!");
System.Environment.Exit(0);
return string.Empty;
}

19
客户端/齐越慧眼/齐越慧眼/MemoryHelper.cs

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Text;
using System.Windows;
namespace Utils
{
@ -59,28 +61,21 @@ namespace Utils
/// 读取映射文件
/// </summary>
/// <param name="mapname"></param>
public static (bool isOk,string content) ReadMMF(string mapname)
public static (bool isOk, string content) ReadMMF(string mapname)
{
try
{
MemoryMappedFile mmf = MemoryMappedFile.OpenExisting(mapname);
using (var mmfStream = mmf.CreateViewStream(0, 1000, MemoryMappedFileAccess.ReadWrite))
{
byte[] buffer = new byte[128];
int nLength = 0;
StringBuilder sb = new StringBuilder();
do
{
nLength = mmfStream.Read(buffer, 0, 128);
sb.AppendLine(System.Text.ASCIIEncoding.Default.GetString(buffer));
} while (nLength > 0);
return (true, sb.ToString().Replace("\0", null).TrimEnd());
StreamReader reader = new StreamReader(mmfStream);
string jwt = reader.ReadToEnd().Replace("\0","").TrimEnd();
return (true, jwt);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return (false, null);
}
}

4
客户端/齐越慧眼/齐越慧眼/UserControls/CatControl.xaml

@ -7,7 +7,9 @@
xmlns:cef="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="grid" DockPanel.Dock="Bottom">
<Grid x:Name="grid" DockPanel.Dock="Bottom" KeyDown="grid_KeyDown">
</Grid>
</UserControl>

35
客户端/齐越慧眼/齐越慧眼/UserControls/CatControl.xaml.cs

@ -3,6 +3,7 @@ using CefSharp.Wpf;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@ -36,19 +37,44 @@ namespace 齐越慧眼.UserControls
};
grid.Children.Add(web);
web.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
web.JavascriptObjectRepository.Register("hyCoreModel", new CatsAsyncJS(), BindingOptions.DefaultBinder);
web.ExecuteScriptAsyncWhenPageLoaded(@$"localStorage.setItem('user', '{{""token"":""{ApiHelper.JwtToken}""}}');window.getDatas();");
// web.WebBrowser.GetDevToolsClient().DOMStorage.SetDOMStorageItemAsync()
web.FrameLoadStart += Web_FrameLoadStart;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
bool isInit = false;
private void Web_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
{
if (isInit)
return;
Application.Current.Dispatcher.Invoke(() =>
{
web.WebBrowser.GetDevToolsClient().DOMStorage.SetDOMStorageItemAsync(new CefSharp.DevTools.DOMStorage.StorageId() { SecurityOrigin = "nacollector://home", IsLocalStorage = true }, "user", Newtonsoft.Json.JsonConvert.SerializeObject(new { token = ApiHelper.JwtToken }));
web.ExecuteScriptAsyncWhenPageLoaded(@$"window.getDatas();");
});
isInit = true;
}
private void grid_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F12)
{
web.ShowDevTools();
}
}
}
public class CatsAsyncJS
{
@ -63,5 +89,10 @@ namespace 齐越慧眼.UserControls
MainWindow.Main.ChangeTab(keyWord, int.Parse(type));
}
public string getToken()
{
return ApiHelper.JwtToken;
}
}
}

3
客户端/齐越慧眼/齐越慧眼/UserControls/ItemControl.xaml

@ -7,6 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="grid">
<Grid x:Name="grid" DockPanel.Dock="Bottom">
</Grid>
</UserControl>

36
客户端/齐越慧眼/齐越慧眼/UserControls/ItemControl.xaml.cs

@ -36,8 +36,42 @@ namespace 齐越慧眼.UserControls
},
};
web.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
web.JavascriptObjectRepository.Register("hyCoreModel", new CatsAsyncJS(), BindingOptions.DefaultBinder);
grid.Children.Add(web);
web.ExecuteScriptAsyncWhenPageLoaded(@$"localStorage.setItem('user', '{{""token"":""{ApiHelper.JwtToken}""}}');window.getDatas(0);");
// web.ExecuteScriptAsyncWhenPageLoaded(@$"localStorage.setItem('user', '{{""token"":""{ApiHelper.JwtToken}""}}');window.getDatas(0);");
web.FrameLoadStart += Web_FrameLoadStart;
}
bool isInit = false;
private void Web_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
{
if (isInit)
return;
Application.Current.Dispatcher.Invoke(() =>
{
web.WebBrowser.GetDevToolsClient().DOMStorage.SetDOMStorageItemAsync(new CefSharp.DevTools.DOMStorage.StorageId()
{
SecurityOrigin = "nacollector://home",
IsLocalStorage = true
}, "user",
Newtonsoft.Json.JsonConvert.SerializeObject(new { token= ApiHelper.JwtToken })
);
web.ExecuteScriptAsyncWhenPageLoaded(@$"window.getDatas(0);");
});
isInit = true;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
web.ShowDevTools();
}
}

4
客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/cats/Index.vue

@ -102,10 +102,10 @@
},
mounted() {
window.getDatas = this.getDatas
this.getDatas()
//this.getDatas()
},
activated() {
this.getDatas()
//this.getDatas()
},
methods: {
getKeyColor(keyword)

4
客户端/齐越慧眼/齐越慧眼/vuepage/client/src/views/items/Index.vue

@ -229,10 +229,10 @@
},
mounted() {
window.getDatas = this.getDatas
this.getDatas(0)
// this.getDatas(0)
},
activated() {
this.getDatas(0)
//this.getDatas(0)
},
methods: {
changeTab(e) {

2
客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js

File diff suppressed because one or more lines are too long

2
客户端/齐越慧眼/齐越慧眼/vuepage/dist/js/app.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save