Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
qxz committed May 6, 2020
2 parents 54e92d0 + baa69d3 commit 7fe00f1
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Acrou: [https://oss.achirou.workers.dev/](https://oss.achirou.workers.dev/)

Since the original author of `goindex` has deleted the `donwa/goindex` warehouse, the extension and modification will be made on this version [yanzai/goindex](https://github.com/yanzai/goindex) in the future

1. Replace `index.js` with [index.js](https://ossdev.achirou.workers.dev/0:/go2index/index.js?a=view)
1. Replace `index.js` with [index.js](https://oss.achirou.workers.dev/0:/go2index/index.js?a=view)
2. Modify the app.js used in index.js of goindex to `https://cloud.jsonpop.cn/go2index/last/app.mini.js`

> The theme file is in the dist directory
Expand Down
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Acrou: [https://oss.achirou.workers.dev/](https://oss.achirou.workers.dev/)

由于`goindex`原作者已将`donwa/goindex`仓库删除,以后将在这个版本上[yanzai/goindex](https://github.com/yanzai/goindex)进行扩展修改

1. 替换`index.js`[index.js](https://ossdev.achirou.workers.dev/0:/go2index/index.js?a=view)
1. 替换`index.js`[index.js](https://oss.achirou.workers.dev/0:/go2index/index.js?a=view)
2. 修改goindex的index.js中所使用的app.js为(https://cloud.jsonpop.cn/go2index/last/app.mini.js)

> 主题文件在dist目录
Expand Down Expand Up @@ -60,4 +60,4 @@ Combining the power of [Cloudflare Workers](https://workers.cloudflare.com/) and

## About

Cloudflare Workers allow you to write JavaScript which runs on all of Cloudflare's 150+ global data centers.
Cloudflare Workers allow you to write JavaScript which runs on all of Cloudflare's 150+ global data centers.
18 changes: 15 additions & 3 deletions dist/app.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/app.mini.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var styles = [
'https://cdn.jsdelivr.net/npm/bulma@0.8.1/css/bulma.min.css',
'https://cdn.jsdelivr.net/npm/bulma-tooltip@3.0.2/dist/css/bulma-tooltip.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css',
'https://cdn.jsdelivr.net/npm/font-awesome-animation@0.2.1/dist/font-awesome-animation.min.css',
'https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css',
'https://cdn.jsdelivr.net/npm/bulma-pageloader@0.3.0/dist/css/bulma-pageloader.min.css'
]
styles.forEach(item=>{
document.write(`<link rel="stylesheet" href="${item}">`);
Expand Down Expand Up @@ -63,6 +65,10 @@ document.write(
white-space: nowrap;
vertical-align: middle;
}
.table td:hover {
cursor: pointer;
}
.no-content {
background: url(https://s1.hdslb.com/bfs/static/jinkela/search/asserts/no-data.png) no-repeat 50% 50%;
Expand Down
46 changes: 46 additions & 0 deletions src/page/html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Vue from "vue";
import { get_file } from "../utils/AcrouUtil";

var gohtml = Vue.component("gohtml", {
props: {
option: {
path: "",
file: {},
},
},
watch: {
option(val) {
this.loading = true;
get_file(this.option, (data) => {
this.content = data;
this.loading = false;
});
},
},
data: function () {
return {
loading: true,
content: "",
};
},
mounted() {
const oIframe = document.getElementById("iframe");
const deviceHeight = document.documentElement.clientHeight;
oIframe.style.height = Number(deviceHeight) + "px";
},
methods: {
},
template: `
<div>
<a href="https://github.com/Aicirou/goindex-theme-acrou" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#fff; color:#151513; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<iframe id="iframe" frameborder="0" scrolling="no" width="100%" :srcdoc="content"></iframe>
<div :class="'pageloader'+(loading?' is-active':'')">
<span class="title">
该功能目前处于测试阶段,欢迎大家提建议<i class="fab fa-github"></i>
</span>
</div>
</div>
`,
});

export default gohtml;
18 changes: 15 additions & 3 deletions src/page/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import list from "./list";
import gotext from "./text";
import goimg from "./img";
import gofooter from "../common/footer";
import gohtml from "./html";
import gocheck from "../common/check";
import { getQueryString, get_filex } from "../utils/AcrouUtil";

Expand All @@ -17,6 +18,7 @@ var layout = Vue.component("layout", {
path: "",
show: "list",
text: { file: {}, path: "" },
html: { file: {}, path: "" },
headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" },
};
Expand All @@ -32,6 +34,7 @@ var layout = Vue.component("layout", {
gotext: gotext,
goimg: goimg,
gofooter: gofooter,
gohtml,
gocheck
},
methods: {
Expand All @@ -46,6 +49,14 @@ var layout = Vue.component("layout", {
} else {
var name = path.split("/").pop();
var ext = name.split(".").pop().toLowerCase();
// if("|html|htm|".indexOf(`|${ext}|`) >= 0){
// this.show = "html"
// this.html = {
// path: path,
// file: {},
// };
// return
// }
if (
"|html|php|css|go|java|js|json|txt|sh|md|".indexOf(`|${ext}|`) >= 0
) {
Expand Down Expand Up @@ -76,8 +87,8 @@ var layout = Vue.component("layout", {
},
template: `
<div>
<navbar ref="navbar"></navbar>
<section class="section">
<navbar ref="navbar" v-if="show!=='html'"></navbar>
<section class="section" v-if="show!=='html'">
<div class="container">
<goheadmd :option="headmd" v-show="headmd.display"></goheadmd>
<breadcrumb ref="breadcrumb"></breadcrumb>
Expand All @@ -87,9 +98,10 @@ var layout = Vue.component("layout", {
<goreadmemd :option="readmemd" v-show="readmemd.display"></goreadmemd>
<gotext :option="text" v-show="show=='text'"></gotext>
<goimg ref="goimg" v-show="show=='img'"></goimg>
<gofooter></gofooter>
<gofooter v-show="show!=='html'"></gofooter>
</div>
</section>
<gohtml :option="html" v-show="show=='html'"></gohtml>
<gocheck></gocheck>
</div>
`,
Expand Down
4 changes: 2 additions & 2 deletions src/page/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ var list = Vue.component("list", {
<td class="is-hidden-mobile is-hidden-touch">{{file.size}}</td>
<td class="is-hidden-mobile is-hidden-touch" v-if="file.mimeType!=='application/vnd.google-apps.folder'">
<span class="icon" @click.stop="go(file,'_blank')">
<i class="fa fa-external-link" title="Open a new tab" aria-hidden="true"></i>
<i class="fa fa-external-link faa-shake animated-hover" title="Open a new tab" aria-hidden="true"></i>
</span>
<span class="icon" @click.stop="go(file,'down')">
<i class="fa fa-download" title="Download"></i>
<i class="fa fa-download faa-shake animated-hover" title="Download"></i>
</span>
</td>
</tr>
Expand Down
47 changes: 34 additions & 13 deletions src/utils/AcrouUtil.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
import axios from "./axios";

const exts = ["html", "php", "css", "go", "java", "js", "json", "py", "txt", "sh", "md", "mp4", "webm", "mkv", "bmp", "jpg", "jpeg", "png", "gif"];

const exts = [
"html",
"php",
"css",
"go",
"java",
"js",
"json",
"py",
"txt",
"sh",
"md",
"mp4",
"webm",
"mkv",
"bmp",
"jpg",
"jpeg",
"png",
"gif",
];

export const checkoutPath = (path, file) => {
var ext = path.split(".").pop();
// 解决/css这种也会匹配的问题
var ext = path.split(".").length > 1 ? path.split(".").pop() : "";
if (exts.indexOf(`${ext}`) >= 0) {
path += "?a=view";
} else {
if (file.mimeType === "application/vnd.google-apps.folder") {
if(path.substr(-1) !== '/'){
if (path.substr(-1) !== "/") {
path += "/";
}
}
}
return path
}
return path;
};

export const getQueryString = (path, param) => {
if (!path) {
Expand All @@ -27,12 +47,13 @@ export const getQueryString = (path, param) => {

export const getURLParameters = (url) =>
url
.match(/([^?=&]+)(=([^&]*))/g)
.reduce(
(a, v) => (
(a[v.slice(0, v.indexOf("="))] = v.slice(v.indexOf("=") + 1)), a
), {}
);
.match(/([^?=&]+)(=([^&]*))/g)
.reduce(
(a, v) => (
(a[v.slice(0, v.indexOf("="))] = v.slice(v.indexOf("=") + 1)), a
),
{}
);

// console.log(getURLParameters("/Movies/xx.mp4?a=view&y=123"));

Expand Down Expand Up @@ -117,4 +138,4 @@ export function formatFileSize(bytes) {
bytes = "";
}
return bytes;
}
}

0 comments on commit 7fe00f1

Please sign in to comment.