优化
This commit is contained in:
11
client/web/plugins/com.msgbyte.biggerfont/manifest.json
Normal file
11
client/web/plugins/com.msgbyte.biggerfont/manifest.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"label": "Bigger Font Size",
|
||||
"label.zh-CN": "字号放大",
|
||||
"name": "com.msgbyte.biggerfont",
|
||||
"url": "/plugins/com.msgbyte.biggerfont/index.js",
|
||||
"version": "0.0.0",
|
||||
"author": "moonrailgun",
|
||||
"description": "Add the feature of enlarging the font size to Tailchat, which is convenient for different user",
|
||||
"description.zh-CN": "为Tailchat增加放大字号的功能,方便不同用户群体",
|
||||
"requireRestart": true
|
||||
}
|
||||
19
client/web/plugins/com.msgbyte.biggerfont/package.json
Normal file
19
client/web/plugins/com.msgbyte.biggerfont/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@plugins/com.msgbyte.biggerfont",
|
||||
"main": "src/index.tsx",
|
||||
"version": "0.0.0",
|
||||
"description": "为Tailchat增加放大字号的功能,方便不同用户群体",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"sync:declaration": "tailchat declaration github"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.191",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"react": "18.2.0",
|
||||
"styled-components": "^5.3.6"
|
||||
}
|
||||
}
|
||||
3
client/web/plugins/com.msgbyte.biggerfont/src/const.ts
Normal file
3
client/web/plugins/com.msgbyte.biggerfont/src/const.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const PLUGIN_ID = 'com.msgbyte.biggerfont';
|
||||
|
||||
export const PLUGIN_CONFIG = `${PLUGIN_ID}.config`;
|
||||
49
client/web/plugins/com.msgbyte.biggerfont/src/index.tsx
Normal file
49
client/web/plugins/com.msgbyte.biggerfont/src/index.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
regPluginSettings,
|
||||
getCachedUserSettings,
|
||||
sharedEvent,
|
||||
} from '@capital/common';
|
||||
import { PLUGIN_CONFIG, PLUGIN_ID } from './const';
|
||||
import { Translate } from './translate';
|
||||
import _get from 'lodash/get';
|
||||
|
||||
console.log(`Plugin ${PLUGIN_ID} is loaded`);
|
||||
|
||||
regPluginSettings({
|
||||
name: PLUGIN_CONFIG,
|
||||
label: Translate.name,
|
||||
position: 'system',
|
||||
type: 'select',
|
||||
defaultValue: '',
|
||||
options: [
|
||||
{ label: Translate.default, value: '' },
|
||||
{ label: Translate.md, value: 'md' },
|
||||
{ label: Translate.lg, value: 'lg' },
|
||||
{ label: Translate.xl, value: 'xl' },
|
||||
],
|
||||
});
|
||||
|
||||
getCachedUserSettings().then((settings) => {
|
||||
updateFontsize(settings);
|
||||
});
|
||||
|
||||
sharedEvent.on('userSettingsUpdate', (settings) => {
|
||||
updateFontsize(settings);
|
||||
});
|
||||
|
||||
function updateFontsize(settings: any) {
|
||||
const fontSize = _get(settings, PLUGIN_CONFIG);
|
||||
|
||||
if (typeof settings === 'object' && typeof fontSize === 'string') {
|
||||
if (fontSize === '') {
|
||||
// 清除字号设置
|
||||
document.documentElement.style.fontSize = '';
|
||||
} else if (fontSize === 'md') {
|
||||
document.documentElement.style.fontSize = '18px';
|
||||
} else if (fontSize === 'lg') {
|
||||
document.documentElement.style.fontSize = '20px';
|
||||
} else if (fontSize === 'xl') {
|
||||
document.documentElement.style.fontSize = '22px';
|
||||
}
|
||||
}
|
||||
}
|
||||
18
client/web/plugins/com.msgbyte.biggerfont/src/translate.ts
Normal file
18
client/web/plugins/com.msgbyte.biggerfont/src/translate.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { localTrans } from '@capital/common';
|
||||
|
||||
export const Translate = {
|
||||
name: localTrans({
|
||||
'zh-CN': '放大字号',
|
||||
'en-US': 'Increase font size',
|
||||
}),
|
||||
default: localTrans({ 'zh-CN': '默认', 'en-US': 'Default' }),
|
||||
md: localTrans({ 'zh-CN': '中号', 'en-US': 'Middle' }),
|
||||
lg: localTrans({
|
||||
'zh-CN': '大号',
|
||||
'en-US': 'Large',
|
||||
}),
|
||||
xl: localTrans({
|
||||
'zh-CN': '特大号',
|
||||
'en-US': 'Extra Large',
|
||||
}),
|
||||
};
|
||||
7
client/web/plugins/com.msgbyte.biggerfont/tsconfig.json
Normal file
7
client/web/plugins/com.msgbyte.biggerfont/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react",
|
||||
"importsNotUsedAsValues": "error"
|
||||
}
|
||||
}
|
||||
2
client/web/plugins/com.msgbyte.biggerfont/types/tailchat.d.ts
vendored
Normal file
2
client/web/plugins/com.msgbyte.biggerfont/types/tailchat.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare module '@capital/common';
|
||||
declare module '@capital/component';
|
||||
Reference in New Issue
Block a user