├── insight-front-end ├── src │ ├── containers │ │ ├── App.less │ │ ├── Home │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── Login │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── Register │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── App.js │ │ └── NotMatch │ │ │ └── index.js │ ├── components │ │ ├── Log │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── Tab │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── RobotForm │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── RobotInfo │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── Robot │ │ │ ├── index.less │ │ │ └── index.js │ │ ├── TaskForm │ │ │ ├── index.less │ │ │ ├── MsgText.js │ │ │ ├── MsgMarkdown.js │ │ │ ├── MsgImage.js │ │ │ ├── MsgNews.js │ │ │ ├── Timing.js │ │ │ └── index.js │ │ ├── index.js │ │ ├── PermissionForm │ │ │ ├── index.less │ │ │ └── index.js │ │ └── Task │ │ │ ├── index.less │ │ │ └── index.js │ ├── utils │ │ ├── index.js │ │ └── CommonUtil.js │ ├── images │ │ ├── add.png │ │ ├── logo.png │ │ ├── s-on.gif │ │ ├── robot.png │ │ ├── s-off.gif │ │ ├── logo-ico.png │ │ ├── s-loading.gif │ │ ├── insight-black.png │ │ └── mars-texture.jpg │ ├── setupProxy.js │ ├── stores │ │ ├── index.js │ │ ├── LogStore.js │ │ ├── CommonStore.js │ │ ├── PermissionStore.js │ │ ├── RobotStore.js │ │ └── TaskStore.js │ ├── services │ │ ├── index.js │ │ ├── LogService.js │ │ ├── UserService.js │ │ ├── PermissionService.js │ │ ├── RobotService.js │ │ └── TaskService.js │ ├── less │ │ ├── variables.less │ │ ├── overrides.less │ │ ├── glitch.less │ │ ├── public.less │ │ └── component.less │ ├── index.js │ ├── dataProxy.js │ └── routes.js ├── env │ ├── .env.development │ └── .env.production ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── manifest.json │ └── index.html ├── README.md ├── .gitignore ├── config-overrides.js ├── .eslintrc.json └── package.json ├── insight-back-end ├── tslint.json ├── config │ ├── config.local.ts │ ├── plugin.ts │ ├── config.prod.ts │ └── config.default.ts ├── typings │ ├── app │ │ ├── index.d.ts │ │ ├── middleware │ │ │ └── index.d.ts │ │ ├── controller │ │ │ └── index.d.ts │ │ └── service │ │ │ └── index.d.ts │ ├── config │ │ ├── index.d.ts │ │ └── plugin.d.ts │ └── typeorm.d.ts ├── app │ ├── middleware │ │ ├── authLogin.ts │ │ └── authPermission.ts │ ├── service │ │ ├── Suite.ts │ │ ├── Msg.ts │ │ ├── Util.ts │ │ ├── Permission.ts │ │ ├── Cron.ts │ │ └── Workday.ts │ ├── controller │ │ ├── log.ts │ │ ├── user.ts │ │ ├── permission.ts │ │ ├── task.ts │ │ └── robot.ts │ ├── entity │ │ ├── User.ts │ │ ├── Permission.ts │ │ ├── Robot.ts │ │ ├── Log.ts │ │ └── Task.ts │ └── router.ts ├── .gitignore ├── .editorconfig ├── README.md ├── app.js ├── .autod.conf.js ├── tsconfig.json └── package.json ├── example ├── insight-cron.png └── insight-datapicker.png ├── CHANGELOG.md ├── package.json ├── .gitignore ├── README.md └── LICENSE /insight-front-end/src/containers/App.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/components/Log/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/components/Tab/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/containers/Home/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/env/.env.development: -------------------------------------------------------------------------------- 1 | REACT_APP_URL= -------------------------------------------------------------------------------- /insight-front-end/env/.env.production: -------------------------------------------------------------------------------- 1 | REACT_APP_URL= -------------------------------------------------------------------------------- /insight-front-end/src/components/RobotForm/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/components/RobotInfo/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/containers/Login/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/containers/Register/index.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /insight-front-end/src/components/Robot/index.less: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /insight-back-end/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint-config-egg"] 3 | } 4 | -------------------------------------------------------------------------------- /example/insight-cron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/example/insight-cron.png -------------------------------------------------------------------------------- /insight-front-end/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /example/insight-datapicker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/example/insight-datapicker.png -------------------------------------------------------------------------------- /insight-front-end/src/utils/index.js: -------------------------------------------------------------------------------- 1 | 2 | import CommonUtil from './CommonUtil'; 3 | 4 | export { CommonUtil }; 5 | -------------------------------------------------------------------------------- /insight-front-end/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/public/favicon.ico -------------------------------------------------------------------------------- /insight-front-end/src/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/add.png -------------------------------------------------------------------------------- /insight-front-end/src/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/logo.png -------------------------------------------------------------------------------- /insight-front-end/src/images/s-on.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/s-on.gif -------------------------------------------------------------------------------- /insight-front-end/src/images/robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/robot.png -------------------------------------------------------------------------------- /insight-front-end/src/images/s-off.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/s-off.gif -------------------------------------------------------------------------------- /insight-front-end/src/images/logo-ico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/logo-ico.png -------------------------------------------------------------------------------- /insight-front-end/src/images/s-loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/s-loading.gif -------------------------------------------------------------------------------- /insight-front-end/src/images/insight-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/insight-black.png -------------------------------------------------------------------------------- /insight-front-end/src/images/mars-texture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elliottssu/insight/HEAD/insight-front-end/src/images/mars-texture.jpg -------------------------------------------------------------------------------- /insight-back-end/config/config.local.ts: -------------------------------------------------------------------------------- 1 | import { EggAppConfig, PowerPartial } from 'egg'; 2 | 3 | export default () => { 4 | const config: PowerPartial = {}; 5 | return config; 6 | }; 7 | -------------------------------------------------------------------------------- /insight-back-end/typings/app/index.d.ts: -------------------------------------------------------------------------------- 1 | // This file is created by egg-ts-helper@1.25.8 2 | // Do not modify this file!!!!!!!!! 3 | 4 | import 'egg'; 5 | export * from 'egg'; 6 | export as namespace Egg; 7 | -------------------------------------------------------------------------------- /insight-front-end/src/containers/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './App.less'; 3 | 4 | export default function App({ children }) { 5 | return ( 6 |
7 |
{children}
8 |
9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /insight-front-end/src/components/TaskForm/index.less: -------------------------------------------------------------------------------- 1 | 2 | .form-area { 3 | background: rgba(59, 63, 81, 0.46); 4 | padding: 20px 0; 5 | border-radius: 4px; 6 | } 7 | .text-green { 8 | color: #7bd47b 9 | } 10 | 11 | .text-red { 12 | color: #d04d4d 13 | } -------------------------------------------------------------------------------- /insight-front-end/README.md: -------------------------------------------------------------------------------- 1 | # insight-front-end Insight前端 2 | 3 | 4 | ### 开发环境 5 | 6 | ```bash 7 | $ npm i 8 | $ npm start 9 | $ open http://localhost:3000/ 10 | ``` 11 | 12 | ### 生产环境 13 | 14 | ```bash 15 | $ npm run build 16 | $ open build # 输出静态资源文件的文件夹 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /insight-front-end/src/components/index.js: -------------------------------------------------------------------------------- 1 | import Robot from './Robot'; 2 | import RobotInfo from './RobotInfo'; 3 | import Task from './Task'; 4 | import TaskForm from './TaskForm'; 5 | import Log from './Log'; 6 | 7 | export { 8 | Robot, RobotInfo, Task, TaskForm, Log, 9 | }; 10 | -------------------------------------------------------------------------------- /insight-front-end/src/components/PermissionForm/index.less: -------------------------------------------------------------------------------- 1 | .wrapper-box { 2 | max-height: 145px; 3 | overflow: auto; 4 | .wrapper-item { 5 | padding: 0px 5px 0px 0; 6 | &:hover { 7 | background-color: rgba(222, 222, 222, 0.05); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /insight-back-end/app/middleware/authLogin.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 登录拦截器 3 | */ 4 | import Util from '../service/Util'; 5 | 6 | module.exports = () => { 7 | return async function authLogin(ctx, next) { 8 | if (Util.getUserId(ctx)) return await next(); 9 | ctx.status = 403; 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /insight-back-end/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | npm-debug.log 3 | node_modules/ 4 | coverage/ 5 | .idea/ 6 | run/ 7 | logs/ 8 | .DS_Store 9 | .vscode 10 | *.swp 11 | *.lock 12 | # *.js 13 | !.autod.conf.js 14 | 15 | app/**/*.js 16 | test/**/*.js 17 | config/**/*.js 18 | app/**/*.map 19 | test/**/*.map 20 | config/**/*.map 21 | -------------------------------------------------------------------------------- /insight-front-end/src/setupProxy.js: -------------------------------------------------------------------------------- 1 | /** 2 | * http代理管理 3 | */ 4 | const proxy = require('http-proxy-middleware'); 5 | 6 | module.exports = function (app) { 7 | app.use( 8 | '/api', 9 | proxy({ 10 | target: 'http://localhost:7001', 11 | changeOrigin: true, 12 | }), 13 | ); 14 | }; 15 | -------------------------------------------------------------------------------- /insight-front-end/src/containers/NotMatch/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default class NotMatch extends React.Component { 4 | constructor() { 5 | super(); 6 | this.state = {}; 7 | } 8 | 9 | render() { 10 | return ( 11 |
404 页面丢了...
12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /insight-back-end/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [makefile] 16 | indent_style = tab 17 | indent_size = 4 18 | -------------------------------------------------------------------------------- /insight-back-end/README.md: -------------------------------------------------------------------------------- 1 | # insight-back-end Insight后端 2 | 3 | ### 开发环境 4 | 5 | ```bash 6 | $ npm i 7 | $ npm run dev 8 | $ open http://localhost:7001/ 9 | ``` 10 | 11 | ### 生产环境-第一次启动 12 | 13 | ```bash 14 | $ npm start 15 | ``` 16 | 17 | ### 生产环境-重新启动 18 | 19 | ```bash 20 | $ npm run stop 21 | $ npm run start 22 | 23 | # 或者 24 | $ npm run restart 25 | ``` 26 | -------------------------------------------------------------------------------- /insight-front-end/src/stores/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mobx store 3 | */ 4 | 5 | import CommonStore from './CommonStore'; 6 | import LogStore from './LogStore'; 7 | import TaskStore from './TaskStore'; 8 | import RobotStore from './RobotStore'; 9 | import PermissionStore from './PermissionStore'; 10 | 11 | export default { 12 | CommonStore, LogStore, TaskStore, RobotStore, PermissionStore, 13 | }; 14 | -------------------------------------------------------------------------------- /insight-front-end/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /insight-front-end/src/services/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * mobx service 3 | */ 4 | 5 | import UserService from './UserService'; 6 | import LogService from './LogService'; 7 | import TaskService from './TaskService'; 8 | import RobotService from './RobotService'; 9 | import PermissionService from './PermissionService'; 10 | 11 | export { 12 | UserService, LogService, TaskService, RobotService, PermissionService, 13 | }; 14 | -------------------------------------------------------------------------------- /insight-front-end/src/less/variables.less: -------------------------------------------------------------------------------- 1 | @white-deep: #d3d3d3; 2 | @white-normal: #b7b7b7; 3 | @white-light: #656773; 4 | 5 | @primary-color: #5783d3; 6 | 7 | 8 | @white: #ffffff; 9 | @grey: #353535; 10 | @dark_grey: #1F2124; 11 | @blue: #2F8BE6; 12 | @green: #1DE9B6; 13 | 14 | //Giphy colors 15 | @giphy_blue: #0cf; 16 | @giphy_pink: #e54cb5; 17 | @giphy_purple: #ac78e0; 18 | @giphy_red: #fc6669; 19 | @giphy_green: #59e4ac; 20 | -------------------------------------------------------------------------------- /insight-back-end/typings/config/index.d.ts: -------------------------------------------------------------------------------- 1 | // This file is created by egg-ts-helper@1.25.8 2 | // Do not modify this file!!!!!!!!! 3 | 4 | import 'egg'; 5 | import { EggAppConfig } from 'egg'; 6 | import ExportConfigDefault from '../../config/config.default'; 7 | type ConfigDefault = ReturnType; 8 | type NewEggAppConfig = ConfigDefault; 9 | declare module 'egg' { 10 | interface EggAppConfig extends NewEggAppConfig { } 11 | } -------------------------------------------------------------------------------- /insight-front-end/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | node_modules 25 | -------------------------------------------------------------------------------- /insight-back-end/config/plugin.ts: -------------------------------------------------------------------------------- 1 | import { EggPlugin } from 'egg'; 2 | 3 | const plugin: EggPlugin = { 4 | healthy: { 5 | enable: true, 6 | package: 'egg-healthy', 7 | env: [ 'prod', 'local' ], 8 | }, 9 | typeorm: { 10 | enable: true, 11 | package: '@forsigner/egg-typeorm', 12 | env: [ 'prod', 'local' ], 13 | }, 14 | cors: { 15 | enable: true, 16 | package: 'egg-cors', 17 | }, 18 | }; 19 | 20 | export default plugin; 21 | -------------------------------------------------------------------------------- /insight-front-end/src/services/LogService.js: -------------------------------------------------------------------------------- 1 | /** 2 | * log service 3 | */ 4 | import dataProxy from '../dataProxy'; 5 | 6 | export default { 7 | // 任务查询 8 | getLog(params) { 9 | return new Promise((resolve, reject) => { 10 | dataProxy.get(`${process.env.REACT_APP_URL}/api/log/getLog`, { params }).then((result) => { 11 | resolve(result); 12 | }).catch((err) => { 13 | reject(err); 14 | }); 15 | }); 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /insight-back-end/app.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | const schedule = require('node-schedule'); 3 | 4 | class AppBootHook { 5 | constructor(app) { 6 | this.app = app; 7 | } 8 | async didReady() { 9 | const ctx = await this.app.createAnonymousContext(); 10 | const n1 = await ctx.service.cron.getTaskAndRun(); 11 | ctx.logger.info(`################################## 定时任务加载完成!, 本次加载 ${n1.length}个任务`); 12 | } 13 | } 14 | 15 | module.exports = AppBootHook; -------------------------------------------------------------------------------- /insight-back-end/typings/app/middleware/index.d.ts: -------------------------------------------------------------------------------- 1 | // This file is created by egg-ts-helper@1.25.8 2 | // Do not modify this file!!!!!!!!! 3 | 4 | import 'egg'; 5 | import ExportAuthLogin from '../../../app/middleware/authLogin'; 6 | import ExportAuthPermission from '../../../app/middleware/authPermission'; 7 | 8 | declare module 'egg' { 9 | interface IMiddleware { 10 | authLogin: typeof ExportAuthLogin; 11 | authPermission: typeof ExportAuthPermission; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /insight-front-end/src/stores/LogStore.js: -------------------------------------------------------------------------------- 1 | /** 2 | * log store 3 | */ 4 | 5 | import { action, observable } from 'mobx'; 6 | import { LogService } from '../services'; 7 | 8 | class LogStore { 9 | @observable logList = []; 10 | 11 | // 获取日志 12 | @action getLogList = (params) => { 13 | LogService.getLog(params).then((result) => { 14 | if (result.data.code !== 0) return; 15 | this.logList = result.data.data; 16 | }); 17 | } 18 | } 19 | 20 | export default new LogStore(); 21 | -------------------------------------------------------------------------------- /insight-back-end/.autod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | write: true, 5 | plugin: 'autod-egg', 6 | prefix: '^', 7 | devprefix: '^', 8 | exclude: [ 9 | 'test/fixtures', 10 | 'coverage', 11 | ], 12 | dep: [ 13 | 'egg', 14 | 'egg-scripts', 15 | ], 16 | devdep: [ 17 | 'autod', 18 | 'autod-egg', 19 | 'egg-bin', 20 | 'tslib', 21 | 'typescript', 22 | ], 23 | keep: [ 24 | ], 25 | semver: [ 26 | ], 27 | test: 'scripts', 28 | }; 29 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ## [1.3.0](https://github.com/Elliottssu/insight/compare/v1.2.0...v1.3.0) (2020-01-03) 6 | 1. 添加eslint 7 | 2. 修复编辑机器人的公共私人状态提醒 8 | 9 | ## 1.2.0 (2020-01-01) 10 | 1. 一键发布消息,支持@所有人、指定人,方便快捷。 11 | 2. 强大的定时功能,可以每天执行并且智能跳过节假日,彻底解放双手。 12 | 3. 简约的排版,科幻的风格,3分钟内轻松上手。 13 | 4. 贴心的自定义套件,拓展代码实现自定义文本内容。 14 | 5. 完备的权限控制,保证机器人运行安全无忧。 15 | 6. 支持移动端布局,支持集成到企业微信控制台。 -------------------------------------------------------------------------------- /insight-front-end/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { Provider } from 'mobx-react'; 4 | import stores from './stores'; 5 | import Routes from './routes'; 6 | 7 | import '../node_modules/bootstrap/dist/css/bootstrap.css'; 8 | import './less/public.less'; 9 | import './less/glitch.less'; 10 | import './less/component.less'; 11 | import './less/overrides.less'; 12 | 13 | 14 | ReactDOM.render( 15 | 16 | {Routes} 17 | , 18 | document.getElementById('root'), 19 | ); 20 | -------------------------------------------------------------------------------- /insight-back-end/app/service/Suite.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 定制Task套件 Suite 3 | * 套件使用规范: 4 | * 1. 创建task的在suite添加“SuiteA” 5 | * 2. 在发送消息处拦截处理名为“SuiteA”套件 6 | * 3. 只有定时任务支持套件,即套件绑定是和任务绑定的 7 | */ 8 | import { Service } from 'egg'; 9 | 10 | export default class Suite extends Service { 11 | /** 12 | * 延迟1s执行(示例,这里可以对消息体操作,支持await) 13 | * @param msgContent 消息体 14 | */ 15 | public async suiteA(msgContent) { 16 | const timeout = ms => new Promise(res => setTimeout(res, ms)); 17 | await timeout(1000); 18 | return msgContent; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /insight-back-end/app/controller/log.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from 'egg'; 2 | import Msg from '../service/Msg'; 3 | import Util from '../service/Util'; 4 | 5 | export default class LogController extends Controller { 6 | 7 | // 日志查询 8 | public async getLog() { 9 | const { ctx } = this; 10 | const { robotId } = ctx.query; 11 | if (Util.emptyVaild(robotId)) return ctx.body = Msg.success([]); 12 | 13 | const filter: any = { 14 | where: { robotId }, 15 | order: { 16 | createDate: 'DESC', 17 | }, 18 | take: 5, 19 | }; 20 | const list = await ctx.repo.Log.find(filter); 21 | ctx.body = Msg.success(list); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /insight-back-end/typings/app/controller/index.d.ts: -------------------------------------------------------------------------------- 1 | // This file is created by egg-ts-helper@1.25.8 2 | // Do not modify this file!!!!!!!!! 3 | 4 | import 'egg'; 5 | import ExportLog from '../../../app/controller/log'; 6 | import ExportPermission from '../../../app/controller/permission'; 7 | import ExportRobot from '../../../app/controller/robot'; 8 | import ExportTask from '../../../app/controller/task'; 9 | import ExportUser from '../../../app/controller/user'; 10 | 11 | declare module 'egg' { 12 | interface IController { 13 | log: ExportLog; 14 | permission: ExportPermission; 15 | robot: ExportRobot; 16 | task: ExportTask; 17 | user: ExportUser; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /insight-front-end/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Insight | 企业微信群机器人管理工具 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /insight-front-end/src/stores/CommonStore.js: -------------------------------------------------------------------------------- 1 | /** 2 | * common store 3 | */ 4 | 5 | import { action, observable } from 'mobx'; 6 | 7 | class CommonStore { 8 | @observable message = {}; // 消息提示 9 | 10 | @observable timer = null; 11 | 12 | /** 13 | * 触发消息提示 14 | * @param type 消息类型 15 | * @param content 消息内容 16 | */ 17 | @action alertMessage = (type, content) => { 18 | this.message = { 19 | status: 1, 20 | type, 21 | content, 22 | }; 23 | if (this.timer) { 24 | clearTimeout(this.timer); 25 | } 26 | this.timer = setTimeout(() => { 27 | this.message = {}; 28 | }, 3000); 29 | } 30 | } 31 | 32 | export default new CommonStore(); 33 | -------------------------------------------------------------------------------- /insight-back-end/app/entity/User.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export default class User { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | // 昵称 10 | @Column() 11 | nickname: string; 12 | 13 | // 用户名 14 | @Column() 15 | username: string; 16 | 17 | // 密码 18 | @Column() 19 | password: string; 20 | 21 | // 是否是超级管理员(能看到所有机器人) 22 | @Column() 23 | isSuperAdmin: boolean; 24 | 25 | // 创建时间 26 | @CreateDateColumn() 27 | createDate: Date = new Date(); 28 | 29 | // 修改时间 30 | @UpdateDateColumn() 31 | updateDate: Date = new Date(); 32 | } 33 | -------------------------------------------------------------------------------- /insight-back-end/app/service/Msg.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 消息 Service 3 | */ 4 | export default class Msg { 5 | 6 | /** 7 | * 成功 8 | * @param data 9 | * @param msg 10 | * @param code 11 | */ 12 | static success(data: any= '', msg: string = 'success', code: number = 0) { 13 | return { 14 | code, 15 | data, 16 | msg, 17 | }; 18 | } 19 | 20 | /** 21 | * 失败 22 | * @param msg 23 | * @param data 24 | * @param code 25 | */ 26 | static error(msg: string = 'error', data: string= '', code: number = 1) { 27 | return { 28 | code, 29 | data, 30 | msg, 31 | }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /insight-front-end/config-overrides.js: -------------------------------------------------------------------------------- 1 | const darkTheme = require("@ant-design/dark-theme").default; 2 | const { override, fixBabelImports, addLessLoader, addDecoratorsLegacy, removeModuleScopePlugin } = require('customize-cra'); 3 | 4 | module.exports = override( 5 | // antd组件按需引用 6 | fixBabelImports('import', { 7 | libraryName: 'antd', 8 | libraryDirectory: 'es', 9 | style: true, 10 | }), 11 | // antd组件全局less控制 12 | addLessLoader({ 13 | javascriptEnabled: true, 14 | modifyVars: { 15 | ...darkTheme, 16 | '@primary-color': '#5783d3' 17 | }, 18 | }), 19 | // 支持@装饰器 20 | addDecoratorsLegacy(), 21 | // 支持node_nodules包引入 22 | removeModuleScopePlugin() 23 | ) -------------------------------------------------------------------------------- /insight-back-end/typings/typeorm.d.ts: -------------------------------------------------------------------------------- 1 | import 'egg' 2 | import { Repository, Connection } from 'typeorm' 3 | import Log from '../app/entity/Log' 4 | import Permission from '../app/entity/Permission' 5 | import Robot from '../app/entity/Robot' 6 | import Task from '../app/entity/Task' 7 | import User from '../app/entity/User' 8 | 9 | declare module 'egg' { 10 | interface Context { 11 | connection: Connection 12 | entity: { 13 | Log: any 14 | Permission: any 15 | Robot: any 16 | Task: any 17 | User: any 18 | } 19 | repo: { 20 | Log: Repository 21 | Permission: Repository 22 | Robot: Repository 23 | Task: Repository 24 | User: Repository 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /insight-front-end/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": [ 4 | "airbnb" 5 | ], 6 | "rules": { 7 | "react/jsx-filename-extension": 0, 8 | "react/prop-types": 0, 9 | "react/destructuring-assignment": 0, 10 | "no-undef": 0, 11 | "arrow-body-style": 0, 12 | "react/jsx-indent": 0, 13 | "react/no-array-index-key": 0, 14 | "func-names": 0, 15 | "react/jsx-props-no-spreading": 0, 16 | "import/prefer-default-export": 0, 17 | "max-len": 0, 18 | "jsx-a11y/control-has-associated-label": 0, 19 | "no-plusplus": 0, 20 | "jsx-a11y/click-events-have-key-events": 0, 21 | "jsx-a11y/no-static-element-interactions": 0 22 | } 23 | } -------------------------------------------------------------------------------- /insight-front-end/src/less/overrides.less: -------------------------------------------------------------------------------- 1 | @import './variables.less'; 2 | 3 | .ant-message-notice-content { 4 | background: #3b3a4d; 5 | } 6 | .ant-message .anticon { 7 | top: -3px; 8 | } 9 | .has-error .ant-form-explain { 10 | font-size: 12px; 11 | } 12 | .ant-select-selection { 13 | background-color: #3b3a4d; 14 | border: 1px solid #3b3a4d; 15 | } 16 | 17 | .ant-select-dropdown-menu-item-selected { 18 | color: @primary-color; 19 | background-color: #3b3a4d!important; 20 | } 21 | .ant-select-dropdown-menu-item { 22 | background-color: #3b3a4d; 23 | &:hover { 24 | background-color: #6a6f91!important; 25 | } 26 | } 27 | .ant-select-dropdown { 28 | box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); 29 | background: unset; 30 | } -------------------------------------------------------------------------------- /insight-back-end/app/entity/Permission.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne } from 'typeorm'; 2 | import User from './User'; 3 | 4 | @Entity() 5 | export default class Permission { 6 | 7 | @PrimaryGeneratedColumn() 8 | id: number; 9 | 10 | // 机器人ID 11 | @Column() 12 | robotId: number; 13 | 14 | // 用户ID 15 | @Column() 16 | userId: number; 17 | 18 | // 角色 管理员: admin 只读:readonly 19 | @Column() 20 | role: string; 21 | 22 | // 多对一外键(查询用) 23 | @ManyToOne(() => User, user => user.id) 24 | user: User; 25 | 26 | // 创建时间 27 | @CreateDateColumn() 28 | createDate: Date = new Date(); 29 | 30 | // 修改时间 31 | @UpdateDateColumn() 32 | updateDate: Date = new Date(); 33 | } 34 | -------------------------------------------------------------------------------- /insight-back-end/app/entity/Robot.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export default class Robot { 5 | 6 | @PrimaryGeneratedColumn() 7 | id: number; 8 | 9 | // 用户ID 10 | @Column() 11 | userId: number; 12 | 13 | // 机器人名字 14 | @Column() 15 | name: string; 16 | 17 | // 机器人描述 18 | @Column() 19 | description: string; 20 | 21 | // 机器人webook地址 22 | @Column() 23 | webhook: string; 24 | 25 | // 发布状态 公共:public 私有:private 26 | @Column() 27 | status: string; 28 | 29 | // 创建时间 30 | @CreateDateColumn() 31 | createDate: Date = new Date(); 32 | 33 | // 修改时间 34 | @UpdateDateColumn() 35 | updateDate: Date = new Date(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "insight", 3 | "version": "1.3.0", 4 | "description": "Insight是一个可以管理企业微信群机器人的小工具,可以非常方便的往群里发布即时消息和定时消息。", 5 | "dependencies": { 6 | "standard-version": "^7.0.0" 7 | }, 8 | "devDependencies": {}, 9 | "scripts": { 10 | "release-f": "standard-version -f", 11 | "release-major": "standard-version -r major", 12 | "release-minor": "standard-version -r minor", 13 | "release-patch": "standard-version -r patch" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/Elliottssu/insight.git" 18 | }, 19 | "author": "Elliottssu", 20 | "license": "ISC", 21 | "bugs": { 22 | "url": "https://github.com/Elliottssu/insight/issues" 23 | }, 24 | "homepage": "https://github.com/Elliottssu/insight/issues#readme" 25 | } 26 | -------------------------------------------------------------------------------- /insight-front-end/src/stores/PermissionStore.js: -------------------------------------------------------------------------------- 1 | /** 2 | * permission store 3 | */ 4 | 5 | import { action, observable } from 'mobx'; 6 | import { PermissionService } from '../services'; 7 | 8 | class PermissionStore { 9 | @observable isModelPermissionVisable = false; 10 | 11 | @observable permissionList = []; 12 | 13 | // 获取日志 14 | @action getPermissionList = (params) => { 15 | PermissionService.getPermission(params).then((result) => { 16 | if (result.data.code !== 0) return; 17 | this.permissionList = result.data.data; 18 | }); 19 | } 20 | 21 | // 显示权限模态框 22 | @action showModelPermission = () => { 23 | this.isModelPermissionVisable = true; 24 | } 25 | 26 | // 隐藏权限模态框 27 | @action handleCancel = () => { 28 | this.isModelPermissionVisable = false; 29 | } 30 | } 31 | 32 | export default new PermissionStore(); 33 | -------------------------------------------------------------------------------- /insight-front-end/src/utils/CommonUtil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 公共方法 3 | */ 4 | import imgLoading from '../images/s-loading.gif'; 5 | import imgOn from '../images/s-on.gif'; 6 | import imgOff from '../images/s-off.gif'; 7 | 8 | class CommonUtil { 9 | /** 10 | * 中文名字显示后两位 11 | * @param name 中文全称 12 | */ 13 | getShortName = (name) => { 14 | return name.substring(name.length - 2); 15 | } 16 | 17 | /** 18 | * 获取机器人状态 19 | * @param isLoading 是否加载中 20 | * @param taskCount 任务数量 21 | */ 22 | getRobotStatus = (isLoading, taskCount) => { 23 | let status = ''; 24 | if (isLoading) { 25 | status = imgLoading; 26 | return status; 27 | } 28 | if (taskCount === 0) { 29 | status = imgOff; 30 | return status; 31 | } 32 | status = imgOn; 33 | return status; 34 | } 35 | } 36 | export default new CommonUtil(); 37 | -------------------------------------------------------------------------------- /insight-front-end/src/components/TaskForm/MsgText.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 文本类型表单 3 | */ 4 | import React from 'react'; 5 | import { inject, observer } from 'mobx-react'; 6 | import { Input } from 'antd'; 7 | 8 | const { TextArea } = Input; 9 | 10 | @inject('TaskStore') 11 | @observer 12 | class MsgText extends React.Component { 13 | constructor() { 14 | super(); 15 | this.state = {}; 16 | } 17 | 18 | render() { 19 | const { publishTextContent } = this.props.TaskStore; 20 | 21 | return ( 22 | <> 23 |