Skip to content

Commit

Permalink
feat: 打包为jar包完成
Browse files Browse the repository at this point in the history
  • Loading branch information
yagol2020 committed Nov 17, 2021
1 parent 59c9d36 commit 5594f54
Show file tree
Hide file tree
Showing 18 changed files with 493 additions and 63 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>
config/base.yaml
</exclude>
</excludes>
</testResource>
<testResource>
<directory>
src/test/resources
</directory>
<includes>
<include>
config/base.yaml
</include>
</includes>
</testResource>
</testResources>
</build>
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/config/MyConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package config;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.setting.yaml.YamlUtil;
import config.property.ChromeProperties;
import lombok.Data;
import param.NormalParam;

/**
* @author yagol
* @TIME 2021/11/17 - 7:16 下午
* @Description 配置类获取类
**/
@Data
public class MyConfig {
ChromeProperties chrome;

/**
* 初始化config,并获得jar外部的config
*
* @param configSavePath
* @return
*/
public static MyConfig initConfig(String configSavePath) {
MyConfig config = YamlUtil.loadByPath("config/" + NormalParam.CONFIG_FILE_NAME, MyConfig.class);
return createOrUpdateConfig(config, configSavePath);
}

/**
* 在不修改的情况下,获得config
*
* @param configPath
* @return
*/
public static MyConfig getConfig(String configPath) {
return YamlUtil.loadByPath(configPath + NormalParam.CONFIG_FILE_NAME, MyConfig.class);
}

/**
* 将传进来的config保存到制定文件中
*
* @param config
* @param configPath
* @return
*/
public static MyConfig createOrUpdateConfig(MyConfig config, String configPath) {
YamlUtil.dump(config,
FileUtil.getWriter
(configPath + NormalParam.CONFIG_FILE_NAME,
CharsetUtil.CHARSET_UTF_8,
false
)
);
return getConfig(configPath);
}
}
13 changes: 13 additions & 0 deletions src/main/java/config/property/ChromeProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package config.property;

import lombok.Data;

/**
* @author yagol
* @TIME 2021/11/17 - 7:21 下午
* @Description
**/
@Data
public class ChromeProperties {
String driverPath;
}
81 changes: 81 additions & 0 deletions src/main/java/gui/designer/HelpGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,85 @@ public void show() {
frame.setVisible(true);
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
mainPanel.setPreferredSize(new Dimension(500, 300));
helpPanel = new JPanel();
helpPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(helpPanel, gbc);
helpTextArea = new JTextArea();
helpPanel.add(helpTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(panel1, gbc);
final JLabel label1 = new JLabel();
label1.setText("关于");
panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
aboutPanel = new JPanel();
aboutPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(aboutPanel, gbc);
aboutTextArea = new JTextArea();
aboutPanel.add(aboutTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(panel2, gbc);
final JLabel label2 = new JLabel();
label2.setText("帮助");
panel2.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
closeButton = new JButton();
closeButton.setText("关闭");
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 4;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainPanel.add(closeButton, gbc);
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return mainPanel;
}
}
36 changes: 35 additions & 1 deletion src/main/java/gui/designer/MainGui.form
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</component>
</children>
</grid>
<grid id="86db6" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="86db6" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand All @@ -95,6 +95,40 @@
<text value="关于&amp;帮助"/>
</properties>
</component>
<grid id="ec87b" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="397" class="javax.swing.JTextField" binding="driverFilePath">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="4a495" class="javax.swing.JButton" binding="driverChoseButton">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="选择驱动"/>
</properties>
</component>
<component id="d630" class="javax.swing.JLabel" binding="driverChoseLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="浏览器驱动(目前仅支持chrome)"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
Expand Down
Loading

0 comments on commit 5594f54

Please sign in to comment.