diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 6909e56..ced5e69 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -10,4 +10,9 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 7f10861..c7d51b2 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -6,6 +6,11 @@
+
+
+
+
+
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..797acea
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/back_config.setting b/back_config.setting
new file mode 100644
index 0000000..3a52515
--- /dev/null
+++ b/back_config.setting
@@ -0,0 +1,5 @@
+[]
+tokenText =
+pathText =
+folderText =
+backType = 0
diff --git a/pom.xml b/pom.xml
index cc3f7db..f0b4fc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,16 @@
flatlaf
0.26
+
+ org.opencb.opencga
+ opencga
+ 2.0.5
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 3.0.0
+
@@ -85,7 +95,21 @@
maven-project-info-reports-plugin
3.0.0
+
+ maven-compiler-plugin
+
+
+ ${jdk-target.version}
+ UTF-8
+
+
+ src/main/webapp/WEB-INF/lib/
+
+
+ ${maven-compiler-plugin.version}
+
+
diff --git a/src/main/java/com/eg/www/AliYunPan.java b/src/main/java/com/eg/www/AliYunPan.java
index a16f522..e192532 100644
--- a/src/main/java/com/eg/www/AliYunPan.java
+++ b/src/main/java/com/eg/www/AliYunPan.java
@@ -6,11 +6,13 @@ import cn.hutool.setting.Setting;
import com.eg.www.common.CommonConstants;
import com.eg.www.common.utils.AliYunPanUtil;
import com.eg.www.common.utils.FileUtil;
+import com.eg.www.common.utils.Login;
import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.awt.event.*;
+import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
/**
@@ -51,6 +53,16 @@ public class AliYunPan extends JFrame implements ActionListener {
// 迭代二单选框
private JRadioButton fenLeiRadio;
+/*
+ //登陆按钮
+ private JButton loginBtn = CommonConstants.loginBtn;
+ //账号框
+ private JTextField usernameText = CommonConstants.userNameText;
+ //密码框
+ private JTextField pwdText = CommonConstants.pwdText;
+
+*/
+
// 开始备份
private JButton startBackup = CommonConstants.startBackup;
// 暂停备份
@@ -130,13 +142,16 @@ public class AliYunPan extends JFrame implements ActionListener {
*/
JLabel pathTitle = new JLabel("选择目录");
pathText = new JTextField();
+
JLabel tokenTitle = new JLabel("Token");
//tokenText = new JTextField();
JLabel folderTitle = new JLabel("备份目录名称");
folderText = new JTextField();
+
JLabel backTitle = new JLabel("备份模式");
backTitle.setBounds(title_left, 150, title_width, title_high);
container.add(backTitle);
+
// 路径选择区域
JPanel selectPanle = new JPanel();
selectPanle.setLayout(null);
@@ -262,6 +277,7 @@ public class AliYunPan extends JFrame implements ActionListener {
//暂停按钮
if (e.getSource() == pauseBackup) {
+ aliYunPanUtil.stopBackup();
JOptionPane.showMessageDialog(null, "此功能正在开发中...", "提示", JOptionPane.INFORMATION_MESSAGE);
}
}
diff --git a/src/main/java/com/eg/www/common/CommonConstants.java b/src/main/java/com/eg/www/common/CommonConstants.java
index cd79eb6..24b3ac9 100644
--- a/src/main/java/com/eg/www/common/CommonConstants.java
+++ b/src/main/java/com/eg/www/common/CommonConstants.java
@@ -24,6 +24,17 @@ public class CommonConstants {
public static JScrollBar scrollBar = consolePane.getVerticalScrollBar();
// Token文本框
public static JTextField tokenText = new JTextField();
+/*
+
+ // 账号框
+ public static JTextField userNameText = new JTextField();
+ // 密码框
+ public static JTextField pwdText = new JTextField();
+ //登陆按钮
+ public static JButton loginBtn = new JButton("登陆");
+
+*/
+
//开始备份按钮
public static JButton startBackup = new JButton("开始备份");
//当前路径
diff --git a/src/main/java/com/eg/www/common/utils/AliYunPanUtil.java b/src/main/java/com/eg/www/common/utils/AliYunPanUtil.java
index 4e331b3..9e1ace8 100644
--- a/src/main/java/com/eg/www/common/utils/AliYunPanUtil.java
+++ b/src/main/java/com/eg/www/common/utils/AliYunPanUtil.java
@@ -76,6 +76,16 @@ public class AliYunPanUtil{
return;
}
+ /**
+ * 暂停备份
+ */
+ public void stopBackup() {
+ CommonConstants.addConsole("暂停成功");
+ startBackup.setText("开始暂停");
+ startBackup.setEnabled(false);
+ CommonConstants.BACK_STATE = false;
+ }
+
/**
* 上传二级文件夹
* @param fileId
diff --git a/src/main/java/com/eg/www/common/utils/Login.java b/src/main/java/com/eg/www/common/utils/Login.java
new file mode 100644
index 0000000..b0cc443
--- /dev/null
+++ b/src/main/java/com/eg/www/common/utils/Login.java
@@ -0,0 +1,70 @@
+package com.eg.www.common.utils;
+
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.interactions.Actions;
+
+import javax.swing.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author: Eg
+ * @Date: 2021/9/8 13:19
+ */
+public class Login {
+
+
+ /**
+ * @param user 用户名
+ * @param pwd 密码
+ * @return token
+ */
+ public static String getToken(String user, String pwd) throws InterruptedException {
+
+ System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
+ //谷歌浏览器
+ WebDriver driver = new ChromeDriver();
+ //设置访问网址
+ String baseurl = "https://www.aliyundrive.com/sign/in?spm=aliyundrive.index.0.0.2d836020snGCDV";
+
+ driver.get(baseurl);
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+ WebElement loginFrame = driver.findElement(By.className("login-frame")).findElement(By.tagName("iframe"));
+ WebElement frame = driver.switchTo().frame(loginFrame).findElement(By.id("alibaba-login-box"));
+ //点击切换到账号登陆
+ driver.switchTo().frame(frame).findElement(By.className("block0")).findElements(By.className("sms-login-link")).get(0).click();
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+
+ //账号框 && 密码框
+ driver.findElement(By.name("fm-login-id")).sendKeys(user);
+ driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
+ driver.findElement(By.name("fm-login-password")).sendKeys(pwd);
+
+ Thread.sleep(2000L);
+
+ //登陆按钮
+ driver.findElement(By.className("password-login")).click();
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+ //滑动验证
+ WebDriver yzm = driver.switchTo().frame("baxia-dialog-content");
+ WebElement moveButton = yzm.findElement(By.id("nc_1_n1z"));
+
+ Actions action = new Actions(yzm);
+ //移到滑块元素并悬停
+ action.moveToElement(moveButton).clickAndHold(moveButton);
+ action.dragAndDropBy(moveButton,270, 0).perform();
+ action.release();
+
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+
+ //执行js脚本
+ String getToken = "JSON.parse(localStorage.getItem('token'))."+"refresh_token";
+
+ return ((JavascriptExecutor) driver).executeScript(getToken).toString();
+ }
+
+}
diff --git a/src/main/java/com/eg/www/common/utils/OkHttpUtil.java b/src/main/java/com/eg/www/common/utils/OkHttpUtil.java
index e7cb768..6f38831 100644
--- a/src/main/java/com/eg/www/common/utils/OkHttpUtil.java
+++ b/src/main/java/com/eg/www/common/utils/OkHttpUtil.java
@@ -26,7 +26,7 @@ public class OkHttpUtil {
/**
* 阿里云盘交互的POST请求
- * @param url
+ * @param url https://websv.aliyundrive.com/token/refresh
* @param data
* @return
* @throws Exception
@@ -65,7 +65,7 @@ public class OkHttpUtil {
/**
* 阿里云盘上传文件的POST请求
- * @param url
+ * @param url https://api.aliyundrive.com/v2/file/create
* @param data
* @return
* @throws Exception
diff --git a/src/main/java/com/eg/www/common/utils/getToken.java b/src/main/java/com/eg/www/common/utils/getToken.java
deleted file mode 100644
index a3eb4c4..0000000
--- a/src/main/java/com/eg/www/common/utils/getToken.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.eg.www.common.utils;
-
-/**
- * @author: Eg
- * @Date: 2021/8/29 17:50
- */
-public class getToken {
-
-
-}
diff --git a/src/main/resources/chromedriver.exe b/src/main/resources/chromedriver.exe
new file mode 100644
index 0000000..f71a567
Binary files /dev/null and b/src/main/resources/chromedriver.exe differ
diff --git a/target/classes/chromedriver.exe b/target/classes/chromedriver.exe
new file mode 100644
index 0000000..f71a567
Binary files /dev/null and b/target/classes/chromedriver.exe differ
diff --git a/target/classes/com/eg/www/AliYunPan$1.class b/target/classes/com/eg/www/AliYunPan$1.class
index 78f34e7..3dd837d 100644
Binary files a/target/classes/com/eg/www/AliYunPan$1.class and b/target/classes/com/eg/www/AliYunPan$1.class differ
diff --git a/target/classes/com/eg/www/AliYunPan$2.class b/target/classes/com/eg/www/AliYunPan$2.class
index 6d0447f..62cb8ae 100644
Binary files a/target/classes/com/eg/www/AliYunPan$2.class and b/target/classes/com/eg/www/AliYunPan$2.class differ
diff --git a/target/classes/com/eg/www/AliYunPan.class b/target/classes/com/eg/www/AliYunPan.class
index b949832..4127301 100644
Binary files a/target/classes/com/eg/www/AliYunPan.class and b/target/classes/com/eg/www/AliYunPan.class differ
diff --git a/target/classes/com/eg/www/common/CommonConstants.class b/target/classes/com/eg/www/common/CommonConstants.class
index cab59ab..e064970 100644
Binary files a/target/classes/com/eg/www/common/CommonConstants.class and b/target/classes/com/eg/www/common/CommonConstants.class differ
diff --git a/target/classes/com/eg/www/common/utils/AliYunPanUtil$1.class b/target/classes/com/eg/www/common/utils/AliYunPanUtil$1.class
index a2a9bc2..73013a6 100644
Binary files a/target/classes/com/eg/www/common/utils/AliYunPanUtil$1.class and b/target/classes/com/eg/www/common/utils/AliYunPanUtil$1.class differ
diff --git a/target/classes/com/eg/www/common/utils/AliYunPanUtil.class b/target/classes/com/eg/www/common/utils/AliYunPanUtil.class
index b8307ca..663d21b 100644
Binary files a/target/classes/com/eg/www/common/utils/AliYunPanUtil.class and b/target/classes/com/eg/www/common/utils/AliYunPanUtil.class differ
diff --git a/target/classes/com/eg/www/common/utils/Login.class b/target/classes/com/eg/www/common/utils/Login.class
new file mode 100644
index 0000000..13753b5
Binary files /dev/null and b/target/classes/com/eg/www/common/utils/Login.class differ
diff --git a/target/classes/com/eg/www/common/utils/getToken.class b/target/classes/com/eg/www/common/utils/getToken.class
deleted file mode 100644
index ee6da02..0000000
Binary files a/target/classes/com/eg/www/common/utils/getToken.class and /dev/null differ