mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 05:16:00 +00:00
group commands
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
import { get } from 'svelte/store';
|
||||
import { commands } from '../stores';
|
||||
import { getCommands } from '../stores';
|
||||
import { GlobalCommand } from './registerCommand';
|
||||
|
||||
export default function runCommand(commandId: string) {
|
||||
const commandsValue = get(commands);
|
||||
const command: GlobalCommand = commandsValue[commandId];
|
||||
if (command.enabled) command.onClick();
|
||||
export default function runCommand(id) {
|
||||
const commandsValue = getCommands();
|
||||
const command = commandsValue[id];
|
||||
if (command) {
|
||||
if (!command.enabled) return;
|
||||
if (command.isGroupCommand) {
|
||||
runGroupCommand(command.group);
|
||||
} else {
|
||||
if (command.onClick) {
|
||||
command.onClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window['dbgate_runCommand'] = runCommand;
|
||||
|
||||
export function runGroupCommand(group) {
|
||||
const commandsValue = getCommands();
|
||||
const values = Object.values(commandsValue) as GlobalCommand[];
|
||||
const real = values.find(x => x.group == group && !x.isGroupCommand && x.enabled);
|
||||
if (real && real.onClick) real.onClick();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user