142 lines
5.8 KiB
HTML
142 lines
5.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Admin Console</title>
|
|
<link rel="icon" href="/assets/favicon.ico" type="image/x-icon"/>
|
|
<link rel="bookmark" href="/assets/favicon.ico" type="image/x-icon"/>
|
|
<link href="/assets/vuetify-v2.6.9/vuetify-v2.6.9.min.css" rel="stylesheet"/>
|
|
<link href="/assets/vuetify-v2.6.9/materialdesignicons.min.css" rel="stylesheet">
|
|
|
|
<script src="/assets/vue/vue.min.js"></script>
|
|
<script src="/assets/vuetify-v2.6.9/vuetify-v2.6.9.min.js"></script>
|
|
<script src="/assets/axios/axios.min.js"></script>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
|
|
</head>
|
|
<body>
|
|
<div id="app"></div>
|
|
</body>
|
|
<script type="text/x-template" id="app-template">
|
|
<v-app id="inspire">
|
|
#{render "common/bar-admin.html" .}
|
|
<v-main class="grey lighten-3">
|
|
<v-container style="height: 100%">
|
|
<v-row style="height: 100%" class="justify-center">
|
|
<v-col cols="12" sm="12" md="3">
|
|
<v-sheet min-height="100%">
|
|
<v-card>
|
|
<v-card-title>写点什么吧
|
|
<v-spacer></v-spacer>
|
|
<v-btn color="primary" @click="send" :loading="sending">发送</v-btn>
|
|
</v-card-title>
|
|
|
|
<v-card-text>
|
|
<v-textarea outlined rows="8" v-model="content"></v-textarea>
|
|
<input id="i-files" type="file" multiple style="display: none"/>
|
|
<v-container style="height: 100%">
|
|
<v-row>
|
|
<v-col cols="4" v-for="(img,index) in images">
|
|
<div style="position: relative;padding: 0px">
|
|
<v-icon style="position: absolute;right: -20px;top: -20px;"
|
|
@click="removeImg(index)">mdi-close-thick
|
|
</v-icon>
|
|
<v-img :src="img" style="max-width: 150px;min-width: 100%"/>
|
|
</div>
|
|
|
|
</v-col>
|
|
<v-col cols="4">
|
|
<v-img src="/assets/images/addBtn.png" style="width: 100%"
|
|
@click="addImage"/>
|
|
<!-- <v-icon @click="addImage" style="width: 100%">mdi-plus-thick</v-icon>
|
|
<v-img src="/static/images/yage.jpg" @click="addImage"/> -->
|
|
</v-col>
|
|
<!-- <v-col cols="4">
|
|
<v-img src="/assets/images/yage.jpg"/>
|
|
</v-col>
|
|
<v-col cols="4">
|
|
<v-img src="/assets/images/yage.jpg"/>
|
|
</v-col> -->
|
|
</v-row>
|
|
</v-container>
|
|
</v-card-text>
|
|
|
|
<v-card-text v-if="error">
|
|
<p>发送失败,原因:</p>
|
|
<p>{{error.message}}</p>
|
|
</v-card-text>
|
|
</v-card>
|
|
|
|
</v-sheet>
|
|
</v-col>
|
|
</v-row>
|
|
</v-container>
|
|
</v-main>
|
|
</v-app>
|
|
</script>
|
|
<style type="text/css">
|
|
.v-responsive__sizer {
|
|
padding-bottom: 100% !important;
|
|
}
|
|
</style>
|
|
<script>
|
|
new Vue({
|
|
el: '#app',
|
|
template: '#app-template',
|
|
data: {
|
|
sending: false,
|
|
content: '',
|
|
files: [],
|
|
images: [],
|
|
error: null
|
|
},
|
|
methods: {
|
|
send() {
|
|
let formData = new FormData();
|
|
this.files.forEach((file) => {
|
|
formData.append("file", file);
|
|
});
|
|
formData.append('content', this.content)
|
|
this.sending = true
|
|
let ths = this
|
|
console.log(formData);
|
|
axios.post('/admin/diary/submit', formData, {headers: {"Content-Type": "multipart/form-data"}}).then(res => {
|
|
let data = res.data
|
|
console.log(data)
|
|
location.href = '/diary'
|
|
this.sending = false
|
|
}).catch(err => {
|
|
ths.error = err
|
|
console.error(err)
|
|
this.sending = false
|
|
});
|
|
|
|
},
|
|
|
|
addImage() {
|
|
let ths = this
|
|
let files = document.getElementById('i-files')
|
|
files.click()
|
|
|
|
files.onchange = () => {
|
|
let URL = window.URL || window.webkitURL
|
|
ths.files.push(...files.files)
|
|
|
|
for (let i = 0; i < files.files.length; i++) {
|
|
let file = files.files[i]
|
|
let src = URL.createObjectURL(file)
|
|
ths.images.push(src)
|
|
}
|
|
}
|
|
},
|
|
|
|
removeImg(index) {
|
|
this.images.splice(index, 1)
|
|
this.files.splice(index, 1)
|
|
}
|
|
|
|
},
|
|
vuetify: new Vuetify(),
|
|
})
|
|
|
|
</script>
|
|
</html> |