Commit fbfb2b4c authored by nanahira's avatar nanahira

optional preserve filename

parent 71005db8
...@@ -13,6 +13,9 @@ export class PicsPluginConfig { ...@@ -13,6 +13,9 @@ export class PicsPluginConfig {
hidden: true, hidden: true,
}) })
failedMessage: string; failedMessage: string;
@DefineSchema({ description: '保留 URL 中的文件名。', default: false })
preseveFilename: boolean;
} }
export type PicsPluginConfigLike = Partial<PicsPluginConfig>; export type PicsPluginConfigLike = Partial<PicsPluginConfig>;
......
...@@ -199,11 +199,15 @@ export default class PicsContainer ...@@ -199,11 +199,15 @@ export default class PicsContainer
if (!result) { if (!result) {
return this.config.failedMessage; return this.config.failedMessage;
} }
let msg = `获取到图片:\n${segment('image', { const picData: segment.Data = {
url: result.url, url: result.url,
file: result.url.split('/').pop(), file: result.url.split('/').pop(),
cache: true, cache: true,
})}`; };
if (this.config.preseveFilename) {
picData.file = result.url.split('/').pop();
}
let msg = `获取到图片:\n${segment('image', picData)}`;
if (result.description) { if (result.description) {
msg += `\n${result.description}`; msg += `\n${result.description}`;
} }
......
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