@candriajs/karin-plugin-git 1.2.0 → 1.4.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +23 -2
  3. package/config/defSet/{cnb.yaml → cnbcool.yaml} +0 -2
  4. package/config/defSet/gitcode.yaml +0 -2
  5. package/config/defSet/gitee.yaml +0 -2
  6. package/config/defSet/github.yaml +0 -3
  7. package/config/defSet/proxy.yaml +5 -0
  8. package/config/defSet/token.yaml +11 -0
  9. package/lib/apps/admin.js +1 -1
  10. package/lib/apps/commit.js +3 -0
  11. package/lib/apps/help.js +1 -1
  12. package/lib/apps/push.js +1 -5
  13. package/lib/common-DJ-f21cV.js +250 -0
  14. package/lib/db-DhpZxiAN.js +55 -0
  15. package/lib/index.js +1 -1
  16. package/lib/models-qDLDUVt0.js +3 -0
  17. package/lib/web.config.js +1 -0
  18. package/package.json +6 -26
  19. package/resources/background.webp +0 -0
  20. package/lib/apps/issue.js +0 -1
  21. package/lib/common-Df1uHYOv.js +0 -1
  22. package/lib/db-DZFBXSmG.js +0 -44
  23. package/lib/types-7HeFLBYV.js +0 -1
  24. package/resources/commit/index.css +0 -293
  25. package/resources/commit/index.html +0 -123
  26. package/resources/fonts/DouyinSansBold.woff2 +0 -0
  27. package/resources/fonts/NotoColorEmoji-Regular.woff2 +0 -0
  28. package/resources/fonts/SmileySans-Oblique.woff2 +0 -0
  29. package/resources/help/index.css +0 -124
  30. package/resources/help/index.html +0 -84
  31. package/resources/help/version-info.css +0 -31
  32. package/resources/help/version-info.html +0 -22
  33. package/resources/icons/branch.svg +0 -1
  34. package/resources/icons/cnb.svg +0 -1
  35. package/resources/icons/commit.svg +0 -1
  36. package/resources/icons/gitcode.svg +0 -1
  37. package/resources/icons/gitee.svg +0 -1
  38. package/resources/icons/github.svg +0 -1
  39. package/resources/icons/issue.svg +0 -1
  40. package/resources/issue/index.css +0 -229
  41. package/resources/issue/index.html +0 -79
  42. /package/lib/{root-C9I_RrRd.js → root-q84D5Ojp.js} +0 -0
  43. /package/resources/{icons/repo.svg → repo.svg} +0 -0
@@ -0,0 +1,55 @@
1
+ import{t as e}from"./root-q84D5Ojp.js";import{karinPathBase as t}from"node-karin";import n from"node-karin/sqlite3";const r=async(e,t,n=`main`,r=`main`)=>{await(await g()).run(`INSERT INTO push (repoId, sessionId, branch, commitSha) VALUES (?, ?, ?, ?)`,[e,t,n,r])},i=async()=>{let e=await g();return await new Promise((t,n)=>{e.all(`SELECT * FROM push`,[],(e,r)=>{e?n(e):t(r)})})},a=async(e,t,n)=>{let r=await g();return await new Promise((i,a)=>{r.get(`SELECT * FROM push WHERE repoId = ? AND sessionId = ? AND branch = ?`,[e,t,n],(e,t)=>{e?a(e):i(t)})})},o=async(e,t,n)=>{let r=await g();n?await r.run(`DELETE FROM push WHERE repoId = ? AND sessionId = ? AND branch = ?`,[e,t,n]):await r.run(`DELETE FROM push WHERE repoId = ? AND sessionId = ?`,[e,t])},s=async(e,t,n,r)=>{await(await g()).run(`UPDATE push SET commitSha = ? WHERE repoId = ? AND sessionId = ? AND branch = ?`,[r,e,t,n])},c=async(e,t)=>{await(await g()).run(`INSERT INTO session (botId,groupId) VALUES (?,?)`,[e,t])},l=async(e,t)=>{let n=await g();return typeof e==`string`?await new Promise((r,i)=>{n.get(`SELECT * FROM session WHERE botId = ? AND groupId = ?`,[e,t],(e,t)=>{e?i(e):r(t)})}):await new Promise((t,r)=>{n.get(`SELECT * FROM session WHERE id = ?`,[e],(e,n)=>{e?r(e):t(n)})})},u=async(e,t)=>{await(await g()).run(`INSERT INTO bind (groupId, repoId) VALUES (?, ?)`,[e,t])},d=async e=>{let t=await g();return await new Promise((n,r)=>{t.get(`SELECT * FROM bind WHERE groupId = ?`,[e],(e,t)=>{e?r(e):n(t)})})},f=async(e,t,n)=>{await(await g()).run(`INSERT INTO repo (platform,owner, repo) VALUES (?,?, ?)`,[e,t,n])},p=async()=>{let e=await g();return await new Promise((t,n)=>{e.all(`SELECT * FROM repo`,(e,r)=>{e?n(e):t(r)})})},m=async(e,t,n)=>{let r=await g();return typeof e==`number`?await new Promise((t,n)=>{r.get(`SELECT * FROM repo WHERE id = ?`,[e],(e,r)=>{e?n(e):t(r)})}):await new Promise((i,a)=>{r.get(`SELECT * FROM repo WHERE platform = ? AND owner = ? AND repo = ?`,[e,t,n],(e,t)=>{e?a(e):i(t)})})};let h=null;const g=async()=>{if(!h){let r=`${t}/${e.Plugin_Name}/data`;h=new n.Database(`${r}/data.db`)}return h},_=async()=>{let e=await g();e.exec(`
2
+ CREATE TABLE IF NOT EXISTS repo (
3
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
4
+ platform TEXT NOT NULL,
5
+ owner TEXT NOT NULL,
6
+ repo TEXT NOT NULL,
7
+ createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
8
+ updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
9
+ UNIQUE(platform, owner, repo)
10
+ )
11
+ `),e.exec(`
12
+ CREATE TABLE IF NOT EXISTS session (
13
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
14
+ botId TEXT NOT NULL,
15
+ groupId TEXT NOT NULL,
16
+ createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
17
+ updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
18
+ UNIQUE(botId, groupId)
19
+ )
20
+ `),e.exec(`
21
+ CREATE TABLE IF NOT EXISTS push (
22
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
23
+ repoId INTEGER NOT NULL,
24
+ sessionId INTEGER NOT NULL,
25
+ branch TEXT NOT NULL,
26
+ commitSha TEXT NOT NULL,
27
+ createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
28
+ updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
29
+ FOREIGN KEY (repoId) REFERENCES repo(id) ON DELETE CASCADE,
30
+ FOREIGN KEY (sessionId) REFERENCES session(id) ON DELETE CASCADE,
31
+ UNIQUE(repoId, sessionId, branch, commitSha)
32
+ )
33
+ `),e.exec(`
34
+ CREATE TABLE IF NOT EXISTS bind (
35
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
36
+ groupId TEXT NOT NULL,
37
+ repoId INTEGER NOT NULL,
38
+ createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
39
+ updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
40
+ FOREIGN KEY (repoId) REFERENCES repo(id) ON DELETE CASCADE,
41
+ UNIQUE(groupId, repoId)
42
+ )
43
+ `),e.exec(`
44
+ CREATE TABLE IF NOT EXISTS release (
45
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
46
+ repoId INTEGER NOT NULL,
47
+ sessionId INTEGER NOT NULL,
48
+ tagName TEXT NOT NULL,
49
+ createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
50
+ updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
51
+ FOREIGN KEY (repoId) REFERENCES repo(id) ON DELETE CASCADE,
52
+ FOREIGN KEY (sessionId) REFERENCES session(id) ON DELETE CASCADE,
53
+ UNIQUE(repoId, sessionId, tagName)
54
+ )
55
+ `),e.exec(`CREATE INDEX IF NOT EXISTS idx_session_lookup ON session(botId, groupId)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_repo_lookup ON repo(platform, owner, repo)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_push_branch ON push(repoId, branch)`)};export{u as a,l as c,a as d,o as f,m as i,r as l,f as n,d as o,s as p,p as r,c as s,_ as t,i as u};
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./root-C9I_RrRd.js";import{t}from"./db-DZFBXSmG.js";import{logger as n}from"node-karin";import r from"node-karin/axios";const i=async()=>{let i=`加载失败`;try{i=(await r.get(`https://api.wuliya.cn/api/image/count?name=${e.Plugin_Name}&type=json`,{timeout:500})).data.data.count}catch{n.error(n.chalk.red.bold(`⚠️ 访问统计数据失败,超时或网络错误`))}await t(),n.info(n.chalk.bold.rgb(0,255,0)(`========= 🌟🌟🌟 =========`)),n.info(n.chalk.bold.blue(`🌍 当前运行环境: `)+n.chalk.bold.white(`${e.Bot_Name}`)+n.chalk.gray(` | `)+n.chalk.bold.green(`🏷️ 运行版本: `)+n.chalk.bold.white(`V${e.Bot_Version}`)+n.chalk.gray(` | `)+n.chalk.bold.yellow(`📊 运行插件总访问/运行次数: `)+n.chalk.bold.cyan(i)),n.info(n.chalk.bold.rgb(255,215,0)(`✨ ${e.Plugin_Name} `)+n.chalk.bold.rgb(255,165,0).italic(e.Plugin_Version)+n.chalk.rgb(255,215,0).bold(` 载入成功 ^_^`)),n.info(n.chalk.green.bold(`=========================`))};export{i as KARIN_PLUGIN_INIT};
1
+ import{t as e}from"./root-q84D5Ojp.js";import{t}from"./db-DhpZxiAN.js";import{logger as n}from"node-karin";import r from"node-karin/axios";const i=async()=>{let i=`加载失败`;try{i=(await r.get(`https://api.wuliya.cn/api/image/count?name=${e.Plugin_Name}&type=json`,{timeout:500})).data.data.count}catch{n.error(n.chalk.red.bold(`⚠️ 访问统计数据失败,超时或网络错误`))}await t(),n.info(n.chalk.bold.rgb(0,255,0)(`========= 🌟🌟🌟 =========`)),n.info(n.chalk.bold.blue(`🌍 当前运行环境: `)+n.chalk.bold.white(`${e.Bot_Name}`)+n.chalk.gray(` | `)+n.chalk.bold.green(`🏷️ 运行版本: `)+n.chalk.bold.white(`V${e.Bot_Version}`)+n.chalk.gray(` | `)+n.chalk.bold.yellow(`📊 运行插件总访问/运行次数: `)+n.chalk.bold.cyan(i)),n.info(n.chalk.bold.rgb(255,215,0)(`✨ ${e.Plugin_Name} `)+n.chalk.bold.rgb(255,165,0).italic(e.Plugin_Version)+n.chalk.rgb(255,215,0).bold(` 载入成功 ^_^`)),n.info(n.chalk.green.bold(`=========================`))};export{i as KARIN_PLUGIN_INIT};
@@ -0,0 +1,3 @@
1
+ import{c as e,i as t,p as n,r,u as i}from"./db-DhpZxiAN.js";import{i as a,n as o,r as s,t as c}from"./common-DJ-f21cV.js";import{components as l,contactGroup as u,getBot as d,logger as f}from"node-karin";import{isEmpty as p}from"es-toolkit/compat";import{CnbClient as m,GitCodeClient as h,GiteeClient as g,GithubClient as _}from"nipaw";const v=()=>{let e=new _;return p(a.proxy.reverseProxy)?p(a.proxy.proxy)||e.setProxy(a.proxy.proxy):e.setReverseProxy(a.proxy.reverseProxy),p(a.token.github)||e.setToken(a.token.github),e},y=()=>{let e=new g;return p(a.proxy.proxy)||e.setProxy(a.proxy.proxy),p(a.token.gitee)||e.setToken(a.token.gitee),e},b=()=>{let e=new h;return p(a.proxy.proxy)||e.setProxy(a.proxy.proxy),p(a.token.gitcode)||e.setToken(a.token.gitcode),e},x=()=>{let e=new m;return p(a.proxy.proxy)||e.setProxy(a.proxy.proxy),p(a.token.cnbcool)||e.setToken(a.token.cnbcool),e};var S=class{platform;client;constructor(e,t){this.platform=e,this.client=t}async action(){let[a,o]=await Promise.all([r(),i()]),s=a.filter(e=>e.platform===this.platform).map(e=>e.id),l=o.filter(e=>s.includes(e.repoId)),p=this.client.commit();l.forEach(async r=>{let i=await t(r.id);f.debug(`开始处理 ${this.platform} ${i.owner}/${i.repo} ${r.branch}}`);let a=await e(r.sessionId),o=await p.info({owner:i.owner,repo:i.repo},r.branch);if(o.sha===r.commitSha)return;let s=d(a.botId);if(!s)throw Error(`Bot ${a.botId} not found`);let l=o.commit.message.split(`
2
+ `),m={owner:i.owner,repo:i.repo,branch:r.branch,sha:o.sha,author:o.commit.author,committer:o.commit.committer,title:l[0],content:l.slice(1).join(`
3
+ `),stats:o.stats,files:o.files},h=await c.commit(this.platform,m),g=u(a.groupId);await s.sendMsg(g,[h]),await n(r.repoId,r.sessionId,r.branch,o.sha)})}},C=class extends S{constructor(){super(s.GitHub,v())}};const w=e=>[l.accordion.create(`github`,{label:`Github 相关`,children:[l.accordion.createItem(`config:github`,{title:`Github 相关`,subtitle:`Github 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.github.cron})]})]}),l.accordionPro.create(`pushlist:github`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,subtitle:`${e.botId}:${e.groupId}`,...e})),{label:`Github 推送仓库列表`,children:l.accordion.createItem(`accordion-item-github`,{children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 Github 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 Github 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 Github 仓库分支`}),l.input.string(`botId`,{label:`推送机器人`,placeholder:`请输入 推送机器人账号`}),l.input.string(`groupId`,{label:`推送群组`,placeholder:`请输入 推送群组ID`}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];var T=class extends S{constructor(){super(s.Gitee,y())}};const E=e=>[l.accordion.create(`gitee`,{label:`Gitee 相关`,children:[l.accordion.createItem(`config:gitee`,{title:`Gitee 相关`,subtitle:`Gitee 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.gitee.cron})]})]}),l.accordionPro.create(`pushlist:gitee`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,...e})),{label:`Gitee 推送仓库列表`,children:l.accordion.createItem(`accordion-item-gitee`,{subtitle:`Gitee 仓库`,children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 Gitee 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 Gitee 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 Gitee 仓库分支`,isRequired:!0}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];var D=class extends S{constructor(){super(s.GitCode,b())}};const O=e=>[l.accordion.create(`gitcode`,{label:`GitCode 相关`,children:[l.accordion.createItem(`config:gitcode`,{title:`GitCode 相关`,subtitle:`GitCode 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.gitcode.cron})]})]}),l.accordionPro.create(`pushlist:gitcode`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,...e})),{label:`GitCode 推送仓库列表`,children:l.accordion.createItem(`accordion-item-gitcode`,{subtitle:`GitCode 仓库`,children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 GitCode 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 GitCode 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 GitCode 仓库分支`}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];var k=class extends S{constructor(){super(s.CnbCool,x())}};const A=e=>[l.accordion.create(`cnbcool`,{label:`CnbCool 相关`,children:[l.accordion.createItem(`config:gitcode`,{title:`CnbCool 相关`,subtitle:`CnbCool 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.cnbcool.cron})]})]}),l.accordionPro.create(`pushlist:cnbcool`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,...e})),{label:`CnbCool 推送仓库列表`,children:l.accordion.createItem(`accordion-item-cnbcoool`,{subtitle:`CnbCool 仓库`,children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 CnbCool 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 CnbCool 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 CnbCool 仓库分支`}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];export{E as a,C as c,y as d,v as f,D as i,x as l,k as n,T as o,O as r,w as s,A as t,b as u};
@@ -0,0 +1 @@
1
+ import"./root-q84D5Ojp.js";import{c as e,d as t,f as n,i as r,l as i,n as a,s as o,u as s}from"./db-DhpZxiAN.js";import{i as c,n as l,r as u}from"./common-DJ-f21cV.js";import{a as d,r as f,s as p,t as m}from"./models-qDLDUVt0.js";import{components as h,defineConfig as g}from"node-karin";import{differenceWith as _}from"es-toolkit/array";const v=async t=>{let n=await s();if(!n.length)return[];let i=[...new Set(n.map(e=>e.repoId))],a=[...new Set(n.map(e=>e.sessionId))],[o,c]=await Promise.all([Promise.all(i.map(e=>r(e))),Promise.all(a.map(t=>e(t)))]),u=new Map(o.filter(Boolean).map(e=>[e.id,e])),d=new Map(c.filter(Boolean).map(e=>[e.id,e]));return n.filter(e=>{let n=u.get(e.repoId),r=d.get(e.sessionId);return n&&r&&(!t||n.platform===t)}).map(e=>{let t=u.get(e.repoId),n=d.get(e.sessionId);return{owner:t.owner,repo:t.repo,botId:n.botId,groupId:n.groupId,branch:e.branch,event:[l.Push]}})},y=(e,t)=>e.owner===t.owner&&e.repo===t.repo&&e.branch===t.branch&&e.botId===t.botId&&e.groupId===t.groupId,b=async(n,s)=>{n.length&&await Promise.all(n.map(async n=>{let[c,u]=await Promise.all([r(s,n.owner,n.repo),e(n.botId,n.groupId)]);u||=(await o(n.botId,n.groupId),await e(n.botId,n.groupId)),c||=(await a(s,n.owner,n.repo),await r(s,n.owner,n.repo)),n.event.includes(l.Push)&&(await t(c.id,u.id,n.branch)||await i(c.id,u.id,n.branch,``))}))},x=async(i,a)=>{i.length&&await Promise.all(i.map(async i=>{let[o,s]=await Promise.all([r(a,i.owner,i.repo),e(i.botId,i.groupId)]);!o||!s||i.event.includes(l.Push)&&await t(o.id,s.id,i.branch)&&await n(o.id,s.id,i.branch)}))};var S=g({info:{id:`@candriajs/karin-plugin-git`,name:`karin-plugin-git`,author:{name:`CandriaJS`,home:`https://github.com/CandriaJS`,avatar:`https://avatars.githubusercontent.com/u/196008293?s=200&v=4`}},components:async()=>[h.divider.create(`divider-1`,{description:`基础配置`,descPosition:50}),h.accordion.create(`token`,{label:`Token 配置`,children:[h.accordion.createItem(`config:github`,{title:`token 相关`,subtitle:`建议, 否则大部分功能不可用`,children:[h.input.string(`github`,{label:`Github`,description:`Github 访问令牌`,placeholder:`请输入 Github 访问令牌`,defaultValue:c.token.github,isClearable:!0,isRequired:!1}),h.input.string(`gitee`,{label:`Gitee`,description:`Gitee 访问令牌`,placeholder:`请输入 Gitee 访问令牌`,defaultValue:c.token.gitee,isClearable:!0,isRequired:!1}),h.input.string(`gitcode`,{label:`GitCode`,description:`GitCode 访问令牌`,placeholder:`请输入 GitCode 访问令牌`,defaultValue:c.token.gitcode,isClearable:!0,isRequired:!1}),h.input.string(`cnbcool`,{label:`CnbCool`,description:`CnbCool 访问令牌`,placeholder:`请输入 CnbCool 访问令牌`,defaultValue:c.token.cnbcool,isClearable:!0,isRequired:!1})]})]}),h.accordion.create(`proxy`,{label:`代理配置`,children:[h.accordion.createItem(`config:proxy`,{title:`代理相关`,subtitle:`此处用于网络访问请求`,children:[h.input.string(`proxy`,{label:`系统代理`,description:`系统代理`,placeholder:`请输入系统代理`,defaultValue:c.proxy.proxy,isClearable:!0,isRequired:!1}),h.input.string(`reverseProxy`,{label:`反向代理`,description:`反向代理`,placeholder:`请输入反向代理`,defaultValue:c.proxy.reverseProxy,isClearable:!0,isRequired:!1})]})]}),h.divider.create(`divider-2`,{description:`平台配置`,descPosition:50}),...p(await v(u.GitHub)),...d(await v(u.Gitee)),...f(await v(u.GitCode)),...m(await v(u.CnbCool))],save:async e=>{console.log(`config`,e);let t=e.token[0],n=e.proxy[0];c.Modify(`proxy`,`proxy`,n.proxy),c.Modify(`proxy`,`reverseProxy`,n.reverseProxy);{c.Modify(`token`,`github`,t.github);let n=u.GitHub,r=e.github[0],i=e[`pushlist:github`],a=_(i,await v(n),y),o=_(await v(n),i,y);await b(a,n),await x(o,n),c.Modify(`github`,`cron`,r.cron)}{c.Modify(`token`,`gitee`,t.gitee);let n=e.gitee[0],r=u.GitHub;c.Modify(`gitee`,`cron`,n.cron);let i=e[`pushlist:gitee`],a=_(i,await v(r),y),o=_(await v(r),i,y);await b(a,r),await x(o,r)}{c.Modify(`token`,`gitcode`,t.gitcode);let n=e.gitcode[0],r=u.GitCode,i=e[`pushlist:gitcode`];c.Modify(`gitcode`,`cron`,n.cron);let a=_(i,await v(r),y),o=_(await v(r),i,y);await b(a,r),await x(o,r)}{c.Modify(`token`,`cnbcool`,t.cnbcool);let n=e.cnbcool[0],r=u.CnbCool,i=e[`pushlist:cnbcool`],a=_(i,await v(r),y),o=_(await v(r),i,y);await b(a,r),await x(o,r),c.Modify(`cnbcool`,`cron`,n.cron)}return{success:!0,message:`保存成功 Ciallo~(∠・ω< )⌒☆`}}});export{S as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candriajs/karin-plugin-git",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "一个karin的git平台仓库订阅推送",
5
5
  "keywords": [
6
6
  "karin-plugin",
@@ -14,7 +14,7 @@
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/CandriaJS/karin-plugin-git.git"
16
16
  },
17
- "license": "GNU General Public License v3.0",
17
+ "license": "GPL-3.0-or-later",
18
18
  "author": "CandriaJS",
19
19
  "type": "module",
20
20
  "main": "lib/index.js",
@@ -38,28 +38,9 @@
38
38
  "watch": "cross-env EBV_FILE=\"development.env\" tsx watch --include \"src/**/*.ts\" src/app.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@mdit/plugin-tasklist": "^0.22.2",
42
- "dayjs": "^1.11.19",
43
- "es-toolkit": "^1.41.0",
44
- "markdown-it": "^14.1.0",
45
- "markdown-it-emoji": "^3.0.0",
46
- "nipaw": "npm:@puniyu/nipaw@^1.8.0"
47
- },
48
- "devDependencies": {
49
- "@karinjs/plugin-puppeteer": "^1.0.21",
50
- "@prettier/plugin-oxc": "^0.0.4",
51
- "@types/express": "^5.0.5",
52
- "@types/markdown-it": "^14.1.2",
53
- "@types/markdown-it-emoji": "^3.0.1",
54
- "@types/node": "^22.15.3",
55
- "cross-env": "^7.0.3",
56
- "node-karin": "^1.12.2",
57
- "oxlint": "^1.26.0",
58
- "prettier": "^3.6.2",
59
- "tsc-alias": "1.8.13",
60
- "tsdown": "^0.15.12",
61
- "tsx": "^4.19.4",
62
- "typescript": "^5.8.3"
41
+ "@puniyu/component": "^0.6.0",
42
+ "es-toolkit": "^1.44.0",
43
+ "nipaw": "npm:@puniyu/nipaw@^1.9.5"
63
44
  },
64
45
  "karin": {
65
46
  "main": "src/index.ts",
@@ -82,6 +63,5 @@
82
63
  "engines": {
83
64
  "karin": ">=1.9.1"
84
65
  }
85
- },
86
- "packageManager": "pnpm@10.14.0"
66
+ }
87
67
  }
Binary file
package/lib/apps/issue.js DELETED
@@ -1 +0,0 @@
1
- import"../root-C9I_RrRd.js";import{d as e,l as t,o as n,r,s as i}from"../db-DZFBXSmG.js";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"../common-Df1uHYOv.js";import{n as p,t as m}from"../types-7HeFLBYV.js";import h,{common as g,contactGroup as _,getBot as v,logger as y}from"node-karin";import{isEmpty as b}from"es-toolkit/compat";const x=h.task(`karin-plugin-git:issue:github`,o.github.cron||`0 */5 * * * *`,async()=>{let{token:e}=o.github;if(b(e))return y.warn(`未配置GitHub Token, 跳过任务`);try{await T(l(),p.GitHub)}catch(e){y.error(e)}}),S=h.task(`karin-plugin-git:issue:gitee`,o.gitee.cron||`0 */5 * * * *`,async()=>{let{token:e}=o.gitee;if(b(e))return y.warn(`未配置Gitee Token, 跳过任务`);try{await T(a(),p.Gitee)}catch(e){y.error(e)}}),C=h.task(`karin-plugin-git:issue:gitcode`,o.gitcode.cron||`0 */5 * * * *`,async()=>{let{token:e}=o.gitcode;if(b(e))return y.warn(`未配置GitCode Token, 跳过任务`);try{await T(s(),p.GitCode)}catch(e){y.error(e)}}),w=h.task(`karin-plugin-git:issue:cnb`,o.cnb.cron||`0 */5 * * * *`,async()=>{let{token:e}=o.cnb;if(b(e))return y.warn(`未配置CnbCool Token, 跳过任务`);try{await T(u(),p.Cnb)}catch(e){y.error(e)}}),T=async(a,o)=>{let s=await r(o,m.Push),l=new Map;for(let r of s){let o=await e(r.repoId);if(!o)continue;let s=`${o.groupId}-${o.botId}`,u=await a.getIssueList(o.owner,o.repo,{perPage:100});l.has(s)||l.set(s,[]);for(let e of u){let a=await i(r.id,e.number);a||=(await n(r.id,e.number,c(e.title),e.body?c(e.body):null,e.state),l.get(s).push({owner:o.owner,repo:o.repo,title:await d.markdown(e.title),body:e.body?await d.markdown(e.body):null,user:e.user,state:e.state,issueDate:f(e.createdAt)}),await i(r.id,e.number)),a&&(a.state!==e.state||a.title!==c(e.title)||a.body!==(e.body?c(e.body):null))&&(l.get(s).push({owner:o.owner,repo:o.repo,title:await d.markdown(e.title),body:e.body?await d.markdown(e.body):null,user:e.user,state:e.state,issueDate:f(e.createdAt)}),await t(r.id,e.number,e.state))}}for(let[e,t]of l){let[n,r]=e.split(`-`),i=t.map(async e=>await d.render(`issue/index`,{issue:e})),a=(await Promise.allSettled(i)).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value);a.length>0&&await E(r,n,a)}l.clear()},E=async(e,t,n)=>{let r=v(e),i=await _(t);if(n.length>1){let t=await g.makeForward(n,e,r?.account.name);await r?.sendForwardMsg(i,t,{source:`议题推送合集`,summary:`查看${t.length}张议题推送消息`,prompt:`议题推送结果`,news:[{text:`点击查看议题推送结果`}]})}else await r?.sendMsg(i,n)};export{w as cnb,C as gitcode,S as gitee,x as github};
@@ -1 +0,0 @@
1
- import{t as e}from"./root-C9I_RrRd.js";import t,{YamlEditor as n,copyConfigSync as r,filesByExt as i,getFiles as a,karinPathBase as o,requireFileSync as s,segment as c,watch as l}from"node-karin";import u from"node:path";import{full as d}from"markdown-it-emoji";import{tasklist as f}from"@mdit/plugin-tasklist";import p from"markdown-it";import{isEmpty as m}from"es-toolkit/compat";import{CnbClient as h,GitCodeClient as g,GiteeClient as _,GithubClient as v}from"nipaw";import y from"dayjs";import b from"dayjs/plugin/relativeTime.js";import"dayjs/locale/zh-cn.js";import x from"node:crypto";var S=class{dirCfgPath;defCfgPath;constructor(){this.dirCfgPath=`${o}/${e.Plugin_Name}/config/`,this.defCfgPath=`${e.Plugin_Path}/config/defSet/`}initCfg(){r(this.defCfgPath,this.dirCfgPath);let e=i(this.dirCfgPath,`.yaml`,`name`);for(let t of e){let e=new n(`${this.dirCfgPath}/${t}`),r=new n(`${this.defCfgPath}/${t}`),{differences:i,result:a}=this.mergeObjectsWithPriority(e,r);i&&a.save()}return i(this.dirCfgPath,`.yaml`,`abs`).forEach(e=>l(e,(e,t)=>{})),this}getDefOrConfig(e){let t=this.getYaml(`defSet`,e),n=this.getYaml(`config`,e);return{...t,...n}}All(){let e={};return a(this.defCfgPath,[`.yaml`]).forEach(t=>{let n=u.basename(t,`.yaml`);e[n]=this.getDefOrConfig(n)??{}}),e}getYaml(e,t){return s(e===`config`?`${this.dirCfgPath}/${t}.yaml`:`${this.defCfgPath}/${t}.yaml`,{force:!0})}Modify(e,t,r,i=`config`){let a=new n(i===`config`?`${this.dirCfgPath}/${e}.yaml`:`${this.defCfgPath}/${e}.yaml`);a.set(t,r),a.save()}mergeObjectsWithPriority(e,t){let n=!1;return((t,r)=>{let i=r.get(t),a=e.get(t);if(typeof a==`object`&&typeof i==`object`)for(let r in i)r in a||(n=!0,e.set(`${t?`${t}.`:``}${r}`,i[r]))})(``,t),{differences:n,result:e}}};const C=new Proxy(Object.assign(new S().initCfg(),{}),{get(e,t){return t in e?Reflect.get(e,t):e.getDefOrConfig(t)}});function w(e=1){return e*=1.5,`style=transform:scale(${e})`}const T={async render(n,r={}){n=n.replace(/.html$/,``);let i=`${e.Plugin_Path}/resources`,a=await t.render({type:`jpeg`,encoding:`base64`,name:u.basename(n),file:`${i}/${n}.html`,data:{_res_path:`${e.Plugin_Path}/resources`.replace(/\\/g,`/`),defaultLayout:`${e.Plugin_Path}/resources/common/layout/default.html`.replace(/\\/g,`/`),sys:{scale:w(r.scale??1)},copyright:`${e.Bot_Name}<span class="version"> ${e.Bot_Version}</span> & ${e.Plugin_Name}<span class="version"> ${e.Plugin_Version}`,...r},screensEval:`#containter`,multiPage:12e3,pageGotoParams:{waitUntil:`networkidle0`,timeout:6e4}});return c.image(`${a.includes(`base64://`)?a:`base64://${a}`}`)},async markdown(e){let t=new p({html:!0,breaks:!0});return t.use(d),t.use(f),t.renderer.rules.bullet_list_open=()=>`<ul style="list-style: none;">`,Promise.resolve(t.render(e))}},E=()=>{let e=new v;return m(C.github.reverseProxy)?m(C.github.proxy)||e.setProxy(C.github.proxy):e.setReverseProxy(C.github.reverseProxy),m(C.github.token)||e.setToken(C.github.token),e},D=()=>{let e=new _;return m(C.gitee.proxy)||e.setProxy(C.gitee.proxy),m(C.gitee.token)||e.setToken(C.gitee.token),e},O=()=>{let e=new g;return m(C.gitcode.proxy)||e.setProxy(C.gitcode.proxy),m(C.gitcode.token)||e.setToken(C.gitcode.token),e},k=()=>{let e=new h;return m(C.cnb.proxy)||e.setProxy(C.cnb.proxy),m(C.cnb.token)||e.setToken(C.cnb.token),e},A=e=>(y.extend(b),y.locale(`zh-cn`),y().diff(e,`month`)>3?y(e).format(`YYYY-MM-DD HH:mm`):y(e).fromNow()),j=e=>{if(typeof e!=`string`)throw TypeError(`Input must be a string`);return x.createHash(`sha256`).update(e,`utf8`).digest(`hex`)};export{D as a,C as c,O as i,j as n,E as o,k as r,T as s,A as t};
@@ -1,44 +0,0 @@
1
- import{t as e}from"./root-C9I_RrRd.js";import{karinPathBase as t}from"node-karin";import n from"node-karin/sqlite3";async function r(e,t){await(await v()).run(`INSERT INTO push (eventId, branch) VALUES (?, ?)`,[e,t])}async function i(e,t){let n=await v();return t==null?await new Promise((t,r)=>{n.all(`SELECT * FROM push WHERE eventId = ?`,[e],(e,n)=>{e?r(e):t(n)})}):await new Promise((r,i)=>{n.get(`SELECT * FROM push WHERE eventId = ? AND branch = ?`,[e,t],(e,t)=>{e?i(e):r(t)})})}async function a(e,t){let n=await v();t?await new Promise((r,i)=>{n.run(`DELETE FROM push WHERE eventId = ? AND branch = ?`,[e,t],e=>{e?i(e):r()})}):await new Promise((t,r)=>{n.run(`DELETE FROM push WHERE eventId = ?`,[e],e=>{e?r(e):t()})})}async function o(e,t,n){await(await v()).run(`UPDATE push SET commitSha = ? WHERE eventId = ? AND branch = ?`,[n,e,t])}async function s(e,t,n,r){await(await v()).run(`INSERT INTO repo (owner, repo, botId, groupId) VALUES (?, ?, ?, ?)`,[n,r,e,t])}async function c(...e){let t=await v();if(e.length===1){let[n]=e;return await new Promise((e,r)=>{t.get(`SELECT * FROM repo WHERE id = ?`,[n],(t,n)=>{t?r(t):e(n)})})}else{let[n,r,i,a]=e;return await new Promise((e,o)=>{t.get(`SELECT * FROM repo WHERE owner = ? AND repo = ? AND botId = ? AND groupId = ?`,[i,a,n,r],(t,n)=>{t?o(t):e(n)})})}}async function l(e,t,n,r,i){let a=await v();t!==void 0&&n!==void 0&&r!==void 0&&i!==void 0?await a.run(`INSERT INTO issue (eventId, issueId, title, body, state) VALUES (?, ?, ?, ?, ?)`,[e,t,n,r,i]):await a.run(`INSERT INTO issue (eventId) VALUES (?)`,[e])}async function u(e,t){let n=await v();return t==null?await new Promise((t,r)=>{n.all(`SELECT * FROM issue WHERE eventId = ?`,[e],(e,n)=>{e?r(e):t(n)})}):await new Promise((r,i)=>{n.get(`SELECT * FROM issue WHERE eventId = ? AND issueId = ?`,[e,t],(e,t)=>{e?i(e):r(t)})})}async function d(e,t){let n=await v();t==null?await new Promise((t,r)=>{n.run(`DELETE FROM issue WHERE eventId = ?`,[e],e=>{e?r(e):t()})}):await new Promise((r,i)=>{n.run(`DELETE FROM issue WHERE eventId = ? AND issueId = ?`,[e,t],e=>{e?i(e):r()})})}async function f(e,t,n){let r=await v();await new Promise((i,a)=>{r.run(`UPDATE issue SET state = ? WHERE eventId = ? AND issueId = ?`,[n,e,t],e=>{e?a(e):i()})})}async function p(e,t,n){let r=await v(),i=n.join(`,`);await r.run(`INSERT INTO event (platform,repoId, eventType) VALUES (?, ?, ?)`,[e,t,i])}async function m(e,t){let n=await v(),r=`SELECT * FROM event`,i=[];e===void 0?t!==void 0&&(r+=` WHERE eventType = ?`,i.push(t)):(r+=` WHERE platform = ?`,i.push(e),t!==void 0&&(r+=` AND eventType = ?`,i.push(t)));let a=await new Promise((e,t)=>{n.all(r,i,(n,r)=>{n?t(n):e(r)})});return a.forEach(e=>{e.eventType=e.eventType.split(`,`)}),a}async function h(e,t,n){let r=await v();if(n){let i=await new Promise((n,i)=>{r.all(`SELECT * FROM event WHERE platform = ? AND repoId = ?`,[e,t],(e,t)=>{e?i(e):n(t)})});if(i&&i.length>0){let e=Array.isArray(n)?n:[n],t=i.filter(t=>{let n=t.eventType.split(`,`);return e.some(e=>n.includes(e))});return t.forEach(e=>{e.eventType=e.eventType.split(`,`)}),t.length>0?t[0]:null}return null}else{let n=await new Promise((n,i)=>{r.all(`SELECT * FROM event WHERE platform = ? AND repoId = ?`,[e,t],(e,t)=>{e?i(e):n(t)})});return n&&n.forEach(e=>{e.eventType=e.eventType.split(`,`)}),n}}async function g(e,t,n){let r=await v(),i=n.join(`,`);await new Promise((n,a)=>{r.run(`UPDATE event SET eventType = ? WHERE platform = ? AND repoId = ?`,[i,e,t],e=>{e?a(e):n()})})}let _=null;const v=async()=>{if(!_){let r=`${t}/${e.Plugin_Name}/data`;_=new n.Database(`${r}/data.db`)}return _},y=async()=>{let e=await v();e.exec(`
2
- CREATE TABLE IF NOT EXISTS repo (
3
- id INTEGER PRIMARY KEY AUTOINCREMENT,
4
- owner TEXT NOT NULL,
5
- repo TEXT NOT NULL,
6
- botId TEXT NOT NULL,
7
- groupId TEXT NOT NULL,
8
- createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
9
- updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
10
- UNIQUE(owner, repo, botId, groupId)
11
- )
12
- `),e.exec(`
13
- CREATE TABLE IF NOT EXISTS event (
14
- id INTEGER PRIMARY KEY AUTOINCREMENT,
15
- repoId INTEGER NOT NULL,
16
- platform TEXT NOT NULL,
17
- eventType TEXT NOT NULL,
18
- createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
19
- updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
20
- FOREIGN KEY (repoId) REFERENCES repo(id) ON DELETE CASCADE
21
- )
22
- `),e.exec(`
23
- CREATE TABLE IF NOT EXISTS push (
24
- id INTEGER PRIMARY KEY AUTOINCREMENT,
25
- eventId INTEGER NOT NULL,
26
- branch TEXT NOT NULL,
27
- commitSha TEXT,
28
- createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
29
- updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
30
- FOREIGN KEY (eventId) REFERENCES event(id) ON DELETE CASCADE
31
- )
32
- `),e.exec(`
33
- CREATE TABLE IF NOT EXISTS issue (
34
- id INTEGER PRIMARY KEY AUTOINCREMENT,
35
- eventId INTEGER NOT NULL,
36
- issueId TEXT NOT NULL,
37
- title TEXT,
38
- body TEXT,
39
- state TEXT,
40
- createdAt DATETIME DEFAULT (datetime('now', 'localtime')),
41
- updatedAt DATETIME DEFAULT (datetime('now', 'localtime')),
42
- FOREIGN KEY (eventId) REFERENCES event(id) ON DELETE CASCADE
43
- )
44
- `),e.exec(`CREATE INDEX IF NOT EXISTS idx_repo_lookup ON repo(botId, groupId)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_push_event ON push(eventId)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_issue_event ON issue(eventId)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_event_repo ON event(repoId)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_event_platform ON event(platform)`),e.exec(`CREATE INDEX IF NOT EXISTS idx_event_type ON event(eventType)`)};export{g as a,d as c,c as d,r as f,o as h,h as i,f as l,a as m,p as n,l as o,i as p,m as r,u as s,y as t,s as u};
@@ -1 +0,0 @@
1
- let e=function(e){return e.GitHub=`github`,e.Gitee=`gitee`,e.GitCode=`gitcode`,e.Cnb=`cnb`,e}({}),t=function(e){return e.Push=`push`,e.Issue=`issue`,e}({});export{e as n,t};
@@ -1,293 +0,0 @@
1
- @font-face {
2
- font-family: 'Noto Color Emoji';
3
- src: url('../fonts/NotoColorEmoji-Regular.woff2') format('woff2');
4
- }
5
-
6
- @font-face {
7
- font-family: 'Smiley Sans';
8
- src: url('../fonts/SmileySans-Oblique.woff2') format('woff2');
9
- font-display: swap;
10
- }
11
-
12
- @font-face {
13
- font-family: 'Douyin Sans';
14
- src: url('../fonts/DouyinSansBold.woff2') format('woff2');
15
- font-display: swap;
16
- }
17
-
18
- * {
19
- margin: 0;
20
- padding: 0;
21
- box-sizing: border-box;
22
- }
23
-
24
- .container {
25
- font-family: 'Douyin Sans', 'Smiley Sans', 'Noto Color Emoji', sans-serif;
26
- display: flex;
27
- justify-content: center;
28
- align-items: flex-start;
29
- min-height: 100vh;
30
- min-width: 800px;
31
- width: 100%;
32
- padding: 20px;
33
- background: rgba(200, 200, 200, 0.85);
34
- }
35
-
36
- .info-section {
37
- display: flex;
38
- flex-direction: column;
39
- width: 100%;
40
- max-width: 800px;
41
- padding: 50px;
42
- margin: 0 auto;
43
- }
44
-
45
- .platform-name {
46
- display: flex;
47
- align-items: center;
48
- justify-content: center;
49
- gap: 12px;
50
- margin-bottom: 32px;
51
- color: #4b5563;
52
- }
53
-
54
- .header h2 {
55
- font-size: 32px;
56
- font-weight: 700;
57
- letter-spacing: -0.5px;
58
- }
59
-
60
- .commit-card {
61
- width: 100%;
62
- background: rgba(248, 250, 255, 0.8);
63
- border: 1px solid rgba(255, 255, 255, 0.4);
64
- border-radius: 16px;
65
- padding: 24px;
66
- margin-bottom: 24px;
67
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
68
- }
69
-
70
- .repo-header {
71
- display: flex;
72
- align-items: center;
73
- gap: 16px;
74
- width: 100%;
75
- margin-bottom: 20px;
76
- }
77
-
78
- .repo-info {
79
- display: flex;
80
- flex-direction: column;
81
- gap: 8px;
82
- }
83
-
84
- .platform-icon img {
85
- width: 50px;
86
- height: 50px;
87
- padding-left: 5px;
88
- }
89
-
90
- .repo-name {
91
- font-size: 25px;
92
- font-weight: 800;
93
- color: #0f0f23;
94
- letter-spacing: -0.3px;
95
- }
96
-
97
- .commit-sha-info {
98
- display: flex;
99
- align-items: center;
100
- gap: 6px;
101
- color: #666;
102
- background: rgba(158, 158, 158, 0.2);
103
- border-radius: 15px;
104
- font-size: 14px;
105
- padding: 5px 10px;
106
- }
107
-
108
- .commit-sha-info img {
109
- width: 24px;
110
- height: 24px;
111
- opacity: 0.7;
112
- }
113
-
114
- .branch-info {
115
- display: flex;
116
- align-items: center;
117
- gap: 6px;
118
- color: #666;
119
- font-size: 14px;
120
- background: rgba(158, 158, 158, 0.2);
121
- padding: 5px 15px;
122
- border-radius: 20px;
123
- white-space: nowrap;
124
- margin-left: auto;
125
- }
126
-
127
- .commit-info {
128
- background: rgba(59, 130, 246, 0.1);
129
- border: 1px solid rgba(59, 130, 246, 0.2);
130
- border-radius: 12px;
131
- padding: 16px;
132
- margin-top: 16px;
133
- display: flex;
134
- align-items: flex-start;
135
- gap: 12px;
136
- flex-direction: column;
137
- overflow: hidden;
138
- backdrop-filter: blur(10px);
139
- }
140
-
141
- .avatar-info {
142
- display: flex;
143
- align-items: center;
144
- gap: 8px;
145
- flex-wrap: wrap;
146
- width: 100%;
147
- }
148
-
149
- .avatar-group {
150
- display: flex;
151
- position: relative;
152
- margin-right: 8px;
153
- flex-shrink: 0;
154
- }
155
-
156
- .author-avatar img,
157
- .committer-avatar img {
158
- width: 40px;
159
- height: 40px;
160
- border-radius: 50%;
161
- border: 3px solid rgba(255, 255, 255, 0.9);
162
- object-fit: cover;
163
- background-color: #fff;
164
- display: block;
165
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
166
- }
167
-
168
- .dual-avatars {
169
- display: flex;
170
- position: relative;
171
- margin-right: 10px;
172
- position: relative;
173
- }
174
-
175
- .author-info > span {
176
- white-space: nowrap;
177
- overflow: hidden;
178
- text-overflow: ellipsis;
179
- color: #2d3748;
180
- font-size: 14px;
181
- }
182
-
183
- .committer-avatar {
184
- margin-left: -14px;
185
- z-index: 1;
186
- }
187
-
188
- .author-info .author-avatar img {
189
- border: 3px solid rgba(255, 255, 255, 0.9);
190
- }
191
-
192
- .time-info {
193
- color: #718096;
194
- background: rgba(158, 158, 158, 0.2);
195
- font-size: 13px;
196
- margin-left: auto;
197
- white-space: nowrap;
198
- flex-shrink: 0;
199
- padding: 6px 12px;
200
- border-radius: 15px;
201
- text-align: right;
202
- }
203
-
204
- .commit-icon img {
205
- width: 24px;
206
- height: 24px;
207
- filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
208
- }
209
-
210
- .commit-message {
211
- margin-top: 16px;
212
- background: rgba(34, 197, 94, 0.08);
213
- border-left: 4px solid #22c55e;
214
- border-radius: 12px;
215
- padding: 18px;
216
- backdrop-filter: blur(10px);
217
- border: 1px solid rgba(34, 197, 94, 0.2);
218
- }
219
-
220
- .commit-title {
221
- display: flex;
222
- align-items: center;
223
- gap: 12px;
224
- min-width: 0;
225
- width: 100%;
226
- color: #1f2937;
227
- font-size: 15px;
228
- font-weight: 600;
229
- }
230
-
231
- .commit-title > span:first-child {
232
- flex: 1 1 auto;
233
- min-width: 0;
234
- width: auto;
235
- text-overflow: ellipsis;
236
- padding-right: 16px;
237
- word-break: break-word;
238
- color: #0f0f23;
239
- }
240
-
241
- .code-changes {
242
- display: flex;
243
- align-items: center;
244
- flex-shrink: 0;
245
- gap: 12px;
246
- margin-left: auto;
247
- padding-left: 16px;
248
- white-space: nowrap;
249
- background: rgba(255, 255, 255, 0.5);
250
- padding: 8px 12px;
251
- border-radius: 8px;
252
- font-size: 13px;
253
- }
254
-
255
- .code-changes span {
256
- font-size: 14px;
257
- line-height: 1.5;
258
- font-weight: 600;
259
- }
260
-
261
- .changes-added {
262
- color: #16a34a;
263
- }
264
-
265
- .changes-deleted {
266
- color: #dc2626;
267
- }
268
-
269
- .changes-divider {
270
- color: #cbd5e1;
271
- }
272
-
273
- .commit-icon {
274
- display: inline-flex;
275
- flex-shrink: 0;
276
- }
277
-
278
- .commit-divider {
279
- height: 1px;
280
- background: rgba(0, 0, 0, 0.2);
281
- width: 100%;
282
- margin-top: 12px;
283
- margin-bottom: 12px;
284
- }
285
-
286
- .commit-content {
287
- padding-left: 0;
288
- padding-top: 8px;
289
- white-space: pre-line;
290
- color: #4b5563;
291
- font-size: 14px;
292
- line-height: 1.6;
293
- }
@@ -1,123 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <link
7
- href="{{_res_path}}/commit/index.css"
8
- rel="stylesheet"
9
- type="text/css"
10
- />
11
- </head>
12
-
13
- <body>
14
- <div class="container" id="container">
15
- <div class="info-section">
16
- <div class="platform-name">
17
- {{if platform === 'github'}}
18
- <h2>GitHub 仓库更新推送</h2>
19
- {{else if platform === 'gitee'}}
20
- <h2>Gitee 仓库更新推送</h2>
21
- {{else if platform === 'gitcode'}}
22
- <h2>GitCode 仓库更新推送</h2>
23
- {{else if platform === 'cnb'}}
24
- <h2>Cnb 仓库更新推送</h2>
25
- {{else}}
26
- <h2>GitHub 仓库更新推送</h2>
27
- {{/if}}
28
- </div>
29
-
30
- <div class="commit-card">
31
- <div class="repo-header">
32
- <div class="platform-icon">
33
- {{if platform === 'github'}}
34
- <img src="{{_res_path}}/icons/github.svg" alt="GitHub Logo" />
35
- {{else if platform === 'gitee'}}
36
- <img src="{{_res_path}}/icons/gitee.svg" alt="Gitee Logo" />
37
- {{else if platform === 'gitcode'}}
38
- <img src="{{_res_path}}/icons/gitcode.svg" alt="Gitcode Logo" />
39
- {{else if platform === 'gitcode'}}
40
- <img src="{{_res_path}}/icons/cnb.svg" alt="Cnb Logo" />
41
- {{else}}
42
- <img src="{{_res_path}}/icons/github.svg" alt="GitHub Logo" />
43
- {{/if}}
44
- </div>
45
- <div class="repo-info">
46
- <div class="repo-name">{{commit.owner}}/{{commit.repo}}</div>
47
- <div class="commit-sha-info">
48
- <div class="commit-sha-icon">
49
- <img src="{{_res_path}}/icons/commit.svg" alt="Commit Icon" />
50
- </div>
51
- <span class="commit-sha">{{ commit.sha }}</span>
52
- </div>
53
- </div>
54
- <div class="branch-info">
55
- <div class="branch-icon">
56
- <img src="{{_res_path}}/icons/branch.svg" alt="Branch Icon" />
57
- </div>
58
- <span class="branch-name">{{ commit.branch }}</span>
59
- </div>
60
- </div>
61
-
62
- <div class="commit-info">
63
- <div class="avatar-info">
64
- {{if commit.commit.author.name === commit.commit.committer.name }}
65
- <div class="author-avatar">
66
- <img
67
- src="{{ commit.commit.author.avatarUrl }}"
68
- alt="Author Avatar"
69
- />
70
- </div>
71
- <span>由 {{ commit.commit.author.name }} 提交</span>
72
- <span class="time-info">{{ commit.commitDate }}</span>
73
- {{else}}
74
- <div class="avatar-group">
75
- <div class="author-avatar">
76
- <img
77
- src="{{ commit.commit.author.avatarUrl }}"
78
- alt="Author Avatar"
79
- title="作者"
80
- />
81
- </div>
82
- <div class="committer-avatar">
83
- <img
84
- src="{{ commit.commit.committer.avatarUrl }}"
85
- alt="Committer Avatar"
86
- title="提交者"
87
- />
88
- </div>
89
- </div>
90
- <span
91
- >由 {{ commit.commit.author.name }} 编写,并由 {{
92
- commit.commit.committer.name }} 提交</span
93
- >
94
- <span class="time-info">{{ commit.commitDate }}</span>
95
- {{/if}}
96
- </div>
97
- </div>
98
-
99
- <div class="commit-message">
100
- <div class="commit-title">
101
- <div class="commit-icon">
102
- <img src="{{_res_path}}/icons/commit.svg" alt="Commit Icon" />
103
- </div>
104
- <span>{{@commit.title}}</span>
105
- <div class="code-changes">
106
- <span class="changes-added">+{{ commit.stats.additions }}</span>
107
- <span class="changes-deleted"
108
- >-{{ commit.stats.deletions }}</span
109
- >
110
- <span class="changes-divider">•</span>
111
- <span>{{ commit.changeFiles }} 个文件被更改</span>
112
- </div>
113
- </div>
114
- <div class="commit-divider"></div>
115
- {{if commit.body }}
116
- <div class="commit-content">{{@commit.body}}</div>
117
- {{/if}}
118
- </div>
119
- </div>
120
- </div>
121
- </div>
122
- </body>
123
- </html>