using CefSharp.WinForms; using TemuKJD.KJDForms.BaseForms; using NaiBa.CefHelper; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TemuKJD.KJDForms.ToolForms { public partial class DouUserLoginForm : LRBaseForm { string url = "https://creator.douyin.com/"; ChromiumWebBrowser cefWebBrowser = null; public DouUserLoginForm() { InitializeComponent(); } public DouUserLoginForm(string _url) { InitializeComponent(); this.url = _url; //"https://buyin.jinritemai.com/mpa/account/login?log_out=1&type=24"; } private void DouUserLogin_Load(object sender, EventArgs e) { InitCef(); } private void InitCef() { this.cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser(this.url, false); this.cefWebBrowser.FrameLoadEnd += ChromiumWebBrowser_FrameLoadEnd; this.cefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged; this.splitContainer1.Panel2.Controls.Clear(); this.splitContainer1.Panel2.Controls.Add(this.cefWebBrowser); this.cefWebBrowser.Dock = DockStyle.Fill; if (!string.IsNullOrEmpty(AllBase.Helper.GlobalConfig.DouUserCookies) && this.url.Contains("creator.douyin.com")) { var t = CEFBrowser.SetCookieAsync(AllBase.Helper.GlobalConfig.DouUserCookies, cefWebBrowser.RequestContext.GetCookieManager(null)); t.Wait(5000); } this.btnIsLogin.BringToFront(); } private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e) { Invoke(new Action(() => { this.textBox1.Text = e.Address; })); } private void ChromiumWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e) { } private void btnIsLogin_Click(object sender, EventArgs e) { if (this.url.Contains("creator.douyin.com")) { AllBase.Helper.GlobalConfig.DouUserCookies = CEFBrowser.GetCookie("", cefWebBrowser.RequestContext.GetCookieManager(null)); StartUp.SaveDouUserCookies(); } else if (this.url.Contains("buyin.jinritemai.com")) { AllBase.Helper.GlobalConfig.DouBuyinCookies = CEFBrowser.GetCookie("", cefWebBrowser.RequestContext.GetCookieManager(null)); StartUp.SaveDouBuyinCookies(); } this.Close(); } } }