|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { ref } from "vue" |
| 3 | +import axios from "axios"; |
| 4 | +import {Base64} from 'js-base64' |
| 5 | +
|
| 6 | +const path = ref('') |
| 7 | +
|
| 8 | +const http = axios.create({ |
| 9 | + baseURL: "/", |
| 10 | + timeout: 40 * 1000, // 30s |
| 11 | +}) |
| 12 | +
|
| 13 | +const doPostImportPath = () => { |
| 14 | + if (!path.value) { |
| 15 | + window.alert('请输入alist的相对路径,比如:/PKPK/LP-Raws/'); |
| 16 | + return; |
| 17 | + } |
| 18 | + // basic64 编码 |
| 19 | + console.debug('original path value: ', path.value); |
| 20 | + var base64Path = Base64.encode(path.value); |
| 21 | + console.debug('basic64 path value: ', base64Path); |
| 22 | + let config = { |
| 23 | + headers: {'Content-Type': "application/json;charset=UTF-8"} |
| 24 | + }; |
| 25 | + let data = { |
| 26 | + path: base64Path |
| 27 | + }; |
| 28 | + var submitBtn = document.getElementById('submitBtn') |
| 29 | + console.debug('submitBtn:', submitBtn) |
| 30 | + if (submitBtn) submitBtn.innerHTML = '处理中...' |
| 31 | + http.post('/apis/plugin.ikaros.run/v1alpha1/PluginAList/alist/import', data, config) |
| 32 | + .then((response) => { |
| 33 | + console.debug('response', response) |
| 34 | + if (response.status === 200) { |
| 35 | + window.alert('导入目录['+path.value+']成功!!') |
| 36 | + } |
| 37 | + }) |
| 38 | + .catch(error => { |
| 39 | + console.error(error) |
| 40 | + }) |
| 41 | + .finally(()=>{ |
| 42 | + if (submitBtn) submitBtn.innerHTML = '提交导入' |
| 43 | + }); |
| 44 | +
|
| 45 | +}; |
| 46 | +
|
| 47 | +const onInputChange = (event:any) => { |
| 48 | + // console.debug('event', event) |
| 49 | + path.value = event.target.value |
| 50 | +} |
3 | 51 |
|
4 | | -const alistPath = ref("/") |
5 | 52 | </script> |
6 | 53 |
|
7 | 54 | <template> |
8 | 55 | <div class="ik-plugin-alist-container"> |
9 | 56 | <h3>AList 插件操作</h3> |
10 | 57 | <hr /> |
11 | | - <form name="form" method="post" action="#"> |
12 | | - <input name="path" placeholder="请输入需要导入的相对路径路径" required v-model="alistPath"> |
13 | | - <input type="submit" name="submit" value="提交导入"> |
14 | | - {{alistPath}} |
15 | | - </form> |
16 | | - </div> |
| 58 | + <input style="width: 800px;display: block;" placeholder="请输入需要导入的相对路径,比如:/PKPK/LP-Raws , 递归处理,提交后还请耐心等待。" :value="path" @input="onInputChange"> |
| 59 | + <br /> |
| 60 | + <button id="submitBtn" v-on:click="doPostImportPath">提交导入</button> |
| 61 | + </div> |
17 | 62 | </template> |
18 | 63 |
|
19 | 64 | <style scoped> |
|
0 commit comments