Compare commits
19 Commits
62831348e4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bc9f82cc8d | |||
| 3f88a20557 | |||
| 1b61722446 | |||
| 2183444676 | |||
| 6c4fbc47ab | |||
| 10c6967869 | |||
| cf5e4f56e7 | |||
| af8cf21705 | |||
| 8b1a2c86c6 | |||
| bad29d16f3 | |||
| c2195c287a | |||
| b653c52669 | |||
| abb67eaf9c | |||
| 4cb79b83cd | |||
| a2b6fc8663 | |||
| 9b4557a297 | |||
| dfd1c9b35b | |||
| 5254acf82a | |||
| c284931d1d |
8
pom.xml
8
pom.xml
@@ -47,7 +47,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.7.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.8</version>
|
||||
<version>2.0.12</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
|
||||
<dependency>
|
||||
@@ -93,13 +93,13 @@
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.15.0</version>
|
||||
<version>3.15.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.36.0.3</version>
|
||||
<version>3.39.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ToolsApplication {
|
||||
public static final String version="1.4.7";
|
||||
public static final String version="1.5.2";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("当前版本号:" + version);
|
||||
|
||||
51
src/main/java/com/yutou/tools/bean/CalendarTask.java
Normal file
51
src/main/java/com/yutou/tools/bean/CalendarTask.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.yutou.tools.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@Data
|
||||
public class CalendarTask {
|
||||
public static final int TYPE_DAY=Calendar.DATE;
|
||||
public static final int TYPE_WEEK=Calendar.WEEK_OF_MONTH;
|
||||
public static final int TYPE_MONTH=Calendar.MONTH;
|
||||
|
||||
public static final int MODEL_ONE=0;
|
||||
public static final int MODEL_LOOP=1;
|
||||
|
||||
private int id;
|
||||
private int type;
|
||||
private int model=MODEL_ONE;
|
||||
private String title;
|
||||
private String content;
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
private int time;
|
||||
private boolean qqbot;
|
||||
|
||||
public Date getEndTime() {
|
||||
if(endTime==null){
|
||||
Calendar calendar=Calendar.getInstance(Locale.CHINA);
|
||||
calendar.setTime(new Date());
|
||||
calendar.set(Calendar.MONTH,calendar.get(Calendar.MONTH)+1);
|
||||
endTime= calendar.getTime();
|
||||
}
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
if(startTime==null){
|
||||
startTime=new Date();
|
||||
}
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
if(time==0){
|
||||
time = (int) ((getEndTime().getTime() - getStartTime().getTime())/1000/60/60/24);
|
||||
}
|
||||
return time;
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/yutou/tools/bean/QQTimerTaskBean.java
Normal file
15
src/main/java/com/yutou/tools/bean/QQTimerTaskBean.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.yutou.tools.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class QQTimerTaskBean implements Serializable {
|
||||
private UUID uuid;
|
||||
private Date timer;
|
||||
private long qqNumber;
|
||||
private Object task;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import java.util.UUID;
|
||||
|
||||
@Controller
|
||||
public class NasManager {
|
||||
public static String NasUrl="http://yutou233.cn";
|
||||
public static String NasUrl="https://nas.yutou233.cn";
|
||||
static {
|
||||
if ("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
|
||||
NasUrl="http://192.168.31.88";
|
||||
@@ -184,7 +184,7 @@ public class NasManager {
|
||||
json.put("data", NasUrl + ":8000");
|
||||
} else {
|
||||
if (UpdateIp.nas_ip == null) {
|
||||
json.put("data", "http://yutou233.cn:8001");
|
||||
json.put("data", "http://nas.yutou233.cn:8001");
|
||||
} else {
|
||||
json.put("data", String.format("http://%s:8000", UpdateIp.nas_ip));
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class NasManager {
|
||||
json.put("data", NasUrl + ":8000/nas/music/list.do?token=");
|
||||
} else {
|
||||
if (UpdateIp.nas_ip == null) {
|
||||
json.put("data", "http://yutou233.cn:8001/nas/music/list.do?token=");
|
||||
json.put("data", "http://nas.yutou233.cn:8001/nas/music/list.do?token=");
|
||||
} else {
|
||||
json.put("data", String.format("http://%s:8000/nas/music/list.do?token=", UpdateIp.nas_ip));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.regex.Pattern;
|
||||
@Controller
|
||||
public class UpdateIp {
|
||||
private static List<String> keys = new ArrayList<>();
|
||||
public static String nas_ip=null;
|
||||
public static String nas_ip="nas.yutou233.cn";
|
||||
static {
|
||||
if ("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
|
||||
nas_ip="192.168.31.88";
|
||||
|
||||
88
src/main/java/com/yutou/tools/other/CalendarController.java
Normal file
88
src/main/java/com/yutou/tools/other/CalendarController.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.yutou.tools.other;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyuncs.utils.StringUtils;
|
||||
import com.yutou.tools.bean.CalendarTask;
|
||||
import com.yutou.tools.utils.CalendarTools;
|
||||
import com.yutou.tools.utils.RedisTools;
|
||||
import com.yutou.tools.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
public class CalendarController {
|
||||
@ResponseBody
|
||||
@RequestMapping("/calendar/all.do")
|
||||
public JSONObject getCalendar(){
|
||||
JSONObject json = new JSONObject();
|
||||
JSONObject holiday= CalendarTools.getHoliday();
|
||||
json.put("data",holiday);
|
||||
return json;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/calendar/set.do")
|
||||
public JSONObject setCalendar(String startDate
|
||||
,String title
|
||||
,String content
|
||||
,String type
|
||||
,String model
|
||||
,String day
|
||||
,String qqbot
|
||||
){
|
||||
JSONObject json = new JSONObject();
|
||||
String[] dates=startDate.split(" - ");
|
||||
Date sDate = Tools.timeToDate(dates[0].split(" ")[0], dates[0].split(" ")[1]);
|
||||
Date endDate = Tools.timeToDate(dates[1].split(" ")[0], dates[1].split(" ")[1]);
|
||||
CalendarTask task=new CalendarTask();
|
||||
task.setModel(Integer.parseInt(model));
|
||||
task.setType(Integer.parseInt(type));
|
||||
task.setTitle(title);
|
||||
task.setContent(content);
|
||||
task.setStartTime(sDate);
|
||||
task.setEndTime(endDate);
|
||||
task.setTime(Integer.parseInt(day));
|
||||
task.setQqbot(!StringUtils.isEmpty(qqbot));
|
||||
CalendarTools.addTask(task);
|
||||
json.put("code",0);
|
||||
json.put("msg","任务添加成功");
|
||||
json.put("data",task);
|
||||
return json;
|
||||
}
|
||||
@RequestMapping("/calendar/list.do")
|
||||
@ResponseBody
|
||||
public JSONObject list(){
|
||||
JSONObject json=new JSONObject();
|
||||
JSONArray array=new JSONArray();
|
||||
Set<String> set = RedisTools.list_get(CalendarTools.REDIS_TAG);
|
||||
for (String s : set) {
|
||||
JSONObject task = JSONObject.parseObject(s);
|
||||
array.add(task);
|
||||
}
|
||||
json.put("code",0);
|
||||
json.put("msg","ok");
|
||||
json.put("data",array);
|
||||
return json;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/calendar/del.do")
|
||||
public JSONObject del(int id){
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("msg","删除失败");
|
||||
Set<String> set = RedisTools.list_get(CalendarTools.REDIS_TAG);
|
||||
for (String s : set) {
|
||||
CalendarTask calendar=JSONObject.parseObject(s,CalendarTask.class);
|
||||
if(calendar.getId()==id){
|
||||
json.put("msg","删除成功");
|
||||
RedisTools.list_remove(CalendarTools.REDIS_TAG,s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
json.put("code",0);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,15 @@ import com.yutou.tools.utils.ConfigTools;
|
||||
import com.yutou.tools.utils.HttpTools;
|
||||
import com.yutou.tools.utils.RedisTools;
|
||||
import com.yutou.tools.utils.Tools;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.Cookie;
|
||||
@@ -25,8 +27,11 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Controller
|
||||
public class tools {
|
||||
@@ -66,9 +71,16 @@ public class tools {
|
||||
return ToolsApplication.version;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@ResponseBody
|
||||
@RequestMapping("/public/request.do")
|
||||
|
||||
public String testRequest(HttpServletRequest request) {
|
||||
return testRequest(request, null);
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/public/file/request.do")
|
||||
public String testRequest(HttpServletRequest request, @RequestParam("file")MultipartFile file) {
|
||||
JSONObject params = new JSONObject();
|
||||
JSONArray cookies = new JSONArray();
|
||||
JSONObject header = new JSONObject();
|
||||
@@ -81,11 +93,26 @@ public class tools {
|
||||
cookies.add(ck);
|
||||
}
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
BufferedInputStream stream = new BufferedInputStream(request.getInputStream());
|
||||
byte[] bytes = new byte[1024];
|
||||
int len = 0, size;
|
||||
while ((len = stream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, len);
|
||||
outputStream.flush();
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Enumeration<String> enumeration = request.getHeaderNames();
|
||||
while (enumeration != null && enumeration.hasMoreElements()) {
|
||||
String tmp = enumeration.nextElement();
|
||||
header.put(tmp, request.getHeader(tmp));
|
||||
}
|
||||
String str = outputStream.toString(StandardCharsets.UTF_8);
|
||||
System.out.println("str = " + str);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("method", request.getMethod());
|
||||
@@ -95,6 +122,15 @@ public class tools {
|
||||
json.put("params", params);
|
||||
json.put("cookie", cookies);
|
||||
json.put("header", header);
|
||||
System.out.println("json = " + json);
|
||||
// Tools.sendServer("打印请求", json.toJSONString());
|
||||
if(file!=null){
|
||||
try {
|
||||
Tools.createFile("tmp",file,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(new Date())+".zip");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Tools.sendServer("打印请求", json.toJSONString());
|
||||
try {
|
||||
switch (RedisTools.get("request")) {
|
||||
@@ -148,30 +184,34 @@ public class tools {
|
||||
Tools.sendServer(title, msg);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/tools/clash/get.do",produces ="text/plain;charset=utf-8")
|
||||
public String getClash(){
|
||||
StringBuilder builder=new StringBuilder();
|
||||
String ssrUrl=RedisTools.get("ssr");
|
||||
String url="http://127.0.0.1:25500/sub?target=clash&new_name=true&url="+URLEncoder.encode(ssrUrl, StandardCharsets.UTF_8) +"&insert=false&config=https%3A%2F%2Fgit.yutou233.cn%2Fyutou%2FACL4SSR%2Fraw%2Fmaster%2FClash%2Fconfig%2FACL4SSR.ini";
|
||||
String text= HttpTools.get(url);
|
||||
if(text==null){
|
||||
@RequestMapping(value = "/tools/clash/get.do", produces = "text/plain;charset=utf-8")
|
||||
public String getClash(String ssr) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String ssrUrl = RedisTools.get("ssr");
|
||||
if (!StringUtils.isEmpty(ssr)) {
|
||||
ssrUrl = ssr;
|
||||
}
|
||||
String url = "http://127.0.0.1:25500/sub?target=clash&new_name=true&url=" + URLEncoder.encode(ssrUrl, StandardCharsets.UTF_8) + "&insert=false&config=https%3A%2F%2Fgit.yutou233.cn%2Fyutou%2FACL4SSR%2Fraw%2Fbranch%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online_Full.ini";
|
||||
String text = HttpTools.get(url);
|
||||
if (text == null) {
|
||||
System.out.println("ssr is Null = " + url);
|
||||
return "";
|
||||
}
|
||||
String[] tmp=text.split("\n");
|
||||
text=RedisTools.get("clash");
|
||||
String[] tmp = text.split("\n");
|
||||
text = RedisTools.get("clash");
|
||||
builder.append("mixed-port: 7890").append("\n");
|
||||
for (String s : tmp) {
|
||||
if("port: 7890".equals(s)||"socks-port: 7891".equals(s)){
|
||||
if ("port: 7890".equals(s) || "socks-port: 7891".equals(s)) {
|
||||
continue;
|
||||
}
|
||||
builder.append(s).append("\n");
|
||||
if("rules:".equals(s.trim())){
|
||||
if(text!=null){
|
||||
JSONArray array=JSONArray.parseArray(text);
|
||||
if ("rules:".equals(s.trim())) {
|
||||
if (text != null) {
|
||||
JSONArray array = JSONArray.parseArray(text);
|
||||
for (Object o : array) {
|
||||
builder.append(" ").append(((JSONObject)o).getString("url").trim()).append("\n");
|
||||
builder.append(" ").append(((JSONObject) o).getString("url").trim()).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,83 +219,106 @@ public class tools {
|
||||
return builder.toString();
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/tools/ssr/get.do", produces = "text/plain;charset=utf-8")
|
||||
public String getSSRUrl(){
|
||||
return (String) ConfigTools.load(ConfigTools.DATA,"ssr");
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/clash/ssr.do")
|
||||
public JSONObject setClashSSR(String url){
|
||||
RedisTools.set("ssr",url);
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("msg","OK~");
|
||||
public JSONObject setClashSSR(String url) {
|
||||
RedisTools.set("ssr", url);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("msg", "OK~");
|
||||
return json;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/clash/getssr.do")
|
||||
public JSONObject getClashSSR(){
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("code",0);
|
||||
json.put("data",RedisTools.get("ssr"));
|
||||
public JSONObject getClashSSR() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("data", RedisTools.get("ssr"));
|
||||
return json;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/clash/list.do")
|
||||
public JSONObject clashList(){
|
||||
String text=RedisTools.get("clash");
|
||||
public JSONObject clashList() {
|
||||
String text = RedisTools.get("clash");
|
||||
JSONArray array;
|
||||
if(text!=null){
|
||||
array=JSONArray.parseArray(text);
|
||||
}else{
|
||||
array=new JSONArray();
|
||||
if (text != null) {
|
||||
array = JSONArray.parseArray(text);
|
||||
} else {
|
||||
array = new JSONArray();
|
||||
}
|
||||
RedisTools.set("clash",array.toJSONString());
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("code",0);
|
||||
json.put("msg","ok~");
|
||||
json.put("data",array);
|
||||
return json;
|
||||
RedisTools.set("clash", array.toJSONString());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok~");
|
||||
json.put("data", array);
|
||||
return json;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/clash/add.do")
|
||||
public JSONObject clashAddUrl(String url){
|
||||
String text=RedisTools.get("clash");
|
||||
public JSONObject clashAddUrl(String url) {
|
||||
String text = RedisTools.get("clash");
|
||||
JSONArray array;
|
||||
if(text!=null){
|
||||
array=JSONArray.parseArray(text);
|
||||
}else{
|
||||
array=new JSONArray();
|
||||
if (text != null) {
|
||||
array = JSONArray.parseArray(text);
|
||||
} else {
|
||||
array = new JSONArray();
|
||||
}
|
||||
JSONObject data=new JSONObject();
|
||||
data.put("url",url);
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("url", url);
|
||||
array.add(data);
|
||||
RedisTools.set("clash",array.toJSONString());
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("code",0);
|
||||
json.put("msg","ok~");
|
||||
return json;
|
||||
RedisTools.set("clash", array.toJSONString());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok~");
|
||||
return json;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/clash/del.do")
|
||||
public JSONObject clashDelUrl(String url){
|
||||
String text=RedisTools.get("clash");
|
||||
public JSONObject clashDelUrl(String url) {
|
||||
String text = RedisTools.get("clash");
|
||||
JSONArray array;
|
||||
if(text!=null){
|
||||
array=JSONArray.parseArray(text);
|
||||
}else{
|
||||
array=new JSONArray();
|
||||
if (text != null) {
|
||||
array = JSONArray.parseArray(text);
|
||||
} else {
|
||||
array = new JSONArray();
|
||||
}
|
||||
int delIndex=-1;
|
||||
int delIndex = -1;
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject item=array.getJSONObject(i);
|
||||
if(item.getString("url").trim().equals(url.trim())){
|
||||
delIndex=i;
|
||||
JSONObject item = array.getJSONObject(i);
|
||||
if (item.getString("url").trim().equals(url.trim())) {
|
||||
delIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(delIndex!=-1){
|
||||
array.remove(delIndex);
|
||||
}
|
||||
RedisTools.set("clash",array.toJSONString());
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("code",0);
|
||||
json.put("msg","ok~");
|
||||
return json;
|
||||
if (delIndex != -1) {
|
||||
array.remove(delIndex);
|
||||
}
|
||||
RedisTools.set("clash", array.toJSONString());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok~");
|
||||
return json;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/public/tools/setu.do")
|
||||
public ResponseEntity<FileSystemResource> getSetu(String model){
|
||||
String url="https://api.lolicon.app/setu/v2?r18=0&size=regular";
|
||||
String body=HttpTools.get(url);
|
||||
JSONObject json=JSONObject.parseObject(body);
|
||||
if (json.getJSONArray("data").isEmpty()) {
|
||||
return Tools.getFile(new File("def_setu.png"));
|
||||
}
|
||||
JSONObject item = json.getJSONArray("data").getJSONObject(0);
|
||||
File file = HttpTools.syncDownload(item.getJSONObject("urls").getString("regular"),
|
||||
System.currentTimeMillis() + "_setu.jpg");
|
||||
return Tools.getFile(file);
|
||||
}
|
||||
public int getUid(HttpServletRequest request) {
|
||||
String token = request.getParameter("token");
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BangumiServiceImpl implements BangumiService {
|
||||
@Override
|
||||
public int addBangumiItem(BangumiItem... list) {
|
||||
for (BangumiItem item : list) {
|
||||
if (item.getId().equals(-1)) {
|
||||
if (item.getId() != null&&item.getId().equals(-1)) {
|
||||
RedisTools.list_add("anim_tmp_rss", JSON.toJSON(item).toString());
|
||||
} else if (itemDao.insert(item) <= 0) {
|
||||
return 0;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.yutou.tools.utils;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
@@ -14,9 +17,12 @@ import java.util.TimerTask;
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationInit implements ApplicationRunner {
|
||||
|
||||
@Resource
|
||||
private Environment environment;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
RedisTools.initConfig(environment.getProperty("redis.port",Integer.class,6379),
|
||||
environment.getProperty("redis.auth"));
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
110
src/main/java/com/yutou/tools/utils/CalendarTools.java
Normal file
110
src/main/java/com/yutou/tools/utils/CalendarTools.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package com.yutou.tools.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.tools.bean.CalendarTask;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public class CalendarTools {
|
||||
public static final String REDIS_TAG = "Calendar";
|
||||
public static final String REDIS_HOLIDAY = "holiday";
|
||||
|
||||
public static JSONObject getHoliday() {
|
||||
int year = Calendar.getInstance(DateFormat.getDateInstance().getTimeZone(), Locale.CHINA).get(Calendar.YEAR);
|
||||
return getHoliday(year + "");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static JSONObject getHoliday(String year) {
|
||||
String get;
|
||||
if(RedisTools.exists(REDIS_HOLIDAY)){
|
||||
get=RedisTools.get(REDIS_HOLIDAY);
|
||||
}else {
|
||||
get = HttpTools.get(String.format("https://timor.tech/api/holiday/year/%s", year));
|
||||
RedisTools.set(REDIS_HOLIDAY,get);
|
||||
}
|
||||
JSONObject json = JSONObject.parseObject(get);
|
||||
JSONObject date = new JSONObject();
|
||||
JSONArray dateHoliday = new JSONArray();
|
||||
JSONObject holiday = json.getJSONObject("holiday");
|
||||
JSONArray a1=new JSONArray();
|
||||
JSONArray a2=new JSONArray();
|
||||
for (CalendarTask task : getTasks()) {
|
||||
for (String datum : getMouthData(task)) {
|
||||
date.put(new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("yyyy-M-d").parse(datum.split(" ")[0])), task.getTitle());
|
||||
a1.add(datum.split(" ")[0]);
|
||||
a2.add(datum.split(" ")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (String key : holiday.keySet()) {
|
||||
JSONObject _tmp = holiday.getJSONObject(key);
|
||||
date.put(year + "-" + key, _tmp.getString("name"));
|
||||
String _key=new SimpleDateFormat("yyyy-M-d").format(new SimpleDateFormat("yyyy-MM-dd").parse(year + "-" + key));
|
||||
if(_tmp.getBooleanValue("holiday")){
|
||||
a1.add(_key);
|
||||
}else{
|
||||
a2.add(_key);
|
||||
}
|
||||
}
|
||||
dateHoliday.add(a1);
|
||||
dateHoliday.add(a2);
|
||||
JSONObject tmp = new JSONObject();
|
||||
tmp.put("date", date);
|
||||
tmp.put("holiday", dateHoliday);
|
||||
return tmp;
|
||||
}
|
||||
public static boolean addTask(CalendarTask task){
|
||||
task.setId(RedisTools.list_get(REDIS_TAG).size()+1);
|
||||
String json = JSONObject.toJSONString(task);
|
||||
RedisTools.list_add(REDIS_TAG,json);
|
||||
return true;
|
||||
}
|
||||
public static List<CalendarTask> getTasks(){
|
||||
List<CalendarTask> list=new ArrayList<>();
|
||||
Set<String> set = RedisTools.list_get(REDIS_TAG);
|
||||
for (String s : set) {
|
||||
list.add(JSONObject.parseObject(s,CalendarTask.class));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static boolean removeTask(CalendarTask task){
|
||||
for (String s : RedisTools.list_get(REDIS_TAG)) {
|
||||
CalendarTask tmp=JSONObject.parseObject(s,CalendarTask.class);
|
||||
if(tmp.getId()==task.getId()){
|
||||
RedisTools.list_remove(REDIS_TAG,s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getMouthData(CalendarTask task) {
|
||||
List<String> list = new ArrayList<>();
|
||||
Calendar calendar = Calendar.getInstance(Locale.CHINA);
|
||||
calendar.setTime(task.getStartTime());
|
||||
list.add(new SimpleDateFormat("yyyy-M-d HH:mm:ss",Locale.CHINA).format(calendar.getTime()));
|
||||
while (true) {
|
||||
calendar.set(task.getType(),calendar.get(task.getType())+task.getTime());
|
||||
if(calendar.getTime().getTime()>task.getEndTime().getTime()){
|
||||
break;
|
||||
}
|
||||
list.add(new SimpleDateFormat("yyyy-M-d HH:mm:ss",Locale.CHINA).format(calendar.getTime()));
|
||||
if(task.getModel()==CalendarTask.MODEL_ONE){
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.yutou.tools.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyuncs.utils.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -8,57 +10,88 @@ import java.io.*;
|
||||
* 配置和参数
|
||||
*/
|
||||
public class ConfigTools {
|
||||
public static final String CONFIG="config.json";
|
||||
public static final String DATA="data.json";
|
||||
public static final String SQLITE="sqlite.json";
|
||||
public static final String CONFIG = "config.json";
|
||||
public static final String DATA = "data.json";
|
||||
public static final String SQLITE = "sqlite.json";
|
||||
|
||||
|
||||
static {
|
||||
try {
|
||||
File file=new File(CONFIG);
|
||||
if(!file.exists()){
|
||||
File file = new File(CONFIG);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
file=new File(DATA);
|
||||
if(!file.exists()){
|
||||
file = new File(DATA);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
file=null;
|
||||
}catch (Exception e){
|
||||
file = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
public static Object load(String type,String key){
|
||||
File file=new File(type);
|
||||
//System.out.println(type+"配置文件地址:"+file.getAbsolutePath());
|
||||
String src=readFile(file);
|
||||
if(src!=null){
|
||||
|
||||
public static Object load(String type, String key) {
|
||||
return load(type, key, Object.class, null);
|
||||
}
|
||||
|
||||
public static <T> T load(String type, String key, Class<T> t) {
|
||||
return load(type, key, t, null);
|
||||
}
|
||||
|
||||
public static <T> T load(String type, String key, Class<T> t, T def) {
|
||||
File file = new File(type);
|
||||
//com.yutou.nas.utils.Log.i(type+"配置文件地址:"+file.getAbsolutePath());
|
||||
String src = readFile(file);
|
||||
if (src != null) {
|
||||
try {
|
||||
JSONObject json=JSONObject.parseObject(src);
|
||||
if(json==null){
|
||||
json=new JSONObject();
|
||||
saveFile(file,json.toJSONString());
|
||||
}
|
||||
return json.getOrDefault(key, "");
|
||||
}catch (Exception e){
|
||||
return "";
|
||||
JSONObject json = JSONObject.parseObject(src, JSONObject.class);
|
||||
return json.getObject(key, t);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
return def;
|
||||
}
|
||||
public static boolean save(String type,String key,Object data){
|
||||
File file=new File(type);
|
||||
String src=readFile(file);
|
||||
if(src==null){
|
||||
src="{}";
|
||||
|
||||
public static String loadIni(File file, String key) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String tmp, str = null;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
if (tmp.startsWith(key + "=")) {
|
||||
str = tmp.split("=")[1];
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
str = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject json=JSONObject.parseObject(src);
|
||||
json.put(key,data);
|
||||
saveFile(file,json.toJSONString());
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean save(String type, String key, Object data) {
|
||||
File file = new File(type);
|
||||
String src = readFile(file);
|
||||
if (src == null) {
|
||||
src = "{}";
|
||||
}
|
||||
JSONObject json = JSON.parseObject(src);
|
||||
json.put(key, data);
|
||||
saveFile(file, json.toJSONString());
|
||||
return false;
|
||||
}
|
||||
public static boolean saveFile(File file,String data){
|
||||
|
||||
public static boolean saveFile(File file, String data) {
|
||||
try {
|
||||
FileWriter writer=new FileWriter(file);
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(data);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
@@ -68,13 +101,14 @@ public class ConfigTools {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static String readFile(File file){
|
||||
|
||||
public static String readFile(File file) {
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new FileReader(file));
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String tmp;
|
||||
StringBuilder str= new StringBuilder();
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
str.append(tmp);
|
||||
StringBuilder str = new StringBuilder();
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
return str.toString();
|
||||
@@ -84,3 +118,4 @@ public class ConfigTools {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,10 @@ public class CorsConfig implements WebMvcConfigurer {
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
//设置允许跨域的路径
|
||||
registry.addMapping("/**")
|
||||
//设置允许跨域请求的域名
|
||||
.allowedOrigins("Access-Control-Allow-Origin")
|
||||
//是否允许证书 不再默认开启
|
||||
.allowCredentials(true)
|
||||
//设置允许的方法
|
||||
.allowedMethods("*")
|
||||
//跨域允许时间
|
||||
.maxAge(3600);
|
||||
.allowedOrigins("https://tools.yutou233.cn") // 允许哪些域的请求
|
||||
.allowedMethods("POST", "GET") // 允许的请求方法
|
||||
.allowedHeaders("*") // 允许的头部设置
|
||||
.allowCredentials(true) // 是否发送cookie
|
||||
.maxAge(168000); // 预检间隔时间
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,19 @@ public class HttpTools {
|
||||
private static final int HttpRequestIndex = 3;
|
||||
|
||||
public static String get(String url) {
|
||||
return https_get(url, null);
|
||||
if(url.startsWith("http:")){
|
||||
return https_get(HttpURLConnection.class, url, null);
|
||||
}else {
|
||||
return https_get(HttpsURLConnection.class,url, null);
|
||||
}
|
||||
}
|
||||
public static <T extends URLConnection> String https_get(String url, Map<String, String> header) {
|
||||
if(url.startsWith("http:")){
|
||||
return https_get(HttpURLConnection.class, url, header);
|
||||
}else {
|
||||
return https_get(HttpsURLConnection.class,url, header);
|
||||
}
|
||||
}
|
||||
|
||||
public static String post(final String url, final byte[] body) {
|
||||
return http_post(url, body, 0, null);
|
||||
}
|
||||
@@ -29,10 +39,9 @@ public class HttpTools {
|
||||
return new HttpTools().http_syncDownload(url, saveName);
|
||||
}
|
||||
|
||||
public static String https_get(String url, Map<String, String> header) {
|
||||
public static <T extends URLConnection> String https_get(Class<T> c, String url, Map<String, String> header) {
|
||||
try {
|
||||
URLConnection connection;
|
||||
connection = new URL(url).openConnection();
|
||||
T connection = (T) new URL(url).openConnection();
|
||||
connection.setConnectTimeout(60*1000);
|
||||
connection.setReadTimeout(60*1000);
|
||||
connection.setRequestProperty("User-Agent", getExtUa());
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.ibatis.mapping.Environment;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
@@ -19,6 +21,7 @@ public class RedisTools {
|
||||
private static boolean isNotInstallRedis = false;
|
||||
private static String host;
|
||||
private static int port;
|
||||
private static String auth;
|
||||
public static int TOKEN_TIMEOUT_DEFAULT = 360;
|
||||
|
||||
private RedisTools() {
|
||||
@@ -26,12 +29,11 @@ public class RedisTools {
|
||||
}
|
||||
|
||||
// 写成静态代码块形式,只加载一次,节省资源
|
||||
static {
|
||||
//Properties properties = PropertyUtil.loadProperties("jedis.properties");
|
||||
//host = properties.getProperty("redis.host");
|
||||
//port = Integer.valueOf(properties.getProperty("redis.port"));
|
||||
public static void initConfig(int port, String auth) {
|
||||
host = "127.0.0.1";
|
||||
port = 6379;
|
||||
RedisTools.port = port;
|
||||
RedisTools.auth = auth;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +138,20 @@ public class RedisTools {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static boolean exists(String key) {
|
||||
if (isNotInstallRedis) {
|
||||
return false;
|
||||
}
|
||||
Jedis jedis = getRedis();
|
||||
boolean flag = jedis.exists(key);
|
||||
jedis.close();
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static Jedis getRedis() {
|
||||
return new Jedis(host, port);
|
||||
Jedis jedis = new Jedis(host, port);
|
||||
jedis.auth(auth);
|
||||
return jedis;
|
||||
}
|
||||
|
||||
public static boolean remove(String key, int index) {
|
||||
@@ -186,6 +200,7 @@ public class RedisTools {
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
private static class PropertyUtil {
|
||||
|
||||
// 加载property文件到io流里面
|
||||
|
||||
17
src/main/java/com/yutou/tools/utils/TimerTask.java
Normal file
17
src/main/java/com/yutou/tools/utils/TimerTask.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.yutou.tools.utils;
|
||||
|
||||
public class TimerTask {
|
||||
private static TimerTask task;
|
||||
|
||||
private TimerTask(){
|
||||
|
||||
}
|
||||
public static TimerTask getInstance(){
|
||||
if(task == null){
|
||||
task=new TimerTask();
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.yutou.tools.utils;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.tools.interfaces.DownloadInterface;
|
||||
import com.yutou.tools.mybatis.dao.ToolsPasswordDao;
|
||||
import com.yutou.tools.mybatis.model.ToolsPassword;
|
||||
import com.yutou.tools.mybatis.model.ToolsPasswordExample;
|
||||
import com.yutou.tools.nas.UpdateIp;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -34,6 +37,7 @@ import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -103,8 +107,8 @@ public class Tools {
|
||||
public static void sendServer(String title, String msg) {
|
||||
try {
|
||||
System.out.println("title=" + title + " msg=" + msg);
|
||||
HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
|
||||
("title=" + URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8));
|
||||
/* HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
|
||||
("title=" + URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8));*/
|
||||
if (!StringUtils.isEmpty(UpdateIp.nas_ip)) {
|
||||
String img = null;
|
||||
msg = msg.replace("<br/>", "\n");
|
||||
@@ -434,7 +438,7 @@ public class Tools {
|
||||
}
|
||||
|
||||
public static String getLoginUser() {
|
||||
if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
|
||||
if ("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
|
||||
return "admin";
|
||||
}
|
||||
Object user = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
@@ -458,10 +462,10 @@ public class Tools {
|
||||
}
|
||||
|
||||
public static String getPinYin(String text) {
|
||||
String pinyin = HttpTools.get("http://api.tianapi.com/pinyin/index?key=a1e0f7267037c4e0ea02fb1cb3912367&text=" + URLEncoder.encode(text, StandardCharsets.UTF_8));
|
||||
String pinyin = HttpTools.get("https://apis.tianapi.com/pinyin/index?key=" + ConfigTools.load(ConfigTools.CONFIG, "tianapi.key", String.class) + "&text=" + URLEncoder.encode(text, StandardCharsets.UTF_8));
|
||||
JSONObject json = JSONObject.parseObject(pinyin);
|
||||
if (json.getInteger("code") == 200) {
|
||||
return json.getJSONArray("newslist").getJSONObject(0).getString("pinyin").trim().replace(" ", "");
|
||||
return json.getJSONObject("result").getString("pinyin").trim().replace(" ", "");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -471,6 +475,24 @@ public class Tools {
|
||||
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
||||
calendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
calendar.setTime(new Date());
|
||||
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
}
|
||||
|
||||
public static Date timeToDate(String date, String time) {
|
||||
String form;
|
||||
if (StringUtils.isEmpty(time)) {
|
||||
form = "yyyy-MM-dd";
|
||||
} else {
|
||||
form = "yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
try {
|
||||
return new SimpleDateFormat(form).parse(date + " " + time);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getPinYin("webdav"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,6 @@ mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.yutou.tools.mybatis
|
||||
#<23><>ӡmybatis<69><73>־
|
||||
#logging.level.com.yutou.tools=debug
|
||||
#server.servlet.session.timeout=10s
|
||||
#server.servlet.session.timeout=10s
|
||||
redis.auth=ADVbdzPbF1jwThtb
|
||||
redis.port=21120
|
||||
@@ -26,10 +26,28 @@
|
||||
<div id="artist">艺术家:</div>
|
||||
<div id="album">专辑:</div>
|
||||
<div id="composer">作曲家</div>
|
||||
<a class="layui-btn layui-btn-normal" id="download">下载</a>
|
||||
<a class="layui-btn layui-btn-normal" id="next">下一首</a>
|
||||
<a class="layui-btn layui-btn-normal" id="play_share">分享</a>
|
||||
<a class="layui-btn layui-btn-normal" id="showLrc">显示歌词</a>
|
||||
<form class="layui-form" lay-filter="calendarForm">
|
||||
<div class="layui-row layui-col-space12">
|
||||
<div class="layui-col-xs3 ">
|
||||
<a class="layui-btn layui-btn-normal" id="download">下载</a>
|
||||
</div>
|
||||
<div class="layui-col-xs3 ">
|
||||
<a class="layui-btn layui-btn-normal" id="next">下一首</a>
|
||||
</div>
|
||||
<div class="layui-col-xs3 ">
|
||||
<a class="layui-btn layui-btn-normal" id="play_share">分享</a>
|
||||
</div>
|
||||
<div class="layui-col-xs3 ">
|
||||
<a class="layui-btn layui-btn-normal" id="showLrc">显示歌词</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-row layui-col-space5">
|
||||
<div class="layui-col-xs2 ">
|
||||
<input type="checkbox" name="" title="过滤instrumental" checked id="filter_instrumental">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="audioWrap"></div>
|
||||
@@ -83,7 +101,7 @@
|
||||
return;
|
||||
}
|
||||
localhost = json.data;
|
||||
if (localhost === 'http://null:8000' || localhost === ":8000") {
|
||||
if (localhost === 'https://null:8000' || localhost === ":8000") {
|
||||
localhost = "https://" + window.location.host;
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -131,7 +149,8 @@
|
||||
}
|
||||
listTable.reload({
|
||||
where: {
|
||||
path: path
|
||||
path: path,
|
||||
filter:$('#filter_instrumental')[0].checked
|
||||
}
|
||||
, page: {
|
||||
curr: 1
|
||||
@@ -161,7 +180,7 @@
|
||||
type: "POST",
|
||||
url: localhost + "/nas/music/list.do",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify({type: true, path: data.file}),
|
||||
data: JSON.stringify({type: true, path: data.file,filter:$('#filter_instrumental')[0].checked}),
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
try {
|
||||
@@ -191,7 +210,7 @@
|
||||
}
|
||||
$.post('/nas/music/share.do', {file: file, isDir: isDir}, function (json) {
|
||||
if (json.code === 0) {
|
||||
var url = "http://" + window.location.host + "/html/body/nas/music.html?share=" + json.data.token
|
||||
var url = "https://" + window.location.host + "/html/body/nas/music.html?share=" + json.data.token
|
||||
layer.prompt({
|
||||
title: "分享链接",
|
||||
value: url
|
||||
@@ -271,7 +290,7 @@
|
||||
$('#play_share').click(function () {
|
||||
$.post('/nas/music/share.do', {file: playNow}, function (json) {
|
||||
if (json.code === 0) {
|
||||
let url = "http://" + window.location.host + "/html/body/nas/music.html?share=" + json.data.token
|
||||
let url = "https://" + window.location.host + "/html/body/nas/music.html?share=" + json.data.token
|
||||
layer.prompt({
|
||||
title: "分享链接",
|
||||
value: url
|
||||
@@ -341,7 +360,7 @@
|
||||
}
|
||||
|
||||
function random() {
|
||||
$.post(localhost + "/nas/music/random.do", function (data) {
|
||||
$.post(localhost + "/nas/music/random.do",{filter:$('#filter_instrumental')[0].checked}, function (data) {
|
||||
let json = JSON.parse(data)
|
||||
if (json.code === 0) {
|
||||
playNow = json.data
|
||||
|
||||
232
web/html/body/tools/calendar.html
Normal file
232
web/html/body/tools/calendar.html
Normal file
@@ -0,0 +1,232 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Calendar</title>
|
||||
<link rel="stylesheet" href="/layui/css/layui.css" media="all">
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="layui-layout layui-layout-admin myDiy">
|
||||
<div id="header"></div>
|
||||
<div class="layui-body" style="left: 200px;overflow:auto;">
|
||||
<div id="side"></div>
|
||||
|
||||
<blockquote class="layui-elem-quote">日历管理
|
||||
</blockquote>
|
||||
|
||||
<br/><br/><br/>
|
||||
|
||||
<div class="layui-bg-gray layui-row layui-col-space15" id="card">
|
||||
<div class="layui-form-item">
|
||||
<table id="demo" lay-filter="test"></table>
|
||||
</div>
|
||||
<form class="layui-form" lay-filter="calendarForm">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">日历</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="calendarShow" name="calendar" style="width: 45%"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新增任务</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" class="layui-input" id="calendar">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标题</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="title" required lay-verify="required" placeholder="请输入标题"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="content" required lay-verify="required" placeholder="请输入内容"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">类型</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="model" value="0" title="单次提醒" checked>
|
||||
<input type="radio" name="model" value="1" title="循环提醒">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">模式</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="type" value="5" title="日" checked>
|
||||
<input type="radio" name="type" value="4" title="周">
|
||||
<input type="radio" name="type" value="2" title="月">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">间隔日期</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="day" required lay-verify="required" placeholder="天数"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">QQ通知</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="qqbot" title="发送到QQ">
|
||||
</div>
|
||||
</div>
|
||||
<blockquote class="layui-elem-quote"><span id="dateText">日期选择</span>
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<a class="layui-btn" id="setCalendar">新增规则</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script src="/layui/layui.js"></script>
|
||||
<script src="/js/jquery-3.2.1.js"></script>
|
||||
<script type="text/html" id="calendarToolBar">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>
|
||||
</script>
|
||||
<script>
|
||||
|
||||
layui.use(['laydate', 'form', 'table'], function () {
|
||||
let dayDateObj
|
||||
let marks = {}
|
||||
let holiday = []
|
||||
let laydate = layui.laydate;
|
||||
let form = layui.form;
|
||||
let table = layui.table;
|
||||
|
||||
$.get("/calendar/all.do", function (json) {
|
||||
//执行一个laydate实例
|
||||
marks = json.data.date;
|
||||
holiday = json.data.holiday;
|
||||
showData()
|
||||
})
|
||||
table.render({
|
||||
elem: '#demo'
|
||||
, toolbar: '#toolbar'
|
||||
, url: '/calendar/list.do' //数据接口
|
||||
, page: true //开启分页
|
||||
, cols: [[ //表头
|
||||
{field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left'}
|
||||
, {field: 'title', title: '标题', width: 100}
|
||||
, {field: 'content', title: '内容', width: 200, sort: true}
|
||||
, {field: 'startTime', title: '开始时间', width: 180}
|
||||
, {field: 'endTime', title: '结束时间', width: 180}
|
||||
, {field: 'time', title: '间隔', width: 80, sort: true}
|
||||
, {field: 'type', title: '类型', width: 80, sort: true}
|
||||
, {field: 'model', title: '模式', width: 80}
|
||||
, {field: 'words', title: '', toolbar: '#calendarToolBar'}
|
||||
]]
|
||||
});
|
||||
table.on('tool(test)', function (obj) {
|
||||
console.log(obj)
|
||||
if (obj.event === 'delete') {
|
||||
$.post('/calendar/del.do', {id: obj.data.id}, function (json) {
|
||||
layer.msg(json.msg)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
function showData() {
|
||||
laydate.render({
|
||||
elem: '#calendar' //指定元素
|
||||
, type: 'datetime'
|
||||
, show: true
|
||||
, range: true
|
||||
, holidays: holiday
|
||||
, done: function (value, date, endDate) {
|
||||
console.log(date)
|
||||
console.log(endDate)
|
||||
dayDateObj = date;
|
||||
dayDateObj.time = value
|
||||
$('#dateText')[0].innerHTML = "从" + date.date + "号开始计算"
|
||||
}, change: function (value, date, endDate) {
|
||||
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#calendarShow' //指定元素
|
||||
, position: 'static'
|
||||
, holidays: holiday
|
||||
, theme: 'molv'
|
||||
, done: function (value, date, endDate) {
|
||||
|
||||
}, change: function (value, date, endDate) {
|
||||
console.log(marks[value] + " > " + value)
|
||||
if (marks[value] !== undefined) {
|
||||
// datatmp.hint(marks[value])
|
||||
layer.tips(marks[value], '#calendarShow')
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$('#setCalendar').click(function () {
|
||||
form.submit('calendarForm', function (obj) {
|
||||
console.log(obj)
|
||||
let field = obj.field;
|
||||
layer.open({
|
||||
title: '确认'
|
||||
, content: '确认从' + dayDateObj.date + '号开始,开始提醒?'
|
||||
, yes: function (index, layero) {
|
||||
$.post("/calendar/set.do", {
|
||||
startDate: dayDateObj.time
|
||||
, title: field.title
|
||||
, content: field.content
|
||||
, type: field.type
|
||||
, model: field.model
|
||||
, day: field.day
|
||||
, qqbot: field.qqbot
|
||||
}, function (json) {
|
||||
layer.msg(json.msg)
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
$('#header').load("/html/header.html");
|
||||
$('#footer').load("/html/footer.html");
|
||||
</script>
|
||||
<style>
|
||||
.myDiy {
|
||||
/*width: 80%;*/
|
||||
margin-top: 10%;
|
||||
margin-left: 15%;
|
||||
margin-right: 15%;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</html>
|
||||
@@ -4,15 +4,34 @@
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-footer" style="left: 0px; text-align: center; height: 60px; line-height: 0;">
|
||||
<div id="sakana-widget" style="right: 5%;bottom: 8%;position: fixed;"></div>
|
||||
<div class="layui-footer" style="left: 0; text-align: center; height: 60px; line-height: 0;">
|
||||
|
||||
<div style="line-height: 44px;">
|
||||
©2022 by yutou
|
||||
</div>
|
||||
<div>
|
||||
<a href="http://beian.miit.gov.cn/">湘ICP备16005656号</a>
|
||||
<a href="https://beian.miit.gov.cn/">湘ICP备16005656号1</a>
|
||||
<!--<script type="text/javascript" src="https://s4.cnzz.com/z_stat.php?id=1279421741&web_id=1279421741"></script>-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="/js/sakana.min.js"></script>
|
||||
<script>
|
||||
function initSakanaWidget() {
|
||||
let widget=new SakanaWidget({
|
||||
audoFit:true
|
||||
}).mount('#sakana-widget');
|
||||
widget.triggetAutoMode();
|
||||
}
|
||||
initSakanaWidget()
|
||||
</script>
|
||||
<style>
|
||||
.sakana-widget-main{
|
||||
position: absolute;
|
||||
right: 5%;
|
||||
bottom: 5%;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
@@ -12,7 +12,7 @@
|
||||
<body>
|
||||
<div class="layui-header">
|
||||
<ul class="layui-nav" lay-filter="" style="background-color: #1772B4;">
|
||||
<li class="layui-nav-item"><a href="http://blog.yutou233.cn">博客</a></li>
|
||||
<li class="layui-nav-item"><a href="https://blog.yutou233.cn">博客</a></li>
|
||||
<div id="admin" style="display: inline-block; font-size: 0px;">
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:;">NAS管理</a>
|
||||
@@ -36,10 +36,11 @@
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:;">页面集</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a href="http://nas.yutou233.cn/" target="_blank">管理后台</a></dd>
|
||||
<dd><a href="http://bt.yutou233.cn" target="_blank">BT下载</a></dd>
|
||||
<dd><a href="http://jellyfin.yutou233.cn:7800/" target="_blank">jellyfin</a></dd>
|
||||
<dd><a href="https://nas.yutou233.cn/" target="_blank">管理后台</a></dd>
|
||||
<dd><a href="https://bt.yutou233.cn" target="_blank">BT下载</a></dd>
|
||||
<dd><a href="https://jellyfin.yutou233.cn:7800/" target="_blank">jellyfin</a></dd>
|
||||
<dd><a href="/html/body/nas/music.html">NAS音乐播放器</a></dd>
|
||||
<dd><a href="/html/body/tools/calendar.html">日历</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="layui-nav-item" id='icon'>
|
||||
|
||||
3
web/js/sakana.min.js
vendored
Normal file
3
web/js/sakana.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#FAFAFA;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
|
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-view{display:block;position:relative;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#fafafa;color:#333;font-family:Courier New;font-size:13px}.layui-code-title{position:relative;padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee;font-size:12px}.layui-code-title>.layui-code-about{position:absolute;right:10px;top:0;color:#b7b7b7}.layui-code-about>a{padding-left:10px}.layui-code-view>.layui-code-ol,.layui-code-view>.layui-code-ul{position:relative;overflow:auto}.layui-code-view>.layui-code-ol>li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view>.layui-code-ol>li:first-child,.layui-code-view>.layui-code-ul>li:first-child{padding-top:10px}.layui-code-view>.layui-code-ol>li:last-child,.layui-code-view>.layui-code-ul>li:last-child{padding-bottom:10px}.layui-code-view>.layui-code-ul>li{position:relative;line-height:20px;padding:0 10px;list-style-type:none;*list-style-type:none;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-dark{border:1px solid #0c0c0c;border-left-color:#3f3f3f;background-color:#0c0c0c;color:#c2be9e}.layui-code-dark>.layui-code-title{border-bottom:none}.layui-code-dark>.layui-code-ol>li,.layui-code-dark>.layui-code-ul>li{background-color:#3f3f3f;border-left:none}.layui-code-dark>.layui-code-ul>li{margin-left:6px}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 299 KiB After Width: | Height: | Size: 321 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user