<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>上传</title>
    <!-- import Vue.js -->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.6/vue.min.js"></script>
    <!-- import stylesheet -->
    <link href="https://cdn.bootcdn.net/ajax/libs/iview/3.5.5-rc.1/styles/iview.min.css" rel="stylesheet">
    <!-- import iView -->
    <script src="https://cdn.bootcdn.net/ajax/libs/iview/3.5.5-rc.1/iview.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    <style>
        #app {
            margin: 20px 40px;
        }
    </style>
</head>

<body>
    <div id="app">

        <h1>上传文件</h1>

        <upload type="drag" action="/upload" paste="true" accept=".zip" :on-success="handleSuccess">
            <div style="padding: 20px 0">
                <icon type="ios-cloud-upload" size="52" style="color: #3399ff"></icon>
                <p>点击或者拖拽上传</p>
            </div>
        </upload>

        <alert type="success" v-for="url in zips">
            浏览地址：${ url }
        </alert>



        <strong>历史prd:</strong>
        <br><br>
        <list border>
            <list-item v-for="dir in dirs">
                <a :href="dir.url" target="_blank">${ dir.name }</a> &nbsp;&nbsp; <span>${ dir.dateTime}</span>
            </list-item>
        </list>
    </div>
    <script>
        new Vue({
            el: "#app",
            delimiters: ['${', '}'],
            data: {
                zips: [],
                dirs: [],
            },
            methods: {
                handleSuccess(response, file, fileList) {
                    this.zips.push(response.url)
                }
            },
            created() {
                axios.get("/dirs").then((res) => {
                    this.dirs = res.data.dirs
                })
            },
        })
    </script>
</body>

</html>