mirror of
https://github.com/rubickCenter/rubick
synced 2025-07-18 05:17:27 +08:00
feat: 支持 uTools list 模板
This commit is contained in:
parent
f34d93691d
commit
b08f4fab54
@ -162,6 +162,10 @@ export default {
|
||||
}
|
||||
},
|
||||
changeCurrent(index) {
|
||||
const webview = document.getElementById('webview');
|
||||
webview && webview.send('changeCurrent', index);
|
||||
if (!this.options) return;
|
||||
if (this.currentSelect + index > this.options.length - 1 || this.currentSelect + index < 0) return;
|
||||
this.currentSelect = this.currentSelect + index;
|
||||
},
|
||||
|
||||
|
@ -24,7 +24,7 @@ export default {
|
||||
webview: null,
|
||||
query: this.$route.query,
|
||||
config: {},
|
||||
templatePath: `File://${path.join(__static, './plugins/doc/doc-tpl.html')}?code=${JSON.parse(this.$route.query.detail).code}&targetFile=${encodeURIComponent(this.$route.query.sourceFile)}`,
|
||||
templatePath: `File://${path.join(__static, './plugins/tpl/index.html')}?code=${JSON.parse(this.$route.query.detail).code}&targetFile=${encodeURIComponent(this.$route.query.sourceFile)}&preloadPath=${this.$route.query.preload}`,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -75,7 +75,6 @@ export default {
|
||||
},
|
||||
beforeRouteUpdate() {
|
||||
this.path = `File://${this.$route.query.sourceFile}`;
|
||||
console.log(this.pluginInfo)
|
||||
this.webview.send('onPluginEnter', this.pluginInfo);
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
@ -72,7 +72,7 @@ export default {
|
||||
computed: {
|
||||
...mapState('main', ['devPlugins']),
|
||||
pluginDetail() {
|
||||
return this.devPlugins[this.currentSelect]
|
||||
return this.prodPlugin[this.currentSelect]
|
||||
},
|
||||
prodPlugin() {
|
||||
return this.devPlugins.filter(plugin => plugin.type === 'prod')
|
||||
|
@ -230,7 +230,13 @@ const actions = {
|
||||
id: uuidv4(),
|
||||
sourceFile: `${fileUrl}/${config.main}`,
|
||||
type: 'prod',
|
||||
icon: payload.logo
|
||||
icon: payload.logo,
|
||||
subType: (() => {
|
||||
if (config.main) {
|
||||
return ''
|
||||
}
|
||||
return 'template';
|
||||
})()
|
||||
};
|
||||
commit('commonUpdate', {
|
||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||
|
@ -4,8 +4,8 @@
|
||||
<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>
|
||||
<script src="../vue.min.js"></script>
|
||||
<script src="../vue-router.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
@ -54,6 +54,50 @@
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
.options {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 99;
|
||||
max-height: calc(100vh);
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
.options::-webkit-scrollbar {
|
||||
width: 0;
|
||||
}
|
||||
.op-item {
|
||||
padding: 0 10px;
|
||||
height: 60px;
|
||||
max-height: 500px;
|
||||
overflow: auto;
|
||||
background: #fafafa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
.icon {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 100%;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.title {
|
||||
width: 500px;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.desc {
|
||||
color: #999;
|
||||
width: 500px;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.op-item.active {
|
||||
background: #DEE2E8;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div id="app">
|
||||
@ -61,5 +105,6 @@
|
||||
</div>
|
||||
</body>
|
||||
<script src="./doc.js" type="module"></script>
|
||||
<script src="./list.js" type="module"></script>
|
||||
<script src="./index.js" type="module"></script>
|
||||
</html>
|
@ -1,4 +1,6 @@
|
||||
import doc from './doc.js';
|
||||
import list from './list.js';
|
||||
|
||||
function getQueryVariable(variable) {
|
||||
var query = window.location.search.substring(1);
|
||||
var vars = query.split("&");
|
||||
@ -11,6 +13,7 @@ function getQueryVariable(variable) {
|
||||
|
||||
const routes = [
|
||||
{ path: '/doc', name: 'doc', component: doc },
|
||||
{ path: '/list', name: 'list', component: list },
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
@ -22,7 +25,7 @@ new Vue({
|
||||
data: {
|
||||
config: window.exports,
|
||||
code: '',
|
||||
current: {}
|
||||
current: {},
|
||||
},
|
||||
mounted() {
|
||||
this.code = getQueryVariable('code');
|
60
static/plugins/tpl/list.js
Normal file
60
static/plugins/tpl/list.js
Normal file
@ -0,0 +1,60 @@
|
||||
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);
|
||||
}
|
||||
|
||||
export default {
|
||||
template: `
|
||||
<div class="list-container">
|
||||
<div class="options" v-show="!!lists.length">
|
||||
<div :class="currentSelect === index ? 'active op-item' : 'op-item'" v-for="(item, index) in lists" @click="() => select(item)">
|
||||
<img class="icon" :src="item.icon" />
|
||||
<div class="content">
|
||||
<div class="title">{{item.title}}</div>
|
||||
<div class="desc">{{decodeURIComponent(item.description)}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
data() {
|
||||
return {
|
||||
query: this.$route.query,
|
||||
menu: [],
|
||||
active: 0,
|
||||
config: window.exports,
|
||||
lists: [],
|
||||
currentSelect: 0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.code = getQueryVariable('code');
|
||||
this.current = this.config[this.code];
|
||||
this.current.args.enter && this.current.args.enter({code: this.code, type: '', payload: [] }, (lists) => {
|
||||
this.lists = lists;
|
||||
});
|
||||
ipcRenderer.on(`changeCurrent`, (e, result) => {
|
||||
if (this.currentSelect + result > this.lists.length - 1 || this.currentSelect + result < 0) return;
|
||||
this.currentSelect = this.currentSelect + result;
|
||||
});
|
||||
ipcRenderer.on(`msg-back-setSubInput`, (e, result) => {
|
||||
this.current.args.search && this.current.args.search({code: this.code, type: '', payload: [] }, result, (lists) => {
|
||||
this.lists = lists;
|
||||
})
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
select(item) {
|
||||
this.current.args.select && this.current.args.select({code: this.code, type: '', payload: [] }, item);
|
||||
},
|
||||
renderTitle(title) {
|
||||
const result = title.split(this.searchValue);
|
||||
return `<div>${result[0]}<span style="color: red">${this.searchValue}</span>${result[1]}</div>`
|
||||
},
|
||||
}
|
||||
}
|
6
static/plugins/vue-router.min.js
vendored
Normal file
6
static/plugins/vue-router.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
static/plugins/vue.min.js
vendored
Normal file
6
static/plugins/vue.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -18,7 +18,7 @@ if (location.href.indexOf('targetFile') > -1) {
|
||||
} else {
|
||||
filePath = location.pathname.replace('file://', '');
|
||||
}
|
||||
const {ipcRenderer, nativeImage, clipboard, remote} = require('electron');
|
||||
const {ipcRenderer, nativeImage, clipboard, remote, shell} = require('electron');
|
||||
|
||||
const currentWindow = remote.getCurrentWindow();
|
||||
const winId = currentWindow.id;
|
||||
@ -281,8 +281,13 @@ window.utools = window.rubick = {
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
shellOpenExternal(url) {
|
||||
shell.openExternal(url);
|
||||
}
|
||||
}
|
||||
require(path.join(filePath, '../preload.js'));
|
||||
window.exports && ipcRenderer.sendToHost('templateConfig', {config: window.exports});
|
||||
const preloadPath = getQueryVariable('preloadPath') || './preload.js';
|
||||
|
||||
require(path.join(filePath, '../', preloadPath));
|
||||
window.exports && ipcRenderer.sendToHost('templateConfig', {config: JSON.parse(JSON.stringify(window.exports))});
|
||||
window.ipcRenderer = ipcRenderer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user