Skip to content

Commit

Permalink
Merge pull request #39 from StringKe/master
Browse files Browse the repository at this point in the history
feat: 对接 info ,完善相关功能。
  • Loading branch information
StringKe authored Mar 13, 2022
2 parents ec9866c + 6fe3c88 commit c8841d1
Show file tree
Hide file tree
Showing 6 changed files with 3,669 additions and 3,249 deletions.
7 changes: 7 additions & 0 deletions src/API/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ export function searchAll(baseURL, key, token) {
cancelToken: token
});
}

export function getConfig(baseURL) {
return request({
method: "get",
url: `${baseURL}/info`
});
}
4 changes: 4 additions & 0 deletions src/assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,7 @@ code, pre, tt {
padding-left: 5px;
font-weight: 600;
}

.file-upload {
margin-left: .5rem;
}
15 changes: 14 additions & 1 deletion src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@
<div id="footer">
<span>
Powered by
<a href="https://github.com/cugxuan/gonelist">GONEList</a> | Theme —
<a href="https://github.com/cugxuan/gonelist">GONEList</a>
| Theme —
<a href="https://github.com/Sillywa/gonelist-web">GONEList-web</a>
| Version
<a :href="versionUrl">{{ version }}</a>
</span>
</div>
</template>

<script>
export default {
props: {
version: String
},
computed: {
versionUrl() {
return (
"https://github.com/gonelist/gonelist/releases/tag/" + this.version
);
}
},
data() {
return {};
}
Expand Down
4 changes: 1 addition & 3 deletions src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const service = axios.create({
// 添加响应拦截器
service.interceptors.response.use(
response => {
const res = response.data;
console.log(res);
return res;
return response.data;
},
error => {
if ("message" in error) {
Expand Down
71 changes: 63 additions & 8 deletions src/views/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="content">
<div class="title">
<h1>GONEList</h1>
<h1>{{ site_config.name }}</h1>
</div>

<div class="list-wrapper">
Expand Down Expand Up @@ -73,7 +73,13 @@
@keyup.native="search"
:key="'input-search'"
/>
<Button type="info" @click="upload">文件上传 </Button>
<Button
v-if="site_config.upload"
class="file-upload"
type="info"
@click="upload"
>文件上传
</Button>
</div>
</div>

Expand Down Expand Up @@ -267,13 +273,20 @@
<img :src="img_src" alt="" style="width: 100%; height: 100%" />
</Modal>

<M-Footer></M-Footer>
<M-Footer :version="site_config.version"></M-Footer>
</div>
</template>

<script>
import axios from "axios";
import { getAllFiles, logout, getReadme, searchAll, Upload } from "@/API/api";
import {
getAllFiles,
getConfig,
getReadme,
logout,
searchAll,
Upload
} from "@/API/api";
import { checkFileType } from "../utils/index";
import DPlayer from "../components/Dplayer";
import APlayer from "../components/Aplayer";
Expand Down Expand Up @@ -375,7 +388,14 @@ export default {
pass: "",
pass_count: 0,
img_modal: false,
img_src: ""
img_src: "",
site_config: {
load: false,
name: "GONEList",
page_title: "GONEList",
upload: false,
version: "v0.0.0"
}
};
},
mounted() {
Expand All @@ -395,6 +415,22 @@ export default {
},
// 深度观察监听
deep: true
},
path: {
handler: function(newValue) {
const cleanPaths = newValue.filter(i => i !== "/");
if (cleanPaths.length) {
const lastName = cleanPaths.slice(-1)[0];
const cleanPath = "/" + cleanPaths.join("/");
if (cleanPaths.length > 1) {
document.title = `${lastName} - ${cleanPath} - ${this.site_config.page_title}`;
} else {
document.title = `${lastName} - ${this.site_config.page_title}`;
}
} else {
document.title = this.site_config.page_title;
}
}
}
},
filters: {
Expand Down Expand Up @@ -472,6 +508,24 @@ export default {
};
tempDom.click();
},
loadConfig() {
if (!this.site_config.load) {
getConfig(this.baseurl)
.then(response => {
if (response.code === 200) {
const data = response.data;
this.site_config = Object.assign(this.site_config, data, {
load: true
});
document.title = this.site_config.page_title;
console.log(this.site_config);
}
})
.catch(err => {
console.log(err);
});
}
},
init() {
this.keywords = "";
this.hash = decodeURIComponent(window.location.hash);
Expand Down Expand Up @@ -531,7 +585,7 @@ export default {
this.modal = true;
} else {
this.files = res.data;
console.log(this.files.children);
// console.log(this.files.children);
// this.files.chirden = [];
// this.files.children.push(...this.files);
// if (!this.files.children) {
Expand All @@ -552,15 +606,16 @@ export default {
this.readme = res.data;
//console.log(this.readme)
});
this.loadConfig();
},
nextFile(index, name) {
console.log(name);
// console.log(name);
// if (this.path.length === 1) {
// this.hash = this.hash + name;
// } else {
// this.hash = this.hash + "/" + name;
// }
console.log("path==>" + this.path);
console.log("path ==>" + this.path);
this.hash =
this.path.length === 1 ? this.hash + name : this.hash + "/" + name;
Expand Down
Loading

0 comments on commit c8841d1

Please sign in to comment.