支持本地启动,修改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

@@ -21,12 +21,35 @@ const createPluginManager = (): any => {
localPlugins: [],
currentPlugin: {},
pluginLoading: false,
pluginHistory: [],
});
const appList = ref([]);
const appList: any = ref([]);
const initPlugins = async () => {
appList.value = await appSearch(nativeImage);
initLocalStartPlugin();
};
const initLocalStartPlugin = () => {
const result = ipcRenderer.sendSync('msg-trigger', {
type: 'dbGet',
data: {
id: 'rubick-local-start-app',
},
});
if (result && result.value) {
appList.value = [...appList.value, ...result.value];
}
};
window.removeLocalStartPlugin = ({ plugin }) => {
appList.value = appList.value.filter((app) => app.desc !== plugin.desc);
};
window.addLocalStartPlugin = ({ plugin }) => {
window.removeLocalStartPlugin({ plugin });
appList.value.push(plugin);
};
const loadPlugin = async (plugin) => {
@@ -43,7 +66,7 @@ const createPluginManager = (): any => {
state.pluginLoading = false;
};
const openPlugin = async (plugin) => {
const openPlugin = async (plugin, option) => {
if (plugin.pluginType === 'ui' || plugin.pluginType === 'system') {
if (state.currentPlugin && state.currentPlugin.name === plugin.name) {
return;
@@ -66,6 +89,23 @@ const createPluginManager = (): any => {
if (plugin.pluginType === 'app') {
execSync(plugin.action);
}
window.initRubick();
changePluginHistory({
...plugin,
...option,
});
};
const changePluginHistory = (plugin) => {
if (state.pluginHistory.length >= 8) {
state.pluginHistory.pop();
}
state.pluginHistory.forEach((p, index) => {
if (p.name === plugin.name) {
state.pluginHistory.splice(index, 1);
}
});
state.pluginHistory.unshift(plugin);
};
const { searchValue, onSearch, setSearchValue, placeholder } =