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) {
|
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;
|
this.currentSelect = this.currentSelect + index;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export default {
|
|||||||
webview: null,
|
webview: null,
|
||||||
query: this.$route.query,
|
query: this.$route.query,
|
||||||
config: {},
|
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() {
|
mounted() {
|
||||||
@ -75,7 +75,6 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeRouteUpdate() {
|
beforeRouteUpdate() {
|
||||||
this.path = `File://${this.$route.query.sourceFile}`;
|
this.path = `File://${this.$route.query.sourceFile}`;
|
||||||
console.log(this.pluginInfo)
|
|
||||||
this.webview.send('onPluginEnter', this.pluginInfo);
|
this.webview.send('onPluginEnter', this.pluginInfo);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
@ -72,7 +72,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState('main', ['devPlugins']),
|
...mapState('main', ['devPlugins']),
|
||||||
pluginDetail() {
|
pluginDetail() {
|
||||||
return this.devPlugins[this.currentSelect]
|
return this.prodPlugin[this.currentSelect]
|
||||||
},
|
},
|
||||||
prodPlugin() {
|
prodPlugin() {
|
||||||
return this.devPlugins.filter(plugin => plugin.type === 'prod')
|
return this.devPlugins.filter(plugin => plugin.type === 'prod')
|
||||||
|
@ -230,7 +230,13 @@ const actions = {
|
|||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
sourceFile: `${fileUrl}/${config.main}`,
|
sourceFile: `${fileUrl}/${config.main}`,
|
||||||
type: 'prod',
|
type: 'prod',
|
||||||
icon: payload.logo
|
icon: payload.logo,
|
||||||
|
subType: (() => {
|
||||||
|
if (config.main) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return 'template';
|
||||||
|
})()
|
||||||
};
|
};
|
||||||
commit('commonUpdate', {
|
commit('commonUpdate', {
|
||||||
devPlugins: [pluginConfig, ...state.devPlugins],
|
devPlugins: [pluginConfig, ...state.devPlugins],
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Title</title>
|
<title>Title</title>
|
||||||
</head>
|
</head>
|
||||||
<script crossorigin="anonymous" src="https://lib.baomitu.com/vue/2.6.12/vue.min.js"></script>
|
<script src="../vue.min.js"></script>
|
||||||
<script src="https://lib.baomitu.com/vue-router/3.5.1/vue-router.min.js"></script>
|
<script src="../vue-router.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -54,6 +54,50 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
border: none;
|
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>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
@ -61,5 +105,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script src="./doc.js" type="module"></script>
|
<script src="./doc.js" type="module"></script>
|
||||||
|
<script src="./list.js" type="module"></script>
|
||||||
<script src="./index.js" type="module"></script>
|
<script src="./index.js" type="module"></script>
|
||||||
</html>
|
</html>
|
@ -1,4 +1,6 @@
|
|||||||
import doc from './doc.js';
|
import doc from './doc.js';
|
||||||
|
import list from './list.js';
|
||||||
|
|
||||||
function getQueryVariable(variable) {
|
function getQueryVariable(variable) {
|
||||||
var query = window.location.search.substring(1);
|
var query = window.location.search.substring(1);
|
||||||
var vars = query.split("&");
|
var vars = query.split("&");
|
||||||
@ -11,6 +13,7 @@ function getQueryVariable(variable) {
|
|||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: '/doc', name: 'doc', component: doc },
|
{ path: '/doc', name: 'doc', component: doc },
|
||||||
|
{ path: '/list', name: 'list', component: list },
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
@ -22,7 +25,7 @@ new Vue({
|
|||||||
data: {
|
data: {
|
||||||
config: window.exports,
|
config: window.exports,
|
||||||
code: '',
|
code: '',
|
||||||
current: {}
|
current: {},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.code = getQueryVariable('code');
|
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 {
|
} else {
|
||||||
filePath = location.pathname.replace('file://', '');
|
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 currentWindow = remote.getCurrentWindow();
|
||||||
const winId = currentWindow.id;
|
const winId = currentWindow.id;
|
||||||
@ -281,8 +281,13 @@ window.utools = window.rubick = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
shellOpenExternal(url) {
|
||||||
|
shell.openExternal(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require(path.join(filePath, '../preload.js'));
|
const preloadPath = getQueryVariable('preloadPath') || './preload.js';
|
||||||
window.exports && ipcRenderer.sendToHost('templateConfig', {config: window.exports});
|
|
||||||
|
|
||||||
|
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