This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
## 喵语翻译
允许用户将自然语言转换为加密后的喵语
在任意聊天款的右侧添加喵语翻译
![](./docs/send.png)
在此输入的任意内容都会被转换为加密后的喵语言,只有安装了相同插件的用户才能翻译
![](./docs/output.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -0,0 +1,12 @@
{
"label": "Miaolang",
"label.zh-CN": "喵语言",
"name": "com.msgbyte.miaolang",
"url": "/plugins/com.msgbyte.miaolang/index.js",
"version": "0.0.0",
"author": "msgbyte",
"description": "It is allowed to send meow, and the two parties encrypt the conversation after installing the plugin. People who have not installed the plugin will see 'meow'",
"description.zh-CN": "允许发送喵语,安装插件后的双方加密对话,未安装插件的人看到的是 '喵'",
"documentUrl": "/plugins/com.msgbyte.miaolang/README.md",
"requireRestart": false
}

View File

@@ -0,0 +1,9 @@
{
"name": "@plugins/com.msgbyte.miaolang",
"main": "src/index.ts",
"version": "0.0.0",
"private": true,
"dependencies": {
"miao-lang": "^1.0.5"
}
}

View File

@@ -0,0 +1,48 @@
import React from 'react';
import { useCallback } from 'react';
import { useState } from 'react';
import {
ModalWrapper,
useModalContext,
ChatInputActionContextProps,
} from '@capital/common';
import { Button, TextArea } from '@capital/component';
import { encode } from './miaotrans';
import { Translate } from './translate';
interface SendMiaoModalProps {
actions: ChatInputActionContextProps;
}
export const SendMiaoModal: React.FC<SendMiaoModalProps> = React.memo(
(props) => {
const [text, setText] = useState('');
const modalContext = useModalContext();
const handleSendMiao = useCallback(() => {
const miao = encode(text);
props.actions.sendMsg(miao);
modalContext?.closeModal();
}, [text, modalContext, props.actions]);
return (
<ModalWrapper title={Translate.title}>
<TextArea
placeholder={Translate.inputHuman}
value={text}
onChange={(e) => setText(e.target.value)}
/>
<Button
style={{ marginTop: 8 }}
type="primary"
block={true}
onClick={handleSendMiao}
>
{Translate.send}
</Button>
</ModalWrapper>
);
}
);
SendMiaoModal.displayName = 'SendMiaoModal';

View File

@@ -0,0 +1,19 @@
import { regChatInputAction, openModal, Loadable } from '@capital/common';
import { createElement } from 'react';
import { Translate } from './translate';
const SendMiaoModal = Loadable(() =>
import('./SendMiaoModal').then((module) => ({
default: module.SendMiaoModal,
}))
);
// Just for reduce entry file size
import('./reg');
regChatInputAction({
label: Translate.title,
onClick: (actions) => {
openModal(createElement(SendMiaoModal, { actions }));
},
});

View File

@@ -0,0 +1,18 @@
import Miao from 'miao-lang';
import { Translate } from './translate';
import { getLanguage } from '@capital/common';
export function encode(human: string): string {
return Miao.encode(human, {
calls: Translate.calls,
halfwidthSymbol: getLanguage() !== 'zh-CN',
});
}
export function decode(miao: string): string {
return Miao.decode(miao);
}
export function isMiao(input: string): boolean {
return Miao.isMiao(input);
}

View File

@@ -0,0 +1,20 @@
import { decode, encode, isMiao } from './miaotrans';
import { regMessageInterpreter } from '@capital/common';
import { Translate } from './translate';
const miao = encode('喵语翻译已加载');
const human = decode(miao);
console.log(`${miao}\n${human}`);
regMessageInterpreter({
name: Translate.miaoTrans,
explainMessage(message: string) {
// 喵语 -> 人话
if (!isMiao(message)) {
return null;
}
return decode(message);
},
});

View File

@@ -0,0 +1,9 @@
import { localTrans } from '@capital/common';
export const Translate = {
miaoTrans: localTrans({ 'zh-CN': '喵语翻译', 'en-US': 'Meow Translate' }),
title: localTrans({ 'zh-CN': '喵言喵语', 'en-US': 'Meow meow' }),
send: localTrans({ 'zh-CN': '发送喵语', 'en-US': 'Send meow' }),
inputHuman: localTrans({ 'zh-CN': '输入人话', 'en-US': 'Input Human' }),
calls: localTrans({ 'zh-CN': '喵', 'en-US': 'Meow~' }),
};

View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"paths": {
"@capital/*": ["../../src/plugin/*"],
}
}
}