public override void Startup(IService service) { Instance = this; var configInfo = Utils.GetConfigInfo(); service .AddDatabaseTable(GroupDao.TableName, GroupDao.Columns) .AddDatabaseTable(GroupUserDao.TableName, GroupUserDao.Columns) .AddDatabaseTable(OAuthDao.TableName, OAuthDao.Columns) .AddDatabaseTable(MenuDao.TableName, MenuDao.Columns) .AddStlElementParser(StlHome.ElementName, StlHome.Parse) .AddPluginMenu(new Menu { Text = "用户中心", Href = configInfo.HomeUrl, Target = "_blank", Menus = new List <Menu> { new Menu { Text = "用户中心设置", Href = $"{nameof(PageSettings)}.aspx" }, new Menu { Text = "用户投稿设置", Href = $"{nameof(PageWriting)}.aspx" }, new Menu { Text = "扩展菜单设置", Href = $"{nameof(PageMenu)}.aspx" }, //new Menu //{ // Text = "进入用户中心", // Href = FilesApi.GetRootUrl("home"), // Target = "_blank" //} } }) ; service.ApiGet += Service_ApiGet; service.ApiPost += Service_ApiPost; var homeDirectoryPath = Path.Combine(PhysicalApplicationPath, "home"); var versionFilePath = Path.Combine(homeDirectoryPath, $"{Version}.txt"); if (!Utils.IsDirectoryExists(homeDirectoryPath) || !Utils.IsFileExists(versionFilePath)) { Utils.DeleteDirectoryIfExists(homeDirectoryPath); var distDirectoryPath = PluginApi.GetPluginPath("dist"); Utils.CopyDirectory(distDirectoryPath, homeDirectoryPath, true); var indexHtml = Utils.ReadText(Path.Combine(distDirectoryPath, "index.html"), Encoding.UTF8); indexHtml = Regex.Replace(indexHtml, "domainAPI:\"[^\"]*\"", $@"domainAPI:""{PluginApi.GetPluginApiUrl()}"""); Utils.WriteText(Path.Combine(homeDirectoryPath, "index.html"), indexHtml); Utils.WriteText(versionFilePath, DateTime.Now.ToString(CultureInfo.CurrentCulture)); } }
public void Init() { instance = new PluginApi(); }
public void _Load(string name) { flowLayoutPanel1.Controls.Clear(); List <PluginHelper.SubtitleWebList> zimuDATA = null; Action _action = () => { try { zimuDATA = PluginApi.SubtitleWebSearch(name); } catch (Exception ez) { Api.OpenMessage(this, MessageType.Error, ez.Message); } }; _task.ContinueWhenAll(new Task[] { _task.StartNew(_action) }, (action => { int width = flowLayoutPanel1.Width - 30; int width2 = width - 108 - 12; if (zimuDATA != null && zimuDATA.Count > 0) { this.Invoke(new Action(() => { foreach (var zimu1 in zimuDATA) { int he = zimu1.data.Count * 40; Panel panel4 = new Panel { Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, Location = new Point(112, 66), Size = new Size(width - 130, he) }; foreach (var zimu in zimu1.data) { PictureBox pictureBox3 = new PictureBox { InitialImage = Image, Dock = DockStyle.Left, ImageLocation = zimu.imgsrc, Size = new Size(28, 40), SizeMode = PictureBoxSizeMode.Zoom }; Label label4 = new Label { AutoEllipsis = true, Dock = DockStyle.Fill, Font = new Font("微软雅黑", 9F, FontStyle.Bold), Location = new Point(28, 0), Size = new Size(336, 40), Text = zimu.title, TextAlign = ContentAlignment.MiddleLeft, }; Label label5 = new Label { AutoSize = true, Dock = DockStyle.Right, Font = new Font("微软雅黑", 8F), Text = "下载:" + zimu.down, TextAlign = ContentAlignment.MiddleCenter, }; Label label6 = new Label { AutoEllipsis = true, Dock = DockStyle.Right, Font = new Font("微软雅黑", 9F, FontStyle.Bold), Size = new Size(40, 40), Text = zimu.type + "分", TextAlign = ContentAlignment.MiddleCenter, }; if (zimu.type == 0) { label6.ForeColor = Color.DarkGray; } else if (zimu.type > 8) { label6.ForeColor = Color.Lime; } else if (zimu.type > 4) { label6.ForeColor = Color.Orange; } ProgressBar progressBar = new ProgressBar { Size = new Size(0, 2), Visible = false, Dock = DockStyle.Bottom }; Panel panel5 = new Panel { Dock = DockStyle.Top, Location = new Point(0, 0), Size = new Size(0, 40), }; panel5.Controls.Add(progressBar); panel5.Controls.Add(label4); panel5.Controls.Add(label6); panel5.Controls.Add(label5); panel5.Controls.Add(pictureBox3); this.metroToolTip1.SetToolTip(pictureBox3, zimu.imgalt); panel4.Controls.Add(panel5); #region 效果 pictureBox3.MouseEnter += (a, b) => { panel5.BackColor = Color.White; }; panel5.MouseEnter += (a, b) => { panel5.BackColor = Color.White; }; label4.MouseEnter += (a, b) => { panel5.BackColor = Color.White; }; label5.MouseEnter += (a, b) => { panel5.BackColor = Color.White; }; label6.MouseEnter += (a, b) => { panel5.BackColor = Color.White; }; pictureBox3.MouseLeave += (a, b) => { panel5.BackColor = panel4.BackColor; }; panel5.MouseLeave += (a, b) => { panel5.BackColor = panel4.BackColor; }; label4.MouseLeave += (a, b) => { panel5.BackColor = panel4.BackColor; }; label5.MouseLeave += (a, b) => { panel5.BackColor = panel4.BackColor; }; label6.MouseLeave += (a, b) => { panel5.BackColor = panel4.BackColor; }; string downPath = zimu1.title + "_" + zimu.url.Md5_16(); pictureBox3.Click += (a, b) => { DownZimu(downPath, panel5, progressBar, zimu.url); }; panel5.Click += (a, b) => { DownZimu(downPath, panel5, progressBar, zimu.url); }; label4.Click += (a, b) => { DownZimu(downPath, panel5, progressBar, zimu.url); }; label5.Click += (a, b) => { DownZimu(downPath, panel5, progressBar, zimu.url); }; label6.Click += (a, b) => { DownZimu(downPath, panel5, progressBar, zimu.url); }; #endregion } PictureBox pictureBox1 = new PictureBox { InitialImage = Image, ImageLocation = zimu1.img, Location = new Point(12, 12), Size = new Size(90, 126), SizeMode = PictureBoxSizeMode.Zoom }; Label label2 = new Label { AutoEllipsis = true, Font = new Font("微软雅黑", 10F, FontStyle.Bold), Location = new Point(108, 12), Size = new Size(width2, 20), Text = zimu1.title, }; Label label3 = new Label { AutoEllipsis = true, Location = new Point(108, 42), Size = new Size(width2, 18), Text = "又名:" + zimu1.intro, TextAlign = ContentAlignment.MiddleLeft, }; Panel panel2 = new Panel { Size = new Size(width, 100 + he), }; panel2.Controls.Add(panel4); if (!string.IsNullOrEmpty(zimu1.intro)) { panel2.Controls.Add(label3); } panel2.Controls.Add(label2); panel2.Controls.Add(pictureBox1); flowLayoutPanel1.Controls.Add(panel2); } frmSearch1.Visible = false; })); } else { frmSearch1.Visible = true; } })); }