第一次提交,该项目为LionWebsite的移动端

This commit is contained in:
emm 2022-09-06 23:25:55 +08:00
commit 34b1fdaadf
6 changed files with 967 additions and 0 deletions

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

23
src/App.vue Normal file
View File

@ -0,0 +1,23 @@
<script setup>
import Side from "./components/Side.vue";
import DashBoard from "./components/DashBoard.vue";
</script>
<template>
<div class="app">
<el-container>
<Side/>
<el-main>
<DashBoard/>
</el-main>
</el-container>
</div>
</template>
<style>
.app{
background-color: #c6e2ff;
}
</style>

View File

@ -0,0 +1,251 @@
<template>
<div class="DashBoard" v-show="loadComplete">
<el-input v-model="link" placeholder="输入链接"/> <br>
<el-button @click="queryTask">查询任务</el-button>
<el-button @click="searchByLink">查找任务</el-button> <br>
<br>
<hr>
<br>
<el-input v-model="keyword" placeholder="输入关键字" @change="searchByKeyword"/>
<br>
<el-button>确定</el-button>
<br>
<el-button @click="openPanel">打开面板</el-button>
<el-button @click="closePanel">关闭面板</el-button>
<br>
<el-button @click="deleteAuthCode">删除授权码</el-button>
</div>
<el-dialog title="查询本子" v-model="preDownloadGallery" width="100">
<table>
<tr>本子名字:{{preDownloadGallery.name}}</tr>
<tr>本子页数:{{preDownloadGallery.pages}}</tr>
<tr>本子语言:{{preDownloadGallery.language}}</tr>
<tr>本子大小:{{preDownloadGallery.fileSize}}</tr>
<tr>本子状态:{{preDownloadGallery.status}}</tr>
<tr v-if="preDownloadGallery.availableResolution">
目标分辨率:<el-select v-model="targetResolution">
<el-option v-for="(fileSize, resolution) in preDownloadGallery.availableResolution" :value="resolution"
:label="modify(resolution, fileSize)">
</el-option>
</el-select>
</tr>
</table>
<el-button @click="postTask" v-if="preDownloadGallery.availableResolution">下载</el-button>
</el-dialog>
<el-dialog title="查询视频" v-model="preDownloadVideo" width="100">
<table>
<tr>视频名字:{{preDownloadVideo.name}}</tr>
<tr>视频网站: <el-link :href="preDownloadVideo.website">{{preDownloadVideo.website}}</el-link> </tr>
<tr>视频链接: <el-link :href="preDownloadVideo.link">{{preDownloadVideo.link}}</el-link></tr>
<tr>视频状态:{{preDownloadVideo.status}}</tr>
<tr v-if="!preDownloadVideo.resolution">
目标分辨率: <el-select v-model="targetResolution">
<el-option v-for="(resolution) in preDownloadVideo.availableResolution" :value="resolution" :label="resolution"/>
</el-select>
</tr>
</table>
<el-button @click="postTask" v-if="!preDownloadVideo.resolution">下载</el-button>
</el-dialog>
<div class="DashBoard" v-show="!loadComplete">
<el-input v-model="AuthCode" class="validate" placeholder="请输入授权码">
</el-input>
<el-checkbox v-model="isRemember">是否记住授权码</el-checkbox><br>
<el-button @click="validate" type="primary" @keydown.enter="validate">验证</el-button>
</div>
</template>
<script>
import store from "../store";
import {computed, ref, onMounted} from "vue";
import {ElMessage} from "element-plus"
export default {
name: "DashBoard",
setup(){
const link = ref("")
const AuthCode = ref("")
const keyword = ref("")
const isRemember = ref(false)
const targetResolution = ref("")
let timer
let preDownloadGallery = computed(() => {
return store.getters.preDownloadGallery
})
let preDownloadVideo = computed(() => {
return store.getters.preDownloadVideo
})
const loadComplete = computed(() => {
return store.getters.loadComplete
})
function modify(str1, str2){
return str1 + " " + str2
}
function postTask(){
if(!validateLink(link.value)){
ElMessage("链接错误")
return
}
if(targetResolution.value === ''){
ElMessage("请选择分辨率再提交")
return
}
let tempLink = coverLink(link.value)
if(link.value.includes("hentai")) {
store.dispatch("postGalleryTask", {link: tempLink, targetResolution: targetResolution.value})
targetResolution.value = ""
}
else {
store.dispatch("postVideoTask", {link: tempLink, targetResolution: targetResolution.value})
targetResolution.value = ""
}
}
function queryTask(){
if(!validateLink(link.value)){
ElMessage("链接错误")
return
}
let tempLink
if(link.value.includes("hentai")) {
tempLink = coverLink(link.value)
store.dispatch("queryGalleryTask", tempLink)
}
else{
tempLink = coverLink(link.value)
store.dispatch("queryVideoTask", tempLink)
}
}
function validate(){
if(AuthCode.value.trim() === ""){
ElMessage("请输入授权码后再验证")
}
else{
store.dispatch("validate", AuthCode.value)
if(isRemember.value)
localStorage.setItem("auth", AuthCode.value)
}
}
function searchByLink() {
if(link.value.trim() === ""){
ElMessage("请输入链接后查找")
}
else {
store.dispatch("searchByLink", link.value)
openPanel()
}
}
function searchByKeyword(){
if(timer)
clearTimeout(timer)
timer = setTimeout(() => {
store.dispatch("searchByKeyword", keyword.value)
}, 500)
}
function coverLink(rawLink){
let tempLink = ""
if(rawLink.includes("hentai")) {
if (rawLink.includes("exhentai.org"))
tempLink = rawLink.replace("exhentai.org", "element-plus.org")
else if (rawLink.includes("e-hentai.org"))
tempLink = rawLink.replace("e-hentai.org", "element.org")
}
else if(rawLink.includes("xvideos.com") || rawLink.includes("pornhub.com")){
tempLink = rawLink.replace("xvideos.com", "xiaomi.com").
replace("cn.pornhub.com", "pixiv.com").
replace("pornhub.com", "pixiv.com")
}
return tempLink;
}
function validateLink(rawLink){
if(rawLink.trim() === "")
return false
if(rawLink.includes("hentai")){
return rawLink.includes("/g/")
}
else if(rawLink.includes("xvideos.com")){
return true
}
else if(rawLink.includes("pornhub.com")){
return rawLink.includes("view_video.php")
}
}
function openPanel(){
store.commit("_openHistoryPanel")
}
function closePanel(){
store.commit("_closeHistoryPanel")
}
function deleteAuthCode() {
localStorage.clear()
}
onMounted(() => {
const auth = localStorage.getItem("auth")
if(auth !== null){
store.dispatch("validate", auth)
}
})
return {postTask,
queryTask,
validate,
searchByLink,
searchByKeyword,
modify,
openPanel,
closePanel,
deleteAuthCode,
link,
loadComplete,
AuthCode,
keyword,
isRemember,
preDownloadGallery,
preDownloadVideo,
targetResolution,
store
}
}
}
</script>
<style scoped>
.DashBoard{
width: auto;
height: 90vh;
background-color: ghostwhite;
text-align: center;
}
.validate{
width: auto;
background-color: ghostwhite;
display: block;
padding-left: 100px;
padding-top: 200px;
}
.el-input{
width: 250px;
}
</style>

271
src/components/Side.vue Normal file
View File

@ -0,0 +1,271 @@
<template>
<el-drawer v-model="isOpenHistoryPanel" direction="ltr" size="150" @close="closeHistoryPanel" :title="showType">
<div class="side">
<div v-show="loadComplete" class="load_complete">
<el-table :data="galleryTasks" v-show="isShowGalleryHistory">
<el-table-column type="expand">
<template #default="props">
名字:{{ props.row.name}} <br>
链接:<el-link :href="props.row.link">Link</el-link> <br>
语言:{{props.row.language}} <br>
页数:{{props.row.pages}} <br>
文件大小:{{props.row.fileSize}}<br>
分辨率:{{props.row.resolution}}<br>
<el-button @click="downloadTask(props.row.download)" :disabled="operational(props.row.download)">下载</el-button>
<el-button @click="deleteGallery(props.row.gid)" :disabled="operational(props.row.download)">删除</el-button>
<el-button @click="onlineGalleryReader(props.row.name)" :disabled="operational(props.row.download)">在线看</el-button>
</template>
</el-table-column>
<el-table-column label="名字" width="200">
<template #default="scoped">
{{scoped.row.name}}
</template>
</el-table-column>
<el-table-column label="进度" width="60">
<template #default="scoped">
{{ scoped.row.progress }}
</template>
</el-table-column>
</el-table>
<el-table :data="videoTasks" v-show="isShowVideoHistory">
<el-table-column type="expand">
<template #default="props">
名字:{{props.row.name}} <br>
网站:{{props.row.website}} <br>
链接:<el-link :href="props.row.link">链接</el-link> <br>
文件大小:{{props.row.fileSize}} <br>
视频长度:{{props.row.duration}} <br>
分辨率:{{props.row.resolution}} <br>
<el-button @click="downloadTask(props.row.download)" :disabled="operational(props.row.download)">下载</el-button>
<el-button @click="deleteVideo(props.row.id)" :disabled="operational(props.row.download)">删除</el-button>
<el-button @click="onlineVideoViewer(props.row.name)" :disabled="operational(props.row.download)">在线看</el-button>
</template>
</el-table-column>
<el-table-column label="名字" width="200">
<template #default="scoped">
{{scoped.row.name}}
</template>
</el-table-column>
<el-table-column label="进度" width="60">
<template #default="scoped">
{{ scoped.row.progress }}
</template>
</el-table-column>
</el-table>
<el-row class="pageChanger">
<el-col>
<el-button @click="toMin">{{min}}</el-button>
<el-button @click="previous">-</el-button>
<el-input v-model="targetPage"
@change="changePage"
v-show="isEditing"
@blur="reverse"
class="page"
ref="inputNode"></el-input>
<span @click="reverse" v-show="!isEditing" class="page">{{page}}</span>
<el-button @click="next">+</el-button>
<el-button @click="toMax">{{max}}</el-button>
</el-col>
<el-col>
<el-button @click="changeShowType">切换</el-button>
</el-col>
</el-row>
</div>
</div>
</el-drawer>
</template>
<script>
import store from "../store";
import {computed, ref} from "vue";
export default {
name: "Side",
setup(){
const targetPage = ref(1)
const isEditing = ref(false)
let inputNode = ref(null)
let showType = ref("本子")
let galleryTasks = computed(() => {
if(store.getters.galleryTasks)
return store.getters.galleryTasks
else
return null
})
let videoTasks = computed(() => {
if(store.getters.videoTasks)
return store.getters.videoTasks
else
return null
})
let isShowVideoHistory = computed(() => {
return store.getters.showType === "video"
})
let isShowGalleryHistory = computed(() => {
return store.getters.showType === "gallery"
})
let isOpenHistoryPanel = computed(() => {
return store.getters.isShowHistory
})
let min = computed(() => {
return store.getters.min
})
let max = computed(() => {
if(targetPage.value > store.getters.max)
store.commit("_changePage", store.getters.max)
return store.getters.max
})
let page = computed(() => {
targetPage.value = store.getters.page
return store.getters.page
})
let loadComplete = computed(() => {
return store.getters.loadComplete
})
function next() {
if(targetPage.value < max.value) {
targetPage.value++
store.commit("_changePage", targetPage.value)
}
}
function previous() {
if(targetPage.value > min.value) {
targetPage.value--
store.commit("_changePage", targetPage.value)
}
}
function toMax() {
store.commit("_changePage", max.value)
targetPage.value = max.value
}
function toMin(){
store.commit("_changePage", min.value)
targetPage.value = min.value
}
function changePage(){
if(targetPage.value >= min.value && targetPage.value <= max.value)
store.commit("_changePage", targetPage.value)
}
function reverse(){
isEditing.value = !isEditing.value
if(isEditing){
inputNode.value.focus()
}
targetPage.value = page.value
}
function closeHistoryPanel(){
store.commit("_closeHistoryPanel")
}
function downloadTask(link){
window.open(link)
}
function deleteGallery(gid){
store.dispatch("deleteGallery", gid)
}
function deleteVideo(id){
store.dispatch("deleteVideo", id)
}
function onlineGalleryReader(name){
window.open("http://100.42.234.138:8080/1/gallery/" + encodeURI(name))
}
function onlineVideoViewer(name){
window.open("http://100.42.234.138:8080/1/video/")
}
function changeShowType(){
if(isShowVideoHistory.value){
store.commit("_setShowType", "gallery")
showType.value = "本子"
}
else{
store.commit("_setShowType", "video")
showType.value = "视频"
}
}
function operational(task){
return task === null
}
return {galleryTasks,
videoTasks,
min,
max,
targetPage,
loadComplete,
page,
isEditing,
inputNode,
isOpenHistoryPanel,
isShowVideoHistory,
isShowGalleryHistory,
showType,
reverse,
changePage,
changeShowType,
closeHistoryPanel,
toMax,
toMin,
previous,
next,
downloadTask,
deleteGallery,
deleteVideo,
onlineGalleryReader,
onlineVideoViewer,
operational,
store
}
}
}
</script>
<style scoped>
.side{
text-align: center;
}
span{
display: block;
}
.pageChanger{
position: absolute;
top:88vh;
left: 45px;
}
.page{
display: inline-block;
width: 50px;
}
</style>

7
src/main.js Normal file
View File

@ -0,0 +1,7 @@
import { createApp } from 'vue'
import App from './App.vue'
import 'element-plus/dist/index.css'
import element from "element-plus"
import "./reset.css"
createApp(App).use(element).mount('#app')

402
src/store/index.js Normal file
View File

@ -0,0 +1,402 @@
import vuex from "vuex"
import axios from "axios"
import {ElMessage} from "element-plus"
import qs from "qs"
const BaseUrl = "http://100.42.234.138:8888/"
const GalleryTaskHandlerUrl = BaseUrl + "GalleryTaskHandler/"
const VideoTaskHandlerUrl = BaseUrl + "VideoTaskHandler/"
const actions = {
updateGalleryTasks(context){
const AuthCode = context.state.AuthCode
axios.get(GalleryTaskHandlerUrl, {
params:{
param:"",
type:"all",
AuthCode
}
}).then((res) => {
let temp = []
context.commit("_emptyGalleryTasks")
JSON.parse(res.data.data).forEach((task) => {
temp.push(task)
})
context.commit("_updateGalleryTasks", temp)
})
},
updateVideoTasks(context){
const AuthCode = context.state.AuthCode
axios.get(VideoTaskHandlerUrl, {
params:{
param:"123",
type:"all",
AuthCode
}
}).then(res => {
let temp = []
context.commit("_emptyVideoTasks")
JSON.parse(res.data.data).forEach(task => {
temp.push(task)
})
context.commit("_updateVideoTasks", temp)
})
},
postGalleryTask(context, data){
axios.post(GalleryTaskHandlerUrl, qs.stringify({
AuthCode:context.state.AuthCode,
link:data.link,
targetResolution:data.targetResolution
})).then((res) => {
if(res.data.result === "success") {
ElMessage("提交成功")
context.commit("_setPreDownloadGallery", {gallery:false, resolution:data.targetResolution})
}
else{
if(res.data.data)
ElMessage(res.data.data)
else{
ElMessage("提交失败")
}
}
})
},
postVideoTask(context, data){
axios.post(VideoTaskHandlerUrl, qs.stringify({
AuthCode:context.state.AuthCode,
link: data.link,
targetResolution: data.targetResolution
})).then((res) => {
if(res.data.result === "success") {
ElMessage("提交成功")
context.commit("_setPreDownloadVideo", {video:false, resolution:data.targetResolution})
}
else{
if(res.data.data)
ElMessage(res.data.data)
else{
ElMessage("提交失败")
}
}
})
},
queryGalleryTask(context, link){
const AuthCode = context.state.AuthCode
axios.get(GalleryTaskHandlerUrl, {
params:{
param:link,
type:'link',
AuthCode
}
}).then((res) => {
if(res.data.result === 'success'){
const gallery = JSON.parse(res.data.data)
context.commit("_setPreDownloadGallery", {gallery})
}
else
ElMessage("查询失败")
})
},
queryVideoTask(context, link){
const AuthCode = context.state.AuthCode
axios.get(VideoTaskHandlerUrl, {
params:{
param: link,
type:"link",
AuthCode
}
}).then((res) => {
if(res.data.result === 'success'){
const video = JSON.parse(res.data.data)
context.commit("_setPreDownloadVideo", {video})
}
else
ElMessage("查询失败")
})
},
validate(context, AuthCode){
axios.post(BaseUrl + "validate?AuthCode=" + AuthCode).then((res)=>{
if(res.data.result === 'success'){
context.commit("_authed", AuthCode, context)
context.dispatch("updateGalleryTasks").then()
context.dispatch("updateVideoTasks").then()
setInterval(() => {
context.dispatch("update").then()
}, 30000)
}
else{
context.commit("_unAuthed")
}
})
},
update(context){
if(context.state.showType === "video")
context.dispatch("updateVideoTasks").then()
else
context.dispatch("updateGalleryTasks").then()
},
searchByLink(context, link){
context.commit("_searchByLink", link)
},
searchByKeyword(context, keyword){
context.commit("_searchByKeyword", keyword)
},
deleteGallery(context, gid){
axios.delete(GalleryTaskHandlerUrl, {
params:{
AuthCode:state.AuthCode,
gid
}}).then((res) => {
if(res.data.result === "success"){
ElMessage("删除成功")
context.commit("_deleteGallery", gid)
}
else{
ElMessage(res.data.data)
}
})
},
deleteVideo(context, id){
axios.delete(VideoTaskHandlerUrl, {
params:{
AuthCode:state.AuthCode,
id
}
}).then((res) => {
if(res.data.result === "success"){
ElMessage("删除成功")
context.commit("_deleteVideo", id)
}
else{
ElMessage(res.data.data)
}
})
}
}
const mutations = {
_emptyGalleryTasks(state){
state.totalGalleryTask.splice(0)
},
_emptyVideoTasks(state){
state.totalVideoTask.splice(0)
},
_updateGalleryTasks(state, tasks){
const download_url = GalleryTaskHandlerUrl + "file?link="
tasks.forEach((task) => {
if(task.status === "已提交"){
task.progress = "已提交"
}
else if(task.status === "下载中"){
task.progress = (Math.round((task.proceeding / task.pages)*100)).toString() + "%"
}
else if(task.status === "下载完成"){
task.progress = "下载完成"
task.download = download_url + task.link + "&AuthCode=" + state.AuthCode
}
state.totalGalleryTask.push(task)
})
if(state.isAuth && !state.loadComplete){
state.loadComplete = true
ElMessage("加载完成")
}
},
_updateVideoTasks(state, tasks){
const downloadUrl = VideoTaskHandlerUrl + "file?link="
tasks.forEach((task) => {
task.progress = task.status
if(task.status === "下载完成"){
let tempLink
if(task.link.includes("xvideos.com"))
tempLink = task.link.replace("xvideos", "xiaomi")
else if(task.link.includes("cn.pornhub"))
tempLink = task.link.replace("cn.pornhub", "pixiv")
else
tempLink = task.link.replace("pornhub", "pixiv")
task.download = downloadUrl + tempLink + "&AuthCode=" + state.AuthCode
}
state.totalVideoTask.push(task)
})
},
_changePage(state, targetPage){
state.page = targetPage
},
_authed(state, AuthCode){
state.AuthCode = AuthCode
state.isAuth = true
ElMessage("验证成功,加载中")
},
_unAuthed(state){
state.isAuth = false
state.AuthCode = ""
ElMessage("授权码错误")
localStorage.removeItem("auth")
},
_searchByLink(state, link){
let tasks
if(state.showType === "gallery") {
tasks = state.totalGalleryTask
}
else
tasks = state.totalVideoTask
let i = 0
let found = false
for (i = 0; i < tasks.length; i++) {
if (tasks[i].link === link) {
state.page = Math.floor(i / state.length) + 1
found = true
break
}
}
if(!found){
ElMessage("未找到此任务")
}
else{
ElMessage("已跳转到该任务所在页数")
}
},
_searchByKeyword(state, keyword){
state.searchTask.splice(0)
state.page = 1
let tasks
if(state.showType === "video")
tasks = state.totalVideoTask
else
tasks = state.totalGalleryTask
tasks.forEach((task) => {
if(task.name.includes(keyword))
state.searchTask.push(task)
})
if(state.searchTask.length === 0){
ElMessage("未找到该关键字的任务")
}
},
_deleteGallery(state, gid){
state.totalGalleryTask.forEach((item, index, arr) => {
if(item.gid === gid){
arr.splice(index, 1)
}
})
},
_deleteVideo(state, id){
state.totalVideoTask.forEach((item, index, arr) => {
if(item.id === id)
arr.splice(index, 1)
})
},
_setPreDownloadGallery(state,data){
if(data.gallery === false) {
state.preDownloadGallery.resolution = data.resolution
state.preDownloadGallery.fileSize = "等待下载完成后再查看"
state.totalGalleryTask.push(state.preDownloadGallery)
}
state.preDownloadGallery = data.gallery
},
_setPreDownloadVideo(state,data){
if(data.video === false) {
state.preDownloadVideo.resolution = data.resolution
state.preDownloadVideo.fileSize = "下载完成后再查看"
state.preDownloadVideo.duration = "下载完成后再查看"
state.totalVideoTask.push(state.preDownloadVideo)
}
state.preDownloadVideo = data.video
},
_setShowType(state, showType){
state.showType = showType
},
_openHistoryPanel(state){
state.isShowHistory = true
},
_closeHistoryPanel(state){
state.isShowHistory = false
}
}
const state = {
totalGalleryTask:[], //存放本子数据的数组
preDownloadGallery:false, //准备下载的本子
totalVideoTask:[], //存放视频数据的数组
preDownloadVideo:false, //准备下载的视频
page:1, //当前页数
length:8, //每页能有多少个链接
isAuth:false, //是否授权
AuthCode:'', //授权码
loadComplete:false, //是否加载完成
isInclude:false, //是否搜索到任务
searchTask:[], //搜索到的任务
isShowHistory:false, //是否打开面板
showType:"gallery"
}
const getters = {
galleryTasks(state){
if(state.searchTask.length !== 0)
return state.searchTask.slice((state.page-1)*state.length, state.page*state.length)
if(state.totalGalleryTask.length !== 0)
return state.totalGalleryTask.slice((state.page-1)*state.length, state.page*state.length)
return null
},
videoTasks(state){
if(state.searchTask.length !== 0)
return state.searchTask.slice((state.page-1)*state.length, state.page*state.length)
if(state.totalVideoTask.length !== 0)
return state.totalVideoTask.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.showHistory === "gallery")
if(state.totalGalleryTask.length !== 0)
tasks = state.totalGalleryTask
else if(state.showHistory === "video")
if(state.totalVideoTask.length)
tasks = state.totalVideoTask
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
},
preDownloadGallery(state){
return state.preDownloadGallery
},
preDownloadVideo(state){
return state.preDownloadVideo
},
isShowHistory(state){
return state.isShowHistory
},
showType(state){
return state.showType
}
}
export default new vuex.Store({
actions,
mutations,
state,
getters
})