mirror of
https://github.com/motajs/template.git
synced 2026-11-11 13:34:31 +08:00
chore: Hotkey 系统遗留提交
This commit is contained in:
1 parent
21dea3adf0
commit
4115753f1f
2 files changed
+2
-27
No files matched your search
@@ -8,7 +8,6 @@ import {
|
||||
} from '@motajs/animate';
|
||||
import { logger } from '@motajs/common';
|
||||
import { IRenderItem, IRenderTreeRoot } from '@motajs/render';
|
||||
import { Hotkey, gameKey } from '@motajs/system';
|
||||
import {
|
||||
ComponentInternalInstance,
|
||||
getCurrentInstance,
|
||||
@@ -64,30 +63,6 @@ export function onOrientationChange(hook: OrientationHook) {
|
||||
});
|
||||
}
|
||||
|
||||
type KeyUsing = [Hotkey, symbol];
|
||||
|
||||
/**
|
||||
* 在组件中定义按键操作
|
||||
* @param noScope 是否不创建新作用域
|
||||
* @param scope 指定作用域,如果 `noScope` 为 `true`,则此项无效
|
||||
*/
|
||||
export function useKey(noScope: boolean = false, scope?: symbol): KeyUsing {
|
||||
if (noScope) {
|
||||
return [gameKey, gameKey.scope];
|
||||
} else {
|
||||
const sym = scope ?? Symbol();
|
||||
if (sym === gameKey.scope) {
|
||||
return [gameKey, gameKey.scope];
|
||||
} else {
|
||||
gameKey.use(sym);
|
||||
onUnmounted(() => {
|
||||
gameKey.dispose();
|
||||
});
|
||||
return [gameKey, sym];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ITransitionedController<T> {
|
||||
readonly ref: Ref<T>;
|
||||
readonly value: T;
|
||||
|
||||
Reference in new issue
Block a user