Commit 0e058b7b authored by nanahira's avatar nanahira

add puppeteer support

parent 133ddc36
Pipeline #19399 passed with stage
in 38 seconds
...@@ -30,7 +30,7 @@ app.plugin(ExtrasInDev); ...@@ -30,7 +30,7 @@ app.plugin(ExtrasInDev);
// Target plugin // Target plugin
app.plugin(TargetPlugin, { app.plugin(TargetPlugin, {
databasePaths: ['./dev/ygopro-database/locales/zh-CN'], databasePaths: ['./dev/ygopro-database/locales/zh-CN'],
usePuppeteer: true, usePuppeteer: false,
}); });
app.plugin(PuppeteerPlugin); app.plugin(PuppeteerPlugin);
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
"url": "https://code.mycard.moe/3rdeye/koishi-plugin-ygocard.git" "url": "https://code.mycard.moe/3rdeye/koishi-plugin-ygocard.git"
}, },
"author": "Nanahira <nanahira@momobako.com>", "author": "Nanahira <nanahira@momobako.com>",
"contributors": [
"Nanahira <nanahira@momobako.com>",
"Anillc <void@anillc.cn>"
],
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
"Koishi.js", "Koishi.js",
...@@ -81,5 +85,12 @@ ...@@ -81,5 +85,12 @@
], ],
"coverageDirectory": "../coverage", "coverageDirectory": "../coverage",
"testEnvironment": "node" "testEnvironment": "node"
},
"koishi": {
"service": {
"optional": [
"puppeteer"
]
}
} }
} }
...@@ -119,23 +119,63 @@ export default class YGOCardPlugin ...@@ -119,23 +119,63 @@ export default class YGOCardPlugin
if (!this.config.usePuppeteer || !this.puppeteer) { if (!this.config.usePuppeteer || !this.puppeteer) {
return card.getDisplayString(this.config); return card.getDisplayString(this.config);
} }
const url = card.getPic(this.config); const img = card.getPic(this.config);
const { name, id, desc } = card; const { name, id, desc } = card;
const metaText = card.getMetaText(this.config); const meta = card.getMetaText(this.config);
return ( return (
<html> <html>
<body> <div>
<div> <style>{`
<image src={url} /> .img {
</div> grid-area: img;
<div> width: 150px;
{name} {id} border-radius: 5px;
</div> border: solid 1px gray;
<div> padding: 5px;
<p>{metaText}</p> }
<p>{desc}</p> .name { grid-area: name; }
.hr {
grid-area: hr;
width: 100%;
}
.id { grid-area: id; }
.meta { grid-area: meta; }
.desc {
grid-area: desc;
border-radius: 5px;
border: solid 1px gray;
padding: 10px;
}
.main {
display: grid;
grid-template-areas:
'img name name name'
'img name name name'
'img hr hr hr '
'img meta meta meta'
'img none none none'
'desc desc desc desc';
gap: 10px;
width: 400px;
padding: 20px;
}
`}</style>
<div class="main">
<image class="img" src={img} />
<div class="name">
<h3>{name}</h3>
<div>{id}</div>
</div>
<hr class="hr" />
<div class="meta">
{...meta.split('\n').map((line) => <div>{line}</div>)}
</div>
<div class="desc">
{...desc.split('\n').map((line) => <div>{line}</div>)}
</div>
</div> </div>
</body> </div>
</html> </html>
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment