Skip to content

Commit

Permalink
🐛 fix #289,#291,#290
Browse files Browse the repository at this point in the history
  • Loading branch information
muwoo committed Nov 10, 2023
1 parent dfb8446 commit f671b83
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 87 deletions.
Binary file added feature/src/assets/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions feature/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ import localConfig from './confOp';

const config: any = localConfig.getConfig();

// 暗夜模式
if (config.perf.common.darkMode) {
document.body.classList.add('dark');
window.rubick.theme = 'dark';
}

ConfigProvider.config({
theme: config.perf.custom || {},
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "4.1.4",
"version": "4.1.5",
"author": "muwoo <2424880409@qq.com>",
"private": true,
"scripts": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"fix-path": "^3.0.0",
"get-mac-apps": "^1.0.2",
"got": "^11.8.3",
"lodash.throttle": "^4.1.1",
"lodash.debounce": "^4.0.8",
"memorystream": "^0.3.1",
"node-key-sender": "^1.0.11",
"npm": "6.14.7",
Expand Down
Binary file added public/icons/delete@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/pin@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/unpin@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ window.rubick = {
showOpenDialog(options) {
return ipcSendSync('showOpenDialog', options);
},
showSaveDialog(options) {
return ipcSendSync('showSaveDialog', options);
},

setExpendHeight(height) {
ipcSendSync('setExpendHeight', height);
},
Expand Down
3 changes: 2 additions & 1 deletion src/common/constans/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import path from 'path';
const appPath = app.getPath('userData');

const PLUGIN_INSTALL_DIR = path.join(appPath, './rubick-plugins-new');
const PLUGIN_HISTORY = 'rubick-local-start-app';

export { PLUGIN_INSTALL_DIR };
export { PLUGIN_INSTALL_DIR, PLUGIN_HISTORY };
3 changes: 2 additions & 1 deletion src/common/utils/dragWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const useDrag = () => {
let draggable = true;

const onMouseDown = (e) => {
// if (commonConst.macOS()) return;
// 右击不移动
if (e.button === 2) return;
draggable = true;
mouseX = e.clientX;
mouseY = e.clientY;
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/getWindowHeight.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const WINDOW_MAX_HEIGHT = 600;
const WINDOW_MAX_HEIGHT = 620;
const WINDOW_MIN_HEIGHT = 60;
const PRE_ITEM_HEIGHT = 60;
const PRE_ITEM_HEIGHT = 70;
const HISTORY_HEIGHT = 70;

export default (searchList: Array<any>, historyList): number => {

Check warning on line 6 in src/common/utils/getWindowHeight.ts

View workflow job for this annotation

GitHub Actions / build and release electron app (windows-2019)

Unexpected any. Specify a different type

Check warning on line 6 in src/common/utils/getWindowHeight.ts

View workflow job for this annotation

GitHub Actions / build and release electron app (windows-2019)

Argument 'historyList' should be typed

Check warning on line 6 in src/common/utils/getWindowHeight.ts

View workflow job for this annotation

GitHub Actions / build and release electron app (ubuntu-latest)

Unexpected any. Specify a different type

Check warning on line 6 in src/common/utils/getWindowHeight.ts

View workflow job for this annotation

GitHub Actions / build and release electron app (ubuntu-latest)

Argument 'historyList' should be typed
Expand Down
5 changes: 4 additions & 1 deletion src/main/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class API extends DBInstance {
public hideMainWindow(arg, window) {
window.hide();
}

public showMainWindow(arg, window) {
window.show();
}
Expand All @@ -148,6 +147,10 @@ class API extends DBInstance {
return dialog.showOpenDialogSync(window, data);
}

public showSaveDialog({ data }, window) {
return dialog.showSaveDialogSync(window, data);
}

public setExpendHeight({ data: height }, window: BrowserWindow, e) {
const originWindow = this.getCurrentWindow(window, e);
if (!originWindow) return;
Expand Down
14 changes: 6 additions & 8 deletions src/main/common/registerHotKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
// 设置开机启动
const setAutoLogin = async () => {
const config = await localConfig.getConfig();
app.setLoginItemSettings({
openAtLogin: config.perf.common.start,
openAsHidden: true,
});
if (app.getLoginItemSettings().openAtLogin !== config.perf.common.start) {
app.setLoginItemSettings({
openAtLogin: config.perf.common.start,
openAsHidden: true,
});
}
};

const setTheme = async () => {
Expand Down Expand Up @@ -86,10 +88,6 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
});
});

// globalShortcut.register(config.perf.shortCut.separate, () => {
//
// });

globalShortcut.register(config.perf.shortCut.quit, () => {
// mainWindow.webContents.send('init-rubick');
// mainWindow.show();
Expand Down
70 changes: 53 additions & 17 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,22 @@
:currentSelect="currentSelect"
:options="options"
:clipboardFile="clipboardFile || []"
@setPluginHistory="setPluginHistory"
@choosePlugin="choosePlugin"
/>
</div>
</template>

<script setup lang="ts">
import { watch, ref, nextTick, toRaw } from 'vue';
import { ipcRenderer } from 'electron';
import { watch, ref, toRaw } from 'vue';
import Result from './components/result.vue';
import Search from './components/search.vue';
import getWindowHeight from '../common/utils/getWindowHeight';
import createPluginManager from './plugins-manager';
import useDrag from '../common/utils/dragWindow';
import { getGlobal } from '@electron/remote';
import { PLUGIN_HISTORY } from '@/common/constans/renderer';
import { message } from 'ant-design-vue';
const { onMouseDown } = useDrag();
const remote = window.require('@electron/remote');
Expand All @@ -60,6 +64,8 @@ const {
clearClipboardFile,
readClipboardContent,
pluginHistory,
setPluginHistory,
changePluginHistory,
} = createPluginManager();
initPlugins();
Expand All @@ -76,19 +82,22 @@ getPluginInfo({
remote.getGlobal('LOCAL_PLUGINS').addPlugin(res);
});
watch([options, pluginHistory, currentPlugin], () => {
currentSelect.value = 0;
if (currentPlugin.value.name) return;
nextTick(() => {
ipcRenderer.sendSync('msg-trigger', {
type: 'setExpendHeight',
data: getWindowHeight(
watch(
[options, pluginHistory, currentPlugin],
() => {
currentSelect.value = 0;
if (currentPlugin.value.name) return;
window.rubick.setExpendHeight(
getWindowHeight(
options.value,
(pluginLoading.value) ? [] : pluginHistory.value
),
});
});
});
pluginLoading.value ? [] : pluginHistory.value
)
);
},
{
immediate: true,
}
);
const changeIndex = (index) => {
if (!options.value.length) {
Expand Down Expand Up @@ -125,13 +134,40 @@ const openMenu = (ext) => {
window.rubick.openMenu = openMenu;
const choosePlugin = () => {
const choosePlugin = (plugin) => {
if (options.value.length) {
const currentChoose = options.value[currentSelect.value];
currentChoose.click();
} else {
const currentChoose = pluginHistory.value[currentSelect.value];
currentChoose.click();
const localPlugins = getGlobal('LOCAL_PLUGINS').getLocalPlugins();
const currentChoose = plugin || pluginHistory.value[currentSelect.value];
let hasRemove = true;
localPlugins.find((plugin) => {
if (plugin.name === currentChoose.originName) {
hasRemove = false;
return true;
}
return false;
});
if (hasRemove) {
const result = window.rubick.db.get(PLUGIN_HISTORY) || {};
const history = result.data.filter(item => item.originName !== currentChoose.originName);
setPluginHistory(history);
return message.warning('插件已被卸载!');
}
changePluginHistory(currentChoose);
window.rubick.openPlugin(
JSON.parse(
JSON.stringify({
...currentChoose,
ext: {
code: currentChoose.feature.code,
type: currentChoose.cmd.type || 'text',
payload: null,
},
})
)
);
}
};
Expand Down
Loading

0 comments on commit f671b83

Please sign in to comment.