commit ed257498c2e2dc2edb1d253e69ad7cf5f1b0790a Author: lion Date: Wed Jul 20 20:02:41 2022 +0800 基本正常,未发现恶性bug diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..fec2fe6 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,28 @@ + + + + diff --git a/src/assets/logo.png b/src/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/src/assets/logo.png differ diff --git a/src/components/DashBoard.vue b/src/components/DashBoard.vue new file mode 100644 index 0000000..63b402e --- /dev/null +++ b/src/components/DashBoard.vue @@ -0,0 +1,148 @@ + + + + + \ No newline at end of file diff --git a/src/components/Side.vue b/src/components/Side.vue new file mode 100644 index 0000000..b83005a --- /dev/null +++ b/src/components/Side.vue @@ -0,0 +1,168 @@ + + + + + \ No newline at end of file diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..852de7a --- /dev/null +++ b/src/index.css @@ -0,0 +1,8 @@ +#app { + font-family: Avenir, Helvetica, Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-align: center; + color: #2c3e50; + margin-top: 60px; +} diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..a14ece2 --- /dev/null +++ b/src/main.js @@ -0,0 +1,6 @@ +import { createApp } from 'vue' +import App from './App.vue' +import 'element-plus/dist/index.css' +import element from "element-plus" + +createApp(App).use(element).mount('#app') diff --git a/src/reset.css b/src/reset.css new file mode 100644 index 0000000..1e754d1 --- /dev/null +++ b/src/reset.css @@ -0,0 +1,42 @@ +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..f241a41 --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,234 @@ +import vuex from "vuex" +import axios from "axios" +import {ElMessage} from "element-plus" +import qs from "qs" + +const base_url = "http://107.189.14.196:8080/TaskHandler/" +const actions = { + update(context){ + const AuthCode = context.state.AuthCode + axios.get(base_url, { + params:{ + param:"", + type:"all", + AuthCode: AuthCode + } + }).then((res) => { + let temp = [] + context.commit("_empty") + JSON.parse(res.data.data).forEach((task) => { + temp.push(JSON.parse(task)) + }) + context.commit("_update", temp) + + }) + }, + post(context, link){ + const AuthCode = context.state.AuthCode + axios.post(base_url, qs.stringify({ + AuthCode:AuthCode, + link:link + })).then((res) => { + if(res.data.result === "success") + ElMessage("提交成功") + else{ + if(res.data.data) + ElMessage(res.data.data) + else{ + ElMessage("提交失败") + } + } + }) + }, + query(context, link){ + const AuthCode = context.state.AuthCode + axios.get(base_url, { + params:{ + param:link, + type:'link', + AuthCode + } + }).then((res) => { + if(res.data.result === 'success'){ + const gallery = JSON.parse(res.data.data) + let message = "本子名字: " + gallery.name + "
" + message += "本子页数: " + gallery.pages + "
" + message += "gid: " + gallery.gid + "
" + if(gallery.language === "N/A") + message += "语言: 未知
" + else + message += "语言: " + gallery.language + "
" + message += "大小: " + gallery.fileSize + "
" + switch (gallery.status){ + case "complete": + message += "状态: 下载完成" + break + case "posted" : + message += "状态: 等待中" + break + case "proceeding": + message += "状态: 下载中" + break + default: + break + } + console.log(gallery) + ElMessage({ + dangerouslyUseHTMLString: true, + duration: 5000, + showClose: true, + message + }) + } + else + ElMessage("查询失败") + }) + }, + validate(context, AuthCode){ + axios.post(base_url + "validate?AuthCode=" + AuthCode).then((res)=>{ + if(res.data.result === 'success'){ + context.commit("_authed", AuthCode, context) + context.dispatch("update") + setInterval(() => { + context.dispatch("update") + }, 30000) + } + else{ + context.commit("_unAuthed") + } + }) + }, + searchByLink(context, link){ + context.commit("_searchByLink", link) + }, + searchByKeyword(context, keyword){ + context.commit("_searchByKeyword", keyword) + } +} + +const mutations = { + _empty(state){ + state.totalTask.splice(0) + }, + _update(state, tasks){ + const download_url = base_url + "file?link=" + + tasks.forEach((task) => { + if(task.status === "posted"){ + task.progress = "0%" + } + else if(task.status === "downloading"){ + task.progress = (Math.round((task.proceeding / task.pages)*100)).toString() + "%" + } + else if(task.status === "complete"){ + task.progress = "100%" + task.download = download_url + task.link + "&AuthCode=" + state.AuthCode + } + state.totalTask.push(task) + }) + if(state.isAuth && !state.loadComplete){ + state.loadComplete = true + ElMessage("加载完成") + } + }, + _changePage(state, targetPage){ + state.page = targetPage + }, + _authed(state, AuthCode){ + state.AuthCode = AuthCode + state.isAuth = true + ElMessage("验证成功,加载中") + }, + _unAuthed(state){ + state.isAuth = false + state.AuthCode = "" + ElMessage("授权码错误") + }, + _searchByLink(state, link){ + let gid = link.split('/')[4] + if(!gid){ + ElMessage("请检查链接输入是否正确") + } + let i = 0 + let found = false + for(i=0; i { + if(task.name.includes(keyword)) + state.searchTask.push(task) + }) + if(state.searchTask.length === 0){ + ElMessage("未找到该关键字的本子") + } + } +} + +const state = { + totalTask:[], //存放数据的数组 + page:1, //当前页数 + length:8, //每页能有多少个链接 + isAuth:false, //是否授权 + AuthCode:'', //授权码 + loadComplete:false, //是否加载完成 + isInclude:false, //是否搜索到任务 + searchTask:[] //搜索到的任务 +} + +const getters = { + task(state){ + if(state.searchTask.length !== 0) + return state.searchTask.slice((state.page-1)*state.length, state.page*state.length) + if(state.totalTask.length !== 0) + return state.totalTask.slice((state.page-1)*state.length, state.page*state.length) + return null + }, + min(){ + return 1 + }, + max(state){ + let max = 0 + let tasks + if(state.searchTask.length !== 0){ + tasks = state.searchTask + } + else if(state.totalTask.length !== 0){ + tasks = state.totalTask + } + if(!tasks) + return 1 + max = Math.floor(tasks.length/state.length) + if(tasks.length % state.length !== 0){ + max += 1 + } + return max + }, + isAuth(state){ + return state.isAuth + }, + page(state){ + return state.page + }, + loadComplete(state){ + return state.loadComplete + } +} + +export default new vuex.Store({ + actions, + mutations, + state, + getters +}) +