{"id":24758566,"url":"https://github.com/dooy/dooy-js-tool","last_synced_at":"2026-07-10T00:31:16.912Z","repository":{"id":60569728,"uuid":"543696548","full_name":"Dooy/dooy-js-tool","owner":"Dooy","description":"自己的小工具","archived":false,"fork":false,"pushed_at":"2022-10-19T05:28:49.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-04T00:08:21.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dooy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-30T16:43:14.000Z","updated_at":"2022-09-30T17:07:12.000Z","dependencies_parsed_at":"2023-01-20T15:02:53.369Z","dependency_job_id":null,"html_url":"https://github.com/Dooy/dooy-js-tool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dooy%2Fdooy-js-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dooy%2Fdooy-js-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dooy%2Fdooy-js-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dooy%2Fdooy-js-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dooy","download_url":"https://codeload.github.com/Dooy/dooy-js-tool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084614,"owners_count":20558251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T16:35:30.853Z","updated_at":"2025-10-30T16:01:54.677Z","avatar_url":"https://github.com/Dooy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dooy-js-tool 小工具\n\n## 安装\n```\nnpm i dooy-js-tool\n\nconst dooy = require(\"dooy-js-tool\");\n```\n\n## 浏览器引入\n\n```html\n\u003cscript src=\"dist/dooy-js-tool.min.js\"\u003e\u003c/script\u003e\n```\n\n## 工具 方法使用\n[在线运行](https://codepen.io/dooy/pen/qBYywzm)\n```js\nconsole.log( dooy.tool.dateFormat(\"yyyy-MM-dd hh:mm:ss\" ) );\nconsole.log( dooy.tool.dateFormat(\"yyyy-MM-dd hh:mm:ss\",new Date()) );\nconsole.log( dooy.tool.dateFormat(\"yyyy-MM-dd hh:mm:ss\",'2022-09-10') );\nconsole.log( dooy.tool.dateFormat(\"yyyy-MM-dd hh:mm:ss\",1664400496) );\n\nconsole.log( dooy.tool.now( 1664400496));\nconsole.log( dooy.tool.now( \"2022-10-01 05:28:16\"));\nconsole.log( dooy.tool.now( new Date(\"2022-10-01 05:28:16\")));\n\nconsole.log( dooy.tool.getQueryStr(\"abc\")); // ?abc=123 仅支持 浏览器模式\n\n```\n\n\n## 腾讯COS\n\n 需要腾讯COS库支持 引入腾讯COS\n```\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/cos-js-sdk-v5/dist/cos-js-sdk-v5.min.js\"\u003e\u003c/script\u003e\n#或者\nlet COS = require('cos-js-sdk-v5');\n```\n调用\n\n```html\n\u003cinput type=\"file\"   onchange=\"upload\"\u003e\n\u003cscript\u003e\n    /**\n     * init(opt) \n     * opt 参数\n     * @param COS 腾讯云COS js\n     * @param {function} callback\n     * @param {String} stsMyServer 验证码服务器地址\n     * @param cosCdn 存放cos CDN 远程域名\n     * @param Bucket 存储桶\n     * @param Region 腾讯云园区\n     */\n    let opt={\n        COS\n        ,stsMyServer:'/pigai?c=mpad\u0026a=cos\u0026do=1' //批改网验证服务器\n        ,callback: res=\u003e{\n            console.log(\"返回\u003e\u003e\",res);\n        }\n    }\nfunction upload(e){\n        const file = e.target.files \u0026\u0026 e.target.files[0];\n\n        dooy.cos.init(opt).upload(file\n            ,{onProgress: info=\u003e{\n                    let percent = Math.floor(info.percent * 10000) / 100;\n                    let speed = Math.floor(info.speed / 1024 / 1024 * 100) / 100;\n                    console.log('进度：' + percent + '%; 速度：' + speed + 'Mb/s;');\n                }\n        });\n\n    }\n\u003c/script\u003e\n```\n## ES\n需要  axios支持\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js\"\u003e\u003c/script\u003e\n```\n使用\n```js\n let es= dooy.es.init({axios});\n //新建一个buckets\n let ts = es.createBuckets(res.data.aggregations.ts.buckets);\n //获取bucket中 key 为 1的值\n let t2 = ts.getObjectByKey('1');\n\n//获取bucket 中的日志 带 key doc_cnt 和file.value \n let rz=ts.getValue();\n```\n## 批改ES\n需要 lodash axios支持\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js\"\u003e\u003c/script\u003e\n```\n\n调用\n\n```js\ngetPigaiEs(){\n    let opt={\n        school:'',//学校 支持多学校[’北京大学‘,'南京大学']\n        stime:'2010-01-01',//开始日期\n        etime:'2022-10-01',//截止日期\n        rank:'y',//排序方式 y 年，m 月，w 周，d 日\n        where:{},//其他条件 比如地域 where.city=['北京市'，’北京‘]\n    }\n    let es= dooy.es.init({axios});\n    let pigaiEs = new dooy.pigaiEs(es,_, opt);\n    return pigaiEs;\n}\n//获取概况统计 分别获取\nloadInit(){\n    this.getPigaiEs().getMember().then(res=\u003e{\n        this.smain= _.extend(this.smain ,res[0].data);\n        //console.log('main\u003e\u003e', this.smain);\n    });\n    this.getPigaiEs().getRequest().then(res=\u003e{\n        this.st.request = true;\n        this.request= _.extend(this.request ,res[0].data);\n        //console.log('request\u003e\u003e', res[0]);\n    });\n    this.getPigaiEs().getEssay({all:1}).then(res=\u003e{\n        this.st.essay = true;\n        this.essay= _.extend(this.essay ,res[0].data);\n        //console.log('essay\u003e\u003e', res[0]);\n    });\n}\n\n//获取按年、月、周、日统计 多次请求等等回来 像 jquery.wehn,axios.all\nthis.getPigaiEs().rankRequest().rankEssay().rankMember().then( res=\u003e{\n    let request= res[0].data;\n    let essay= res[1].data;\n    let member= res[2].data;\n});\n\n```\n## 批改网登录登出\n初始化\n```js\nlet pigaiLogin=  dooy.pigaiLogin.init({axios})\n```\n获取登录信息\n```js\nlet u = pigaiLogin.getJsPigaiInfo();\n#未登录为 null\n#有登录为 返回\n{\n    \"userName\": \"用户名\",\n    \"userId\": \"123\",\n    \"isLogin\": true,\n    \"nickName\": \"显示名字\",\n    \"lang\": \"cn\",\n    \"isV\": 1,\n    \"ts\": 2,\n    \"school\": \"学校\"\n}\n```\n\n登录\n```js\npigaiLogin.login(this.form.name,this.form.psw).then(res=\u003e{\n                    console.log('dddd',res);\n                    if(res.error==0){\n                        userInfo=res.data;\n                    }\n                });\n```\n登出\n```js\npigaiLogin.logout();\n```\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdooy%2Fdooy-js-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdooy%2Fdooy-js-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdooy%2Fdooy-js-tool/lists"}