feat: Nyan Cat Widget
This commit is contained in:
parent
5d9b9eeaad
commit
4634805923
@ -1252,6 +1252,7 @@ _widgets:
|
|||||||
serverMetric: "サーバーメトリクス"
|
serverMetric: "サーバーメトリクス"
|
||||||
aiscript: "AiScriptコンソール"
|
aiscript: "AiScriptコンソール"
|
||||||
aichan: "藍"
|
aichan: "藍"
|
||||||
|
nyancat: "Nyan Cat"
|
||||||
|
|
||||||
_cw:
|
_cw:
|
||||||
hide: "隠す"
|
hide: "隠す"
|
||||||
|
@ -20,6 +20,7 @@ export default function(app: App) {
|
|||||||
app.component('MkwButton', defineAsyncComponent(() => import('./button.vue')));
|
app.component('MkwButton', defineAsyncComponent(() => import('./button.vue')));
|
||||||
app.component('MkwAiscript', defineAsyncComponent(() => import('./aiscript.vue')));
|
app.component('MkwAiscript', defineAsyncComponent(() => import('./aiscript.vue')));
|
||||||
app.component('MkwAichan', defineAsyncComponent(() => import('./aichan.vue')));
|
app.component('MkwAichan', defineAsyncComponent(() => import('./aichan.vue')));
|
||||||
|
app.component('MkwNyancat', defineAsyncComponent(() => import('./nyancat.vue')));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const widgets = [
|
export const widgets = [
|
||||||
@ -42,4 +43,5 @@ export const widgets = [
|
|||||||
'button',
|
'button',
|
||||||
'aiscript',
|
'aiscript',
|
||||||
'aichan',
|
'aichan',
|
||||||
|
'nyancat',
|
||||||
];
|
];
|
||||||
|
73
packages/client/src/widgets/nyancat.vue
Normal file
73
packages/client/src/widgets/nyancat.vue
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<MkContainer :naked="widgetProps.transparent" :show-header="false">
|
||||||
|
<iframe ref="live2d" class="kjhasfa" src="https://raw.githubusercontent.com/Gowee/nyancat-svg/main/nyancat.svg" @click="touched"></iframe>
|
||||||
|
</MkContainer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
||||||
|
import { GetFormResultType } from '@/scripts/form';
|
||||||
|
import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
|
||||||
|
|
||||||
|
const name = 'ai';
|
||||||
|
|
||||||
|
const widgetPropsDef = {
|
||||||
|
transparent: {
|
||||||
|
type: 'boolean' as const,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
|
||||||
|
|
||||||
|
// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
|
||||||
|
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
||||||
|
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
||||||
|
const props = defineProps<{ widget?: Widget<WidgetProps>; }>();
|
||||||
|
const emit = defineEmits<{ (e: 'updateProps', props: WidgetProps); }>();
|
||||||
|
|
||||||
|
const { widgetProps, configure } = useWidgetPropsManager(name,
|
||||||
|
widgetPropsDef,
|
||||||
|
props,
|
||||||
|
emit,
|
||||||
|
);
|
||||||
|
|
||||||
|
const live2d = ref<HTMLIFrameElement>();
|
||||||
|
|
||||||
|
const touched = () => {
|
||||||
|
//if (this.live2d) this.live2d.changeExpression('gurugurume');
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const onMousemove = (ev: MouseEvent) => {
|
||||||
|
const iframeRect = live2d.value.getBoundingClientRect();
|
||||||
|
live2d.value.contentWindow.postMessage({
|
||||||
|
type: 'moveCursor',
|
||||||
|
body: {
|
||||||
|
x: ev.clientX - iframeRect.left,
|
||||||
|
y: ev.clientY - iframeRect.top,
|
||||||
|
}
|
||||||
|
}, '*');
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('mousemove', onMousemove, { passive: true });
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('mousemove', onMousemove);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
defineExpose<WidgetComponentExpose>({
|
||||||
|
name,
|
||||||
|
configure,
|
||||||
|
id: props.widget ? props.widget.id : null,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.dedjhjmo {
|
||||||
|
width: 100%;
|
||||||
|
height: 350px;
|
||||||
|
border: none;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
x
Reference in New Issue
Block a user