Files
FileCodeBox/templates/index.html
T

308 lines
13 KiB
HTML
Raw Permalink Normal View History

2022-12-09 19:06:47 +08:00
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="/static/assert/index.css">
<title>{{title}}</title>
<meta name="description" content="{{description}}"/>
<meta name="keywords" content="{{keywords}}"/>
<meta name="generator" content="FileCodeBox"/>
2022-12-11 18:03:46 +08:00
<meta name="template" content="Lan-V1.4.2"/>
2022-12-09 19:06:47 +08:00
<style>
.qu .el-button {
width: 100px;
height: 100px;
margin: 0.2rem;
font-size: 30px;
font-weight: bold;
}
.qu .el-input__inner {
height: 100px;
margin: 1rem 0;
font-size: 30px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="app" style="text-align: center;">
2022-12-11 12:11:10 +08:00
<el-row v-if="tool === 0" class="qu" style="width:400px;margin: 6vh auto 0 auto">
2022-12-09 19:06:47 +08:00
<el-card style="padding-bottom: 1rem">
<el-col :span="24">
<el-input autofocus @input="inputing" clearable v-model:value="code" maxlength="5"
:disabled="inout_disable"
placeholder="请输入取件码"></el-input>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('1')">1</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('2')">2</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('3')">3</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('4')">4</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('5')">5</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('6')">6</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('7')">7</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('8')">8</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('9')">9</el-button>
</el-col>
<el-col :span=8>
<el-button @click="tool=1">寄</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('0')">0</el-button>
</el-col>
<el-col :span=8>
<el-button @click="quDrawer=true">取</el-button>
</el-col>
</el-card>
</el-row>
<el-row v-else style="width:400px;margin: 20vh auto 0 auto">
2022-12-09 19:06:47 +08:00
<el-col :span="24" style="margin: 1rem 0">
<el-card>
<div style="margin-bottom: 1rem">
<el-radio-group v-model="destoryData.style">
<el-radio label="1">次数</el-radio>
<el-radio label="2">天数</el-radio>
</el-radio-group>
<el-input-number
placeholder="输入数量,默认1"
style="margin-left: 1rem" v-model="destoryData.value" controls-position="right" :min="1">
</el-input-number>
</div>
2022-12-09 19:06:47 +08:00
<el-upload
drag
action="/share"
multiple
:data="destoryData"
2022-12-09 19:06:47 +08:00
:on-success="successUpload"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文字、文件拖、粘贴到此处,或<em>点击上传</em></div>
<div class="el-upload__text" style="font-size: 10px">天数<7或限制次数(24h后删除)</div>
2022-12-09 19:06:47 +08:00
<div class="el-upload__tip" slot="tip">
<el-button @click="tool=0">去取件</el-button>
<el-button @click="cunDrawer=true">取件码</el-button>
2022-12-09 19:06:47 +08:00
</div>
</el-upload>
</el-card>
</el-col>
</el-row>
<div style="text-align: center; margin-top: 1rem;color: #606266">
2022-12-10 14:26:10 +08:00
<span> <a style="text-decoration: none;color: #606266" target="_blank"
href="https://github.com/vastsa/FileCodeBox">FileCodeBox</a></span>
2022-12-09 19:06:47 +08:00
</div>
<el-drawer
title="文件箱"
2022-12-09 19:06:47 +08:00
:visible.sync="quDrawer"
:direction="direction"
size="50%"
>
<el-card v-for="(file,index) in files" :key="index" class="box-card">
<div style="cursor: pointer;text-align: left">
<div>取件码:${ file.code }</div>
<div>文件名:${ file.name }</div>
<div v-if="file.name==='文本分享'">
2022-12-09 19:06:47 +08:00
<span>内&nbsp;&nbsp; 容:${ file.text }</span>
</div>
<div v-else>
<span>链&nbsp;&nbsp; 接:</span>
<a :href="file.text" target="_blank"
style="color: #1E9FFF;text-underline: none"
type="primary">点击下载</a>
</div>
</div>
</el-card>
<el-empty v-if="files.length===0" description="请输入取件码,收取文件"></el-empty>
</el-drawer>
<el-drawer
title="文件箱"
2022-12-09 19:06:47 +08:00
:visible.sync="cunDrawer"
direction="btt"
size="50%">
<el-card>
<el-empty v-if="files.length===0" description="请上传文件"></el-empty>
<el-card style="margin-top: 0.2rem" v-for="(file,index) in files" :key="index">
2022-12-09 19:06:47 +08:00
<el-row>
<el-col :span="20">
<el-row>
<el-col :span="24" style="line-height: 45px">
${ file.name }
</el-col>
<el-col :span="24">
取件码:<h1 style="margin: 0;display: inline">${ file.code }</h1>
</el-col>
</el-row>
2022-12-09 19:06:47 +08:00
</el-col>
<el-col :span="4">
<img style="width: 80px;height: 80px;"
:src="qrcodeUrl(file)" :alt="file.code">
2022-12-09 19:06:47 +08:00
</el-col>
</el-row>
</el-card>
</el-card>
</el-drawer>
</div>
</body>
<script src="/static/assert/qrcode.min.js"></script>
<script src="/static/assert/vue.min.js"></script>
<script src="/static/assert/index.js"></script>
<script src="/static/assert/axios.min.js"></script>
2022-12-09 19:06:47 +08:00
<script>
new Vue({
el: '#app',
delimiters: ['${', '}'],
data: function () {
return {
code: '',
inout_disable: false,
files: [],
quDrawer: false,
cunDrawer: false,
direction: 'btt',
tool: 0,
destoryData: {
style: '2',
value: 1
},
2022-12-09 19:06:47 +08:00
};
},
mounted: function () {
this.code = window.location.search.substring('code=='.length)
if (this.code) {
this.get_file();
}
const that = this
document.addEventListener('paste', function (event) {
if (that.tool === 1) {
const items = event.clipboardData && event.clipboardData.items;
if (items && items.length) {
for (let i = 0; i < items.length; i++) {
if (items[i].kind === 'string') {
if (items[i].type.match(/^text\/plain/)) {
const FileData = new FormData();
that.$message('剪切板文字正在上传,请稍等');
items[i].getAsString(function (str) {
FileData.append('text', str);
FileData.append('style', that.destoryData.style);
FileData.append('value', that.destoryData.value);
2022-12-09 19:06:47 +08:00
axios.post('/share', FileData)
.then(function (res) {
if (res.data.code === 200) {
that.$message({'message': res.data.msg, 'type': 'success'});
that.files.push(res.data.data)
} else {
that.$message({'message': res.data.msg, 'type': 'error'});
}
})
.catch(function (error) {
that.$message({'message': error.data.msg, 'type': 'error'});
});
2022-12-09 19:06:47 +08:00
});
}
} else {
const file = items[i].getAsFile();
that.$message('剪切板文件正在上传,请稍等');
const FileData = new FormData();
FileData.append('file', file || '');
FileData.append('style', that.destoryData.style);
FileData.append('value', that.destoryData.value);
2022-12-09 19:06:47 +08:00
axios.post('/share', FileData).then(async res => {
if (res.data.code === 200) {
that.$message({'message': res.data.msg, 'type': 'success'});
that.files.push(res.data.data)
} else {
that.$message({'message': res.data.msg, 'type': 'error'});
}
2022-12-09 19:06:47 +08:00
})
}
}
}
}
});
},
methods: {
inputing: function (value) {
if (value.length === 5) {
this.inout_disable = true;
this.get_file();
}
},
get_file: function () {
const that = this;
axios.post('?code=' + this.code).then(function (response) {
if (response.data.code === 404) {
that.$message({
message: response.data.msg,
type: 'error'
});
} else {
that.files.push(response.data.data);
that.$message({
message: response.data.msg,
type: 'success'
});
that.quDrawer = true;
2022-12-09 19:06:47 +08:00
}
that.code = '';
that.inout_disable = false
}).catch(function (error) {
console.log(error);
});
},
inputNumber: function (number) {
if (number === 'C') {
this.code = '';
} else if (number === 'X') {
this.code = this.code.substring(0, this.code.length - 1);
} else {
if (this.code.length < 5) {
this.code += number;
}
}
if (this.code.length === 5) {
this.inout_disable = true
this.get_file()
}
},
successUpload(response, file, fileList) {
if (response.code === 200) {
this.$message({
message: response.msg,
type: 'success'
});
this.files.push(response.data);
} else {
this.$message({
message: response.msg,
type: 'error'
});
}
2022-12-09 19:06:47 +08:00
},
qrcodeUrl(file) {
return 'https://api.qrserver.com/v1/create-qr-code/?data=' + window.location.origin + '/?code=' + file.code
},
2022-12-09 19:06:47 +08:00
}
})
</script>
</html>