generated from KarinJS/karin-plugin-template-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 注释掉了 render.ts 和 task.ts 文件中的未使用导入和导出 - 保留了文件结构和注释,以便未来可能的使用
- Loading branch information
1 parent
2819e64
commit b737090
Showing
2 changed files
with
80 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,88 @@ | ||
import { dirPath } from '@/utils' | ||
import { karin, render, common, segment, logger } from 'node-karin' | ||
// import { dirPath } from '@/utils' | ||
// import { karin, render, common, segment, logger } from 'node-karin' | ||
|
||
/** | ||
* 渲染demo | ||
* 触发指令: #测试渲染 | ||
*/ | ||
export const image = karin.command(/^#?测试渲染$/, async (e) => { | ||
try { | ||
const filePath = common.absPath(dirPath + '/resources') | ||
const html = filePath + '/template/test.html' | ||
const image = filePath + '/image/启程宣发.png' | ||
// /** | ||
// * 渲染demo | ||
// * 触发指令: #测试渲染 | ||
// */ | ||
// export const image = karin.command(/^#?测试渲染$/, async (e) => { | ||
// try { | ||
// const filePath = common.absPath(dirPath + '/resources') | ||
// const html = filePath + '/template/test.html' | ||
// const image = filePath + '/image/启程宣发.png' | ||
|
||
const img = await render.render({ | ||
name: 'render', | ||
file: html, | ||
data: { | ||
file: image, | ||
pluResPath: process.cwd(), | ||
}, | ||
pageGotoParams: { | ||
waitUntil: 'networkidle2', | ||
}, | ||
}) as string | ||
// const img = await render.render({ | ||
// name: 'render', | ||
// file: html, | ||
// data: { | ||
// file: image, | ||
// pluResPath: process.cwd(), | ||
// }, | ||
// pageGotoParams: { | ||
// waitUntil: 'networkidle2', | ||
// }, | ||
// }) as string | ||
|
||
await e.reply(segment.image(img)) | ||
return true | ||
} catch (error) { | ||
logger.error(error) | ||
await e.reply(JSON.stringify(error)) | ||
// await e.reply(segment.image(img)) | ||
// return true | ||
// } catch (error) { | ||
// logger.error(error) | ||
// await e.reply(JSON.stringify(error)) | ||
|
||
return true | ||
} | ||
}, { | ||
/** 插件优先级 */ | ||
priority: 9999, | ||
// return true | ||
// } | ||
// }, { | ||
// /** 插件优先级 */ | ||
// priority: 9999, | ||
|
||
/** 插件触发是否打印触发日志 */ | ||
log: true, | ||
// /** 插件触发是否打印触发日志 */ | ||
// log: true, | ||
|
||
/** 插件名称 */ | ||
name: '测试渲染', | ||
// /** 插件名称 */ | ||
// name: '测试渲染', | ||
|
||
/** 谁可以触发这个插件 'all' | 'master' | 'admin' | 'group.owner' | 'group.admin' */ | ||
permission: 'all', | ||
// /** 谁可以触发这个插件 'all' | 'master' | 'admin' | 'group.owner' | 'group.admin' */ | ||
// permission: 'all', | ||
|
||
}) | ||
// }) | ||
|
||
/** | ||
* 渲染demo | ||
* 触发指令: #渲染 | ||
*/ | ||
export const renderUrl = karin.command(/^#?渲染/, async (e) => { | ||
const file = e.msg.replace(/^#?渲染/, '').trim() | ||
try { | ||
const img = await render.render({ | ||
name: 'render', | ||
file: file || 'https://whitechi73.github.io/OpenShamrock/', | ||
type: 'png', | ||
pageGotoParams: { | ||
waitUntil: 'networkidle2', | ||
}, | ||
setViewport: { | ||
width: 1920, | ||
height: 1080, | ||
deviceScaleFactor: 1, | ||
}, | ||
}) as string | ||
await e.reply(segment.image(img)) | ||
return true | ||
} catch (error: any) { | ||
logger.error(error) | ||
await e.reply(error.message) | ||
return true | ||
} | ||
}, { | ||
/** 插件优先级 */ | ||
priority: 9999, | ||
// /** | ||
// * 渲染demo | ||
// * 触发指令: #渲染 | ||
// */ | ||
// export const renderUrl = karin.command(/^#?渲染/, async (e) => { | ||
// const file = e.msg.replace(/^#?渲染/, '').trim() | ||
// try { | ||
// const img = await render.render({ | ||
// name: 'render', | ||
// file: file || 'https://whitechi73.github.io/OpenShamrock/', | ||
// type: 'png', | ||
// pageGotoParams: { | ||
// waitUntil: 'networkidle2', | ||
// }, | ||
// setViewport: { | ||
// width: 1920, | ||
// height: 1080, | ||
// deviceScaleFactor: 1, | ||
// }, | ||
// }) as string | ||
// await e.reply(segment.image(img)) | ||
// return true | ||
// } catch (error: any) { | ||
// logger.error(error) | ||
// await e.reply(error.message) | ||
// return true | ||
// } | ||
// }, { | ||
// /** 插件优先级 */ | ||
// priority: 9999, | ||
|
||
/** 插件触发是否打印触发日志 */ | ||
log: true, | ||
// /** 插件触发是否打印触发日志 */ | ||
// log: true, | ||
|
||
/** 插件名称 */ | ||
name: '渲染demo', | ||
// /** 插件名称 */ | ||
// name: '渲染demo', | ||
|
||
/** 谁可以触发这个插件 'all' | 'master' | 'admin' | 'group.owner' | 'group.admin' */ | ||
permission: 'master', | ||
}) | ||
// /** 谁可以触发这个插件 'all' | 'master' | 'admin' | 'group.owner' | 'group.admin' */ | ||
// permission: 'master', | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { karin, logger } from 'node-karin' | ||
// import { karin, logger } from 'node-karin' | ||
|
||
/** | ||
* 定时任务模板 | ||
* 参数1: 任务名称 | ||
* 参数2: cron表达式 | ||
* 参数3: 任务方法 | ||
*/ | ||
export const Task = karin.task('1分钟打印1次hello', '0 */1 * * * *', async () => { | ||
logger.info('hello') | ||
}) | ||
// export const Task = karin.task('1分钟打印1次hello', '0 */1 * * * *', async () => { | ||
// logger.info('hello') | ||
// }) |