支持本地启动,修改mac 下获取 APP icon 的方式

This commit is contained in:
muwoo
2023-09-15 16:17:52 +08:00
parent 61b4e37fe0
commit c21c08c370
24 changed files with 493 additions and 124 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "rubick-system-feature",
"pluginName": "rubick 系统菜单",
"description": "rubick 系统菜单",
"pluginName": "系统菜单",
"description": "系统菜单",
"main": "index.html",
"logo": "https://pic1.zhimg.com/80/v2-c09780808301668a82e6646cb42f0806_720w.png",
"version": "0.0.0",
@@ -10,19 +10,19 @@
"features": [
{
"code": "market",
"explain": "rubick 插件市场",
"explain": "插件市场",
"cmds":[
"插件市场"
]
},{
"code": "installed",
"explain": "rubick 已安装插件",
"explain": "已安装插件",
"cmds":[
"已安装插件"
]
},{
"code": "settings",
"explain": "rubick 偏好设置",
"explain": "偏好设置",
"cmds":[
"偏好设置"
]

View File

@@ -1,4 +1,21 @@
const remote = require('@electron/remote');
const { ipcRenderer } = require('electron');
const ipcSendSync = (type, data) => {
const returnValue = ipcRenderer.sendSync('msg-trigger', {
type,
data,
});
if (returnValue instanceof Error) throw returnValue;
return returnValue;
};
const ipcSend = (type, data) => {
ipcRenderer.send('msg-trigger', {
type,
data,
});
};
window.market = {
getLocalPlugins() {
@@ -13,4 +30,10 @@ window.market = {
refreshPlugin(plugin) {
return remote.getGlobal('LOCAL_PLUGINS').refreshPlugin(plugin);
},
addLocalStartPlugin(plugin) {
ipcSend('addLocalStartPlugin', { plugin });
},
removeLocalStartPlugin(plugin) {
ipcSend('removeLocalStartPlugin', { plugin });
},
};

View File

@@ -96,6 +96,9 @@ export default {
accessToken: 'access token',
placeholder: 'required for private network gitlab warehouse',
},
localstart: {
title: 'Local Start',
},
},
dev: {
title: 'Developer',

View File

@@ -94,6 +94,9 @@ export default {
accessToken: 'access token',
placeholder: '内网gitlab仓库必填',
},
localstart: {
title: '本地启动',
},
},
dev: {
title: '开发者',

View File

@@ -14,6 +14,12 @@
</template>
{{ $t('feature.settings.basic.title') }}
</a-menu-item>
<a-menu-item key="localstart">
<template #icon>
<FolderOpenOutlined />
</template>
{{ $t('feature.settings.localstart.title') }}
</a-menu-item>
<a-menu-item key="global">
<template #icon>
<LaptopOutlined />
@@ -220,6 +226,7 @@
</div>
<SuperPanel v-if="currentSelect[0] === 'superpanel'" />
<Localhost v-if="currentSelect[0] === 'localhost'" />
<LocalStart v-if="currentSelect[0] === 'localstart'" />
</div>
</div>
</template>
@@ -232,6 +239,7 @@ import {
MinusCircleOutlined,
PlusCircleOutlined,
UserOutlined,
FolderOpenOutlined,
} from '@ant-design/icons-vue';
import debounce from 'lodash.debounce';
import { ref, reactive, watch, toRefs, computed } from 'vue';
@@ -239,6 +247,7 @@ import keycodes from './keycode';
import Localhost from './localhost.vue';
import SuperPanel from './super-panel.vue';
import UserInfo from './user-info';
import LocalStart from './local-start';
import { useI18n } from 'vue-i18n';
import localConfig from '@/confOp';

View File

@@ -0,0 +1,71 @@
<template>
<div class="file-container" @drop.prevent="dropFile" @dragenter="checkDrop" @dragover="checkDrop">
<a-alert message="可拖放文件夹到这里加入启动" type="info" show-icon />
<a-list item-layout="horizontal" :data-source="localStartList">
<template #renderItem="{ item }">
<a-list-item>
<template #actions>
<a key="list-loadmore-edit" @click="() => remove(item)">移除</a>
</template>
<a-list-item-meta :description="item.desc">
<template #title>
<div>{{item.name}}</div>
</template>
<template #avatar>
<a-avatar shape="square" :src="item.icon" />
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</div>
</template>
<script setup>
import { ref } from 'vue';
const dbId = 'rubick-local-start-app';
const localStartList = ref(window.rubick.dbStorage.getItem(dbId) || []);
const dropFile = (e) => {
const files = Array.from(e.dataTransfer.files).map((file) => {
const plugin = {
icon: window.rubick.getFileIcon(file.path),
value: 'plugin',
desc: file.path,
pluginType: 'app',
name: file.name,
action: `open ${file.path.replace(/ /g, '\\ ')}`,
keyWords: [file.name],
names: [file.name],
};
window.market.addLocalStartPlugin(plugin);
return plugin;
});
localStartList.value = [
...localStartList.value,
...files,
];
window.rubick.dbStorage.setItem(dbId, JSON.parse(JSON.stringify(localStartList.value)));
};
const remove = (item) => {
localStartList.value = localStartList.value.filter(app => app.desc !== item.desc);
window.rubick.dbStorage.setItem(dbId, JSON.parse(JSON.stringify(localStartList.value)));
window.market.removeLocalStartPlugin(JSON.parse(JSON.stringify(item)));
};
const checkDrop = (e) => {
e.preventDefault();
};
</script>
<style lang="less">
.file-container {
box-sizing: border-box;
width: 100%;
overflow-x: hidden;
background: var(--color-body-bg);
height: calc(~'100vh - 106px');
}
</style>