Skip to content

Commit 469839a

Browse files
author
li-guohao
committed
feat: support import path in console.
1 parent 2e961fb commit 469839a

3 files changed

Lines changed: 133 additions & 9 deletions

File tree

console/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"dependencies": {
1212
"@element-plus/icons-vue": "^2.1.0",
1313
"@runikaros/shared": "^0.0.2",
14-
"vue": "^3.2.47"
14+
"axios": "^1.7.2",
15+
"js-base64": "^3.7.7"
1516
},
1617
"devDependencies": {
1718
"@types/node": "^16.18.0",
@@ -21,5 +22,8 @@
2122
"typescript": "^5.0.2",
2223
"vite": "^4.3.9",
2324
"vue-tsc": "^1.4.2"
25+
},
26+
"peerDependencies": {
27+
"vue": "^3.2.45"
2428
}
2529
}

console/pnpm-lock.yaml

Lines changed: 76 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console/src/views/AListControl.vue

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,64 @@
11
<script setup lang="ts">
22
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+
}
351
4-
const alistPath = ref("/")
552
</script>
653

754
<template>
855
<div class="ik-plugin-alist-container">
956
<h3>AList 插件操作</h3>
1057
<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>
1762
</template>
1863

1964
<style scoped>

0 commit comments

Comments
 (0)