feat: 支持文本模板,系统命令

This commit is contained in:
muwoo
2021-06-10 20:54:28 +08:00
parent 31e7e17cc9
commit 31d57fc404
29 changed files with 377 additions and 205 deletions

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script crossorigin="anonymous" src="https://lib.baomitu.com/vue/2.6.12/vue.min.js"></script>
<script src="https://lib.baomitu.com/vue-router/3.5.1/vue-router.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.doc-container {
width: 100%;
height: 100vh;
display: flex;
align-items: flex-start;
justify-content: flex-start;
border-top: 1px solid #ddd;
}
.doc-container .menu {
width: 200px;
height: 100%;
border-right: 1px solid #ddd;
overflow: auto;
background: #fff;
}
.doc-container .menu .item.active {
background: #DEE2E6;
}
.doc-container .menu .item {
padding: 5px 10px;
cursor: pointer;
}
.doc-container .menu .title {
font-size: 14px;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
width: 100%;
}
.doc-container .menu .desc {
font-size: 12px;
color: #999;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
width: 100%;
}
.frame {
flex: 1;
height: 100%;
border: none;
}
</style>
<body>
<div id="app">
<router-view />
</div>
</body>
<script src="./doc.js" type="module"></script>
<script src="./index.js" type="module"></script>
</html>

28
static/plugins/doc/doc.js Normal file
View File

@@ -0,0 +1,28 @@
export default {
template: `
<div class="doc-container">
<div class="menu">
<div @click="active = index" :class="active === index ? 'active item' : 'item'" v-for="(item, index) in menu">
<div class="title">{{item.t}}</div>
<div class="desc">{{item.d}}</div>
</div>
</div>
<iframe class="frame" :src="path" />
</div>
`,
data() {
return {
query: this.$route.query,
menu: [],
active: 0,
}
},
mounted() {
this.menu = JSON.parse(this.query.args).indexes || [];
},
computed: {
path() {
return decodeURIComponent(this.query.rootPath) + (this.menu[this.active] || {}).p
}
}
}

View File

@@ -0,0 +1,40 @@
import doc from './doc.js';
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
const routes = [
{ path: '/doc', name: 'doc', component: doc },
]
const router = new VueRouter({
routes
})
new Vue({
el: '#app',
data: {
config: window.exports,
code: '',
current: {}
},
mounted() {
this.code = getQueryVariable('code');
this.current = this.config[this.code];
this.$router.push({
name: this.current.mode,
query: {
args: JSON.stringify(this.current.args),
rootPath: getQueryVariable('targetFile').replace('index.html', '')
},
})
},
router,
})

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Picker</title>
<link rel="stylesheet" href="./picker.css" />
<script defer src="./picker.js"></script>
</head>
<body>
<section id="picker"></section>
</body>
</html>

View File

@@ -0,0 +1,17 @@
* {
margin: 0;
padding: 0;
}
body {
background: transparent;
cursor: crosshair;
overflow: hidden;
}
#picker {
width: 100px;
height: 100px;
border-radius: 120px;
box-sizing: border-box;
}

View File

@@ -0,0 +1,23 @@
const { ipcRenderer } = require("electron");
document.querySelector(
"#picker"
).style.border = `10px solid rgba(200, 200, 200, 0.3)`;
document.addEventListener(
"DOMContentLoaded",
() => ipcRenderer.send("pickerRequested"),
false
);
document.addEventListener(
"keydown",
(event) => {
if (event.key === "Escape") ipcRenderer.send("closePicker");
},
false
);
ipcRenderer.on("updatePicker", (event, color) => {
document.querySelector("#picker").style.border = `10px solid ${color}`;
});