+
跳转新地址
@@ -113,7 +113,6 @@
});
const emits = defineEmits(['changeTab']);
const eventValue = ref(props.eventData.type);
- const movementValue = ref(props.eventData.movementList[0].movement);
const handleEventTypeChange = (value: string) => {
eventValue.value = value;
props.eventData.type = value;
@@ -132,15 +131,25 @@
};
const handleClose = (name: string) => {
const index = name.match(/动作(\S*)-/)[1];
- goDialog({
- message: '是否删除此动作?',
- onPositiveCallback: () => {
- movementData.value.splice(index - 1, 1);
- },
- });
+ if (props.eventData.movementList.length > 1) {
+ goDialog({
+ message: '是否删除此动作?',
+ onPositiveCallback: () => {
+ props.eventData.movementList.splice(index - 1, 1);
+ if (index > 1) {
+ const movement = props.eventData.movementList[index - 2].movement;
+ movementTab.value = '动作' + (index - 1) + '-' + getEventName(movement);
+ } else {
+ const movement = props.eventData.movementList[0].movement;
+ movementTab.value = '动作1' + '-' + getEventName(movement);
+ }
+ },
+ });
+ } else {
+ window['$message'].error('至少保留一个动作');
+ }
};
const handleMovementTypeChange = (value: string, index: number) => {
- movementValue.value = value;
props.eventData.movementList[index].movement = value;
movementTab.value = '动作' + (index + 1) + '-' + getEventName(value);
};
diff --git a/src/views/chart/ContentConfigurations/components/ChartEvent/index.vue b/src/views/chart/ContentConfigurations/components/ChartEvent/index.vue
index ffff705..881db6d 100644
--- a/src/views/chart/ContentConfigurations/components/ChartEvent/index.vue
+++ b/src/views/chart/ContentConfigurations/components/ChartEvent/index.vue
@@ -21,6 +21,5 @@
import { useTargetData } from '../hooks/useTargetData.hook';
const { targetData } = useTargetData();
- console.log(targetData);
const showModal = ref(false);
diff --git a/src/views/chart/hooks/useKeyboard.hook.ts b/src/views/chart/hooks/useKeyboard.hook.ts
index c8a7968..f42e792 100644
--- a/src/views/chart/hooks/useKeyboard.hook.ts
+++ b/src/views/chart/hooks/useKeyboard.hook.ts
@@ -1,16 +1,18 @@
-import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
-import { WinKeyboard, MacKeyboard, MenuEnum } from '@/enums/editPageEnum'
-import throttle from 'lodash/throttle'
-import debounce from 'lodash/debounce'
-import keymaster from 'keymaster'
-import { setKeyboardDressShow } from '@/utils'
+import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
+import { WinKeyboard, MacKeyboard, MenuEnum } from '@/enums/editPageEnum';
+import throttle from 'lodash/throttle';
+import debounce from 'lodash/debounce';
+import keymaster from 'keymaster';
+import { setKeyboardDressShow } from '@/utils';
+import { useSync } from './useSync.hook';
+const { dataSyncUpdate } = useSync();
// Keymaster可以支持识别以下组合键: ⇧,shift,option,⌥,alt,ctrl,control,command,和⌘
-const chartEditStore = useChartEditStore()
+const chartEditStore = useChartEditStore();
-const winCtrlMerge = (e: string) => `${WinKeyboard.CTRL}+${e}`
-const winShiftMerge = (e: string) => `${WinKeyboard.SHIFT}+${e}`
-const winAltMerge = (e: string) => `${WinKeyboard.ALT}+${e}`
+const winCtrlMerge = (e: string) => `${WinKeyboard.CTRL}+${e}`;
+const winShiftMerge = (e: string) => `${WinKeyboard.SHIFT}+${e}`;
+const winAltMerge = (e: string) => `${WinKeyboard.ALT}+${e}`;
export const winKeyboardValue = {
[MenuEnum.ARROW_UP]: winCtrlMerge('up'),
@@ -28,13 +30,14 @@ export const winKeyboardValue = {
[MenuEnum.LOCK]: winCtrlMerge('l'),
[MenuEnum.UNLOCK]: winCtrlMerge(winShiftMerge('l')),
[MenuEnum.HIDE]: winCtrlMerge('h'),
- [MenuEnum.SHOW]: winCtrlMerge(winShiftMerge('h'))
-}
+ [MenuEnum.SHOW]: winCtrlMerge(winShiftMerge('h')),
+ [MenuEnum.SAVE]: winCtrlMerge('s'),
+};
// 这个 Ctrl 后面还是换成了 ⌘
-const macCtrlMerge = (e: string) => `${MacKeyboard.CTRL}+${e}`
-const macShiftMerge = (e: string) => `${MacKeyboard.SHIFT}+${e}`
-const macAltMerge = (e: string) => `${MacKeyboard.ALT}+${e}`
+const macCtrlMerge = (e: string) => `${MacKeyboard.CTRL}+${e}`;
+const macShiftMerge = (e: string) => `${MacKeyboard.SHIFT}+${e}`;
+const macAltMerge = (e: string) => `${MacKeyboard.ALT}+${e}`;
// 没有测试 macOS 系统,因为我没有😤👻
export const macKeyboardValue = {
@@ -53,8 +56,9 @@ export const macKeyboardValue = {
[MenuEnum.LOCK]: macCtrlMerge('l'),
[MenuEnum.UNLOCK]: macCtrlMerge(macShiftMerge('l')),
[MenuEnum.HIDE]: macCtrlMerge('h'),
- [MenuEnum.SHOW]: macCtrlMerge(macShiftMerge('h'))
-}
+ [MenuEnum.SHOW]: macCtrlMerge(macShiftMerge('h')),
+ [MenuEnum.SAVE]: macCtrlMerge('s'),
+};
// Win 快捷键列表
const winKeyList: Array
= [
@@ -78,8 +82,10 @@ const winKeyList: Array = [
winKeyboardValue.unLock,
winKeyboardValue.hide,
- winKeyboardValue.show
-]
+ winKeyboardValue.show,
+
+ winKeyboardValue.save,
+];
// Mac 快捷键列表
const macKeyList: Array = [
@@ -103,129 +109,245 @@ const macKeyList: Array = [
macKeyboardValue.unLock,
macKeyboardValue.hide,
- macKeyboardValue.show
-]
+ macKeyboardValue.show,
+
+ macKeyboardValue.save,
+];
// 处理键盘记录
const keyRecordHandle = () => {
// 默认赋值
window.$KeyboardActive = {
ctrl: false,
- space: false
- }
+ space: false,
+ };
document.onkeydown = (e: KeyboardEvent) => {
- const { keyCode } = e
- if (keyCode == 32 && e.target == document.body) e.preventDefault()
+ const { keyCode } = e;
+ if (keyCode == 32 && e.target == document.body) e.preventDefault();
if ([17, 32].includes(keyCode) && window.$KeyboardActive) {
- setKeyboardDressShow(e.keyCode)
+ setKeyboardDressShow(e.keyCode);
switch (keyCode) {
- case 17: window.$KeyboardActive.ctrl = true; break
- case 32: window.$KeyboardActive.space = true; break
+ case 17:
+ window.$KeyboardActive.ctrl = true;
+ break;
+ case 32:
+ window.$KeyboardActive.space = true;
+ break;
}
}
- }
+ };
document.onkeyup = (e: KeyboardEvent) => {
- const { keyCode } = e
- if (keyCode == 32 && e.target == document.body) e.preventDefault()
+ const { keyCode } = e;
+ if (keyCode == 32 && e.target == document.body) e.preventDefault();
if ([17, 32].includes(keyCode) && window.$KeyboardActive) {
- setKeyboardDressShow()
+ setKeyboardDressShow();
switch (keyCode) {
- case 17: window.$KeyboardActive.ctrl = false; break
- case 32: window.$KeyboardActive.space = false; break
+ case 17:
+ window.$KeyboardActive.ctrl = false;
+ break;
+ case 32:
+ window.$KeyboardActive.space = false;
+ break;
}
}
- }
-}
+ };
+};
// 初始化监听事件
export const useAddKeyboard = () => {
- const throttleTime = 50
+ const throttleTime = 50;
const switchHandle = (keyboardValue: typeof winKeyboardValue, e: string) => {
switch (e) {
// ct+↑
case keyboardValue.up:
- keymaster(e, throttle(() => { chartEditStore.setMove(MenuEnum.ARROW_UP); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setMove(MenuEnum.ARROW_UP);
+ return false;
+ }, throttleTime),
+ );
break;
// ct+→
case keyboardValue.right:
- keymaster(e, throttle(() => { chartEditStore.setMove(MenuEnum.ARROW_RIGHT); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setMove(MenuEnum.ARROW_RIGHT);
+ return false;
+ }, throttleTime),
+ );
break;
// ct+↓
case keyboardValue.down:
- keymaster(e, throttle(() => { chartEditStore.setMove(MenuEnum.ARROW_DOWN); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setMove(MenuEnum.ARROW_DOWN);
+ return false;
+ }, throttleTime),
+ );
break;
// ct+←
case keyboardValue.left:
- keymaster(e, throttle(() => { chartEditStore.setMove(MenuEnum.ARROW_LEFT); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setMove(MenuEnum.ARROW_LEFT);
+ return false;
+ }, throttleTime),
+ );
break;
// 删除 delete
case keyboardValue.delete:
- keymaster(e, debounce(() => { chartEditStore.removeComponentList(); return false }, throttleTime))
+ keymaster(
+ e,
+ debounce(() => {
+ chartEditStore.removeComponentList();
+ return false;
+ }, throttleTime),
+ );
break;
// 复制 ct+v
case keyboardValue.copy:
- keymaster(e, debounce(() => { chartEditStore.setCopy(); return false }, throttleTime))
+ keymaster(
+ e,
+ debounce(() => {
+ chartEditStore.setCopy();
+ return false;
+ }, throttleTime),
+ );
break;
// 剪切 ct+x
case keyboardValue.cut:
- keymaster(e, debounce(() => { chartEditStore.setCut(); return false }, throttleTime))
+ keymaster(
+ e,
+ debounce(() => {
+ chartEditStore.setCut();
+ return false;
+ }, throttleTime),
+ );
break;
// 粘贴 ct+v
case keyboardValue.parse:
- keymaster(e, throttle(() => { chartEditStore.setParse(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setParse();
+ return false;
+ }, throttleTime),
+ );
break;
// 撤回 ct+z
case keyboardValue.back:
- keymaster(e, throttle(() => { chartEditStore.setBack(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setBack();
+ return false;
+ }, throttleTime),
+ );
break;
// 前进 ct+sh+z
case keyboardValue.forward:
- keymaster(e, throttle(() => { chartEditStore.setForward(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setForward();
+ return false;
+ }, throttleTime),
+ );
break;
-
+
// 创建分组 ct+g
case keyboardValue.group:
- keymaster(e, throttle(() => { chartEditStore.setGroup(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setGroup();
+ return false;
+ }, throttleTime),
+ );
break;
// 解除分组 ct+sh+g
case keyboardValue.unGroup:
- keymaster(e, throttle(() => { chartEditStore.setUnGroup(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setUnGroup();
+ return false;
+ }, throttleTime),
+ );
break;
// 锁定 ct+l
case keyboardValue.lock:
- keymaster(e, throttle(() => { chartEditStore.setLock(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setLock();
+ return false;
+ }, throttleTime),
+ );
break;
// 解除锁定 ct+sh+l
case keyboardValue.unLock:
- keymaster(e, throttle(() => { chartEditStore.setUnLock(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setUnLock();
+ return false;
+ }, throttleTime),
+ );
break;
// 隐藏 ct+h
case keyboardValue.hide:
- keymaster(e, throttle(() => { chartEditStore.setHide(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setHide();
+ return false;
+ }, throttleTime),
+ );
break;
// 解除隐藏 ct+sh+h
case keyboardValue.show:
- keymaster(e, throttle(() => { chartEditStore.setShow(); return false }, throttleTime))
+ keymaster(
+ e,
+ throttle(() => {
+ chartEditStore.setShow();
+ return false;
+ }, throttleTime),
+ );
+ break;
+ // 复制 ct+s
+ case keyboardValue.save:
+ keymaster(
+ e,
+ throttle(() => {
+ dataSyncUpdate();
+ return false;
+ }, throttleTime),
+ );
break;
}
- }
+ };
winKeyList.forEach((key: string) => {
- switchHandle(winKeyboardValue, key)
- })
+ switchHandle(winKeyboardValue, key);
+ });
macKeyList.forEach((key: string) => {
- switchHandle(macKeyboardValue, key)
- })
+ switchHandle(macKeyboardValue, key);
+ });
- keyRecordHandle()
-}
+ keyRecordHandle();
+};
// 卸载监听事件
export const useRemoveKeyboard = () => {
@@ -233,9 +355,9 @@ export const useRemoveKeyboard = () => {
document.onkeyup = () => {};
winKeyList.forEach((key: string) => {
- keymaster.unbind(key)
- })
+ keymaster.unbind(key);
+ });
macKeyList.forEach((key: string) => {
- keymaster.unbind(key)
- })
-}
\ No newline at end of file
+ keymaster.unbind(key);
+ });
+};
diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts
index 9ca6c8b..dc9cecb 100644
--- a/src/views/chart/hooks/useSync.hook.ts
+++ b/src/views/chart/hooks/useSync.hook.ts
@@ -303,6 +303,7 @@ export const useSync = () => {
// * 数据保存
const dataSyncUpdate = throttle(async (updateImg = true) => {
+ window['$message'].success('正在保存,请稍后...');
if (!fetchRouteParamsLocation()) return;
let projectId = chartEditStore.getProjectInfo[ProjectInfoEnum.PROJECT_ID];
if (projectId === null || projectId === '') {
@@ -369,7 +370,6 @@ export const useSync = () => {
// 失败状态
chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.FAILURE);
window['$message'].error('保存失败!');
-
}, 3000);
// * 定时处理
diff --git a/src/views/sys/login/Login.vue b/src/views/sys/login/Login.vue
index 4e2e2da..8bb060b 100644
--- a/src/views/sys/login/Login.vue
+++ b/src/views/sys/login/Login.vue
@@ -1,5 +1,5 @@
-