koishi-plugin-onebot-info-image 0.2.0-alpha.9 → 0.3.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/dist/style.css +1 -0
- package/docs/napcat_al_flat.png +0 -0
- package/docs/napcat_aui_flat.png +0 -0
- package/lib/data_server.d.ts +37 -0
- package/lib/index.d.ts +9 -3
- package/lib/index.js +1071 -47
- package/lib/renderUserInfo.d.ts +4 -1
- package/lib/type.d.ts +4 -0
- package/package.json +9 -2
- package/readme.md +23 -7
- package/lib/renderAdminList.d.ts +0 -3
- package/lib/utils.d.ts +0 -27
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineComponent as H,inject as N,ref as c,computed as h,resolveComponent as y,createElementBlock as k,openBlock as u,Fragment as O,createCommentVNode as s,createBlock as S,createElementVNode as t,toDisplayString as w,withCtx as m,createVNode as T,createTextVNode as V,withDirectives as _,vModelSelect as x}from"vue";import{store as U,send as v}from"@koishijs/client";const E={key:0,class:"oii-loading-wrapper"},K={class:"oii-comment"},W={class:"oii-comment"},j={key:3,class:"oii-bot-info-card oii-fade-in"},z={class:"oii-card-header"},I={class:"oii-controls"},q={class:"oii-select-wrapper"},A={class:"oii-select-wrapper"},G={class:"oii-select-wrapper"},J={class:"oii-select-icon"},L={class:"oii-card-content"},P=["srcdoc"],Q=H({__name:"settings",setup(a){const f=N("manager.settings.local"),i=c({status:"loading",msg:"正在加载..."}),n=c("sourceHanSerif"),l=c("sourceHanSerif"),r=c(true),p=h(()=>{if(f.value.name!=="koishi-plugin-onebot-info-image")return;const o=U["onebot-info-image"];return o?(i.value=o,o.currentTemplate&&(n.value=o.currentTemplate),o.currentFont&&(l.value=o.currentFont),o.currentDarkMode!==void 0&&(r.value=o.currentDarkMode),o.status):"loading"}),D=h(()=>{let o=i.value.htmlContent||"";return o=o.replace(/<div class="timestamp-watermark">.*?<\/div>/g,""),o=o.replace(/<div class="timestamp">.*?<\/div>/g,""),o=o.replace(/width:\s*999px/g,"width: 100%"),o=o.replace(/height:\s*999px/g,"height: auto; min-height: 500px"),o=o.replace(/width:\s*920px/g,"width: 100%"),o=o.replace(/height:\s*920px/g,"height: auto"),o}),g=()=>{v("onebot-info-image/refresh")},F=()=>{v("onebot-info-image/setTemplate",n.value)},M=()=>{v("onebot-info-image/setFont",l.value)},B=()=>{v("onebot-info-image/setDarkMode",r.value)};return(o,e)=>{const C=y("k-button"),b=y("k-comment");return u(),k(O,null,[p.value==="loading"?(u(),k("div",E,[e[3]||(e[3]=t("div",{class:"oii-spinner"},null,-1)),t("p",null,w(i.value.msg),1)])):s("v-if",true),p.value==="no_bot"?(u(),S(b,{key:1,type:"warning"},{default:m(()=>[t("div",K,[e[5]||(e[5]=t("p",null,"未找到 OneBot 平台的机器人",-1)),e[6]||(e[6]=t("p",{style:{"font-size":"12px",color:"#888"}},"请确保已连接 OneBot 协议的机器人",-1)),T(C,{onClick:g},{default:m(()=>e[4]||(e[4]=[V("刷新",-1)])),_:1,__:[4]})])]),_:1})):s("v-if",true),p.value==="error"?(u(),S(b,{key:2,type:"error"},{default:m(()=>[t("div",W,[t("p",null,w(i.value.msg),1),T(C,{onClick:g},{default:m(()=>e[7]||(e[7]=[V("重试",-1)])),_:1,__:[7]})])]),_:1})):s("v-if",true),p.value==="loaded"?(u(),k("div",j,[t("div",z,[t("div",{class:"oii-header-left"},[e[9]||(e[9]=t("h3",null,"🤖 aui指令渲染效果预览捏",-1)),s(" 刷新按钮 "),t("button",{class:"oii-refresh-btn",onClick:g,title:"刷新预览"},e[8]||(e[8]=[t("span",{class:"oii-refresh-icon"},"🔄",-1)]))]),t("div",I,[s(" 模板选择 "),t("div",q,[e[11]||(e[11]=t("span",{class:"oii-select-icon"},"🎨",-1)),_(t("select",{"onUpdate:modelValue":e[0]||(e[0]=d=>n.value=d),onChange:F,class:"oii-select"},e[10]||(e[10]=[t("option",{value:"sourceHanSerif"},"思源宋体风格",-1),t("option",{value:"flatMinimal"},"扁平简约风格",-1),t("option",{value:"lxgwWenKai"},"文楷风格",-1)]),544),[[x,n.value]]),e[12]||(e[12]=t("span",{class:"oii-select-arrow"},"▼",-1))]),s(" 字体选择 "),t("div",A,[e[14]||(e[14]=t("span",{class:"oii-select-icon"},"✏️",-1)),_(t("select",{"onUpdate:modelValue":e[1]||(e[1]=d=>l.value=d),onChange:M,class:"oii-select"},e[13]||(e[13]=[t("option",{value:"sourceHanSerif"},"思源宋体",-1),t("option",{value:"lxgwWenKai"},"霞鹜文楷",-1)]),544),[[x,l.value]]),e[15]||(e[15]=t("span",{class:"oii-select-arrow"},"▼",-1))]),s(" 主题选择 "),t("div",G,[t("span",J,w(r.value?"🌙":"☀️"),1),_(t("select",{"onUpdate:modelValue":e[2]||(e[2]=d=>r.value=d),onChange:B,class:"oii-select oii-theme-select"},e[16]||(e[16]=[t("option",{value:true},"深色模式",-1),t("option",{value:false},"浅色模式",-1)]),544),[[x,r.value]]),e[17]||(e[17]=t("span",{class:"oii-select-arrow"},"▼",-1))])])]),t("div",L,[t("iframe",{srcdoc:D.value,class:"oii-iframe",frameborder:"0",scrolling:"no"},null,8,P)])])):s("v-if",true)],64)}}}),R=(a,f)=>{const i=a.__vccOpts||a;for(const[n,l]of f)i[n]=l;return i},X=R(Q,[["__scopeId","data-v-6439a724"]]),$=a=>{a.slot({type:"plugin-details",component:X,order:0})};export{$ as default};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.oii-loading-wrapper[data-v-6439a724]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:40px;gap:16px}.oii-spinner[data-v-6439a724]{width:40px;height:40px;border:4px solid rgba(255,255,255,.1);border-left-color:#fb7299;border-radius:50%;animation:oii-spin-6439a724 1s linear infinite}@keyframes oii-spin-6439a724{to{transform:rotate(360deg)}}.oii-comment[data-v-6439a724]{display:flex;flex-direction:column;align-items:center;gap:12px;padding:20px}.oii-bot-info-card[data-v-6439a724]{background:linear-gradient(135deg,#ffffff14,#ffffff08);border-radius:20px;overflow:hidden;border:1px solid rgba(255,255,255,.12);box-shadow:0 8px 32px #0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.oii-bot-info-card .oii-card-header[data-v-6439a724]{display:flex;justify-content:space-between;align-items:center;padding:18px 24px;background:linear-gradient(135deg,#ffffff0f,#ffffff05);border-bottom:1px solid rgba(255,255,255,.08);flex-wrap:wrap;gap:14px}.oii-bot-info-card .oii-card-header .oii-header-left[data-v-6439a724]{display:flex;align-items:center;gap:12px}.oii-bot-info-card .oii-card-header h3[data-v-6439a724]{margin:0;font-size:17px;font-weight:600;background:linear-gradient(135deg,#fff,#fffc);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}.oii-bot-info-card .oii-card-header .oii-controls[data-v-6439a724]{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.oii-bot-info-card .oii-card-content[data-v-6439a724]{padding:20px;overflow:hidden}.oii-bot-info-card .oii-card-content .oii-iframe[data-v-6439a724]{width:100%;height:888px;border:none;border-radius:16px;background:transparent}.oii-select-wrapper[data-v-6439a724]{position:relative;display:flex;align-items:center}.oii-select-wrapper .oii-select-icon[data-v-6439a724]{position:absolute;left:12px;font-size:14px;pointer-events:none;z-index:1}.oii-select-wrapper .oii-select-arrow[data-v-6439a724]{position:absolute;right:12px;font-size:10px;color:#ffffff80;pointer-events:none;transition:transform .2s ease}.oii-select-wrapper:hover .oii-select-arrow[data-v-6439a724]{transform:translateY(2px)}.oii-select-wrapper .oii-select[data-v-6439a724]{-moz-appearance:none;appearance:none;-webkit-appearance:none;padding:10px 36px 10px 38px;border-radius:12px;border:1px solid rgba(255,255,255,.15);background:linear-gradient(135deg,#ffffff1a,#ffffff0d);color:#fff;font-size:14px;font-weight:500;cursor:pointer;outline:none;transition:all .3s cubic-bezier(.4,0,.2,1);min-width:140px}.oii-select-wrapper .oii-select[data-v-6439a724]:hover{border-color:#fb729980;background:linear-gradient(135deg,#ffffff26,#ffffff14);box-shadow:0 4px 12px #fb729926}.oii-select-wrapper .oii-select[data-v-6439a724]:focus{border-color:#fb7299;box-shadow:0 0 0 3px #fb729933,0 4px 12px #fb729933}.oii-select-wrapper .oii-select option[data-v-6439a724]{background:#1e1e2e;color:#fff;padding:10px}.oii-select-wrapper .oii-theme-select[data-v-6439a724]{min-width:120px}.oii-refresh-btn[data-v-6439a724]{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:12px;border:1px solid rgba(255,255,255,.15);background:linear-gradient(135deg,#ffffff1a,#ffffff0d);cursor:pointer;transition:all .3s cubic-bezier(.4,0,.2,1)}.oii-refresh-btn .oii-refresh-icon[data-v-6439a724]{font-size:18px;transition:transform .4s ease}.oii-refresh-btn[data-v-6439a724]:hover{border-color:#fb729980;background:linear-gradient(135deg,#fb729933,#fb72991a);box-shadow:0 4px 12px #fb729933}.oii-refresh-btn:hover .oii-refresh-icon[data-v-6439a724]{transform:rotate(180deg)}.oii-refresh-btn[data-v-6439a724]:active{transform:scale(.95)}.oii-refresh-btn:active .oii-refresh-icon[data-v-6439a724]{transform:rotate(360deg)}.oii-fade-in[data-v-6439a724]{animation:oii-fadeIn-6439a724 .5s ease-out}@keyframes oii-fadeIn-6439a724{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { DataService } from '@koishijs/plugin-console';
|
|
3
|
+
export type TemplateType = 'sourceHanSerif' | 'flatMinimal' | 'lxgwWenKai';
|
|
4
|
+
export type FontType = 'sourceHanSerif' | 'lxgwWenKai';
|
|
5
|
+
declare module '@koishijs/plugin-console' {
|
|
6
|
+
namespace Console {
|
|
7
|
+
interface Services {
|
|
8
|
+
'onebot-info-image': BotInfoData;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface Events {
|
|
12
|
+
'onebot-info-image/refresh'(): void;
|
|
13
|
+
'onebot-info-image/setTemplate'(template: TemplateType): void;
|
|
14
|
+
'onebot-info-image/setFont'(font: FontType): void;
|
|
15
|
+
'onebot-info-image/setDarkMode'(darkMode: boolean): void;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export interface BotInfoData {
|
|
19
|
+
status: 'loading' | 'no_bot' | 'error' | 'loaded';
|
|
20
|
+
msg: string;
|
|
21
|
+
htmlContent?: string;
|
|
22
|
+
currentTemplate?: TemplateType;
|
|
23
|
+
currentFont?: FontType;
|
|
24
|
+
currentDarkMode?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare class OnebotInfoImageDataServer extends DataService<BotInfoData> {
|
|
27
|
+
fontsBase64: Record<FontType, string>;
|
|
28
|
+
fontLoaded: boolean;
|
|
29
|
+
currentTemplate: TemplateType;
|
|
30
|
+
currentFont: FontType;
|
|
31
|
+
currentDarkMode: boolean;
|
|
32
|
+
static inject: string[];
|
|
33
|
+
constructor(ctx: Context);
|
|
34
|
+
private loadFonts;
|
|
35
|
+
private getHtmlGenerator;
|
|
36
|
+
get(): Promise<BotInfoData>;
|
|
37
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ImageStyleKey, type ImageType, type OneBotImplName } from './type';
|
|
3
3
|
export declare const name = "onebot-info-image";
|
|
4
4
|
export declare const inject: {
|
|
5
5
|
required: string[];
|
|
6
6
|
};
|
|
7
7
|
export declare const usage: string;
|
|
8
|
+
export interface ImageStyleDetail {
|
|
9
|
+
styleKey: ImageStyleKey;
|
|
10
|
+
darkMode: boolean;
|
|
11
|
+
}
|
|
8
12
|
export interface Config {
|
|
9
13
|
onebotImplName: OneBotImplName;
|
|
10
14
|
enableUserInfoCommand: boolean;
|
|
11
15
|
userinfoCommandName: string;
|
|
16
|
+
hidePhoneNumber: boolean;
|
|
12
17
|
enableGroupAdminListCommand: boolean;
|
|
13
18
|
groupAdminListCommandName: string;
|
|
19
|
+
inspectStyleCommandName: string;
|
|
14
20
|
sendText: boolean;
|
|
15
21
|
enableQuoteWithText: boolean;
|
|
16
22
|
sendImage: boolean;
|
|
17
23
|
enableQuoteWithImage: boolean;
|
|
18
|
-
|
|
19
|
-
enableDarkMode: boolean;
|
|
24
|
+
imageStyleDetails: ImageStyleDetail[];
|
|
20
25
|
imageType: ImageType;
|
|
21
26
|
screenshotQuality: number;
|
|
22
27
|
sendForward: boolean;
|
|
23
28
|
verboseSessionOutput: boolean;
|
|
24
29
|
verboseConsoleOutput: boolean;
|
|
30
|
+
verboseFileOutput: boolean;
|
|
25
31
|
}
|
|
26
32
|
export declare const Config: Schema<Config>;
|
|
27
33
|
export declare function apply(ctx: Context, config: Config): void;
|