Skip to content

Commit

Permalink
钉钉Linux版
Browse files Browse the repository at this point in the history
  • Loading branch information
宇天 committed Jun 9, 2017
0 parents commit ad3a1d3
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 钉钉App - Linux版
> `非官方版`
> 该版本用nwjs基于网页版钉钉封装而成, 通过js注入的方式,实现记住密码(自动登录)功能,
> 关闭驻留,最小化到托盘等实用功能。

该修改版并不对钉钉现有功能进行任何的修改,也不收集任何信息。
代码量很少, 而且完全开源, 请放心使用。


## 使用方法
> 下载nwjs,编译运行,或直接使用nwjs运行。
> nwjs具体方法请自行"网上搜索答案"





**注:** 本程序只是为了方便个人使用而进行的封装, 现在应网友要求上传到github供学习参考之用, 请勿用于非法途径, 由此产生的一切后果与本人无关。
15 changes: 15 additions & 0 deletions blank.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/css/base.css">
<style type="text/css">
body {overflow:hidden;position:absolute;width:100%;height:100%;}
.webview {display:block;width:100%;height:100%;}
</style>
</head>
<body>

</body>
</html>
47 changes: 47 additions & 0 deletions css/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@charset "UTF-8";
/**
*
* @authors yutent (yutent@doui.cc)
* @date 2014-10-10 00:45:09
*
* doui的CSS规范
*
* 不能出现大写,以连字符风格命名
* 表示状态的应该用do-st-*命名
* 表示功能的应该用do-fn-*命名
* 表示页面模块的应该用do-mod-modname 命名
* 表示UI组件的应该用do-uiname命名, 它的子元素应该全部包在 .do-uiname这个根类下
* 如 .do-layer .body { ... }
*
* 样式规则的出现顺序
* 1 display float position overflow z-index 表示定位/布局的属性
* 2 width height margin padding border 表示盒子模型的属性
* 3 line-height font-size vertical-align text-align user-select outline ....排版相关的属性
* 4 color background opacity cursor ...表示装饰相关的属性
* 5 content list-style quotes ... 内容生成相关的属性
*
*/
* {margin: 0;padding: 0;vertical-align: baseline;box-sizing:border-box;}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section,content {display: block;}
img {border:0;display:inline-block;}
ol, ul {list-style: none;}
blockquote, q {quotes: none;}
blockquote:before, blockquote:after,
q:before, q:after {content: '';content: none;}
table {border-collapse: collapse;border-spacing: 0;}

.do-fn-cl { *zoom: 1; }
.do-fn-cl:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; overflow:hidden;}
.do-fn-clear {clear:both;display:inline;}

.do-fn-show{display:block;}
.do-fn-hide{display:none;}
.do-fn-fl{float:left;}
.do-fn-fr{float:right;}
.do-fn-noselect {-webkit-touch-callout: none;-webkit-user-select: none;-moz-user-select: none;user-select: none;}
.do-fn-noselect img, .do-fn-noselect a {-webkit-user-drag:none;}
.do-fn-ell {overflow:hidden; white-space:nowrap; text-overflow:ellipsis }
.do-st-thin {-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
.do-st-hand {cursor:pointer;}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/css/base.css">
<style type="text/css">
body {overflow:hidden;position:absolute;width:1000px;height:662px;}
.webview {display:block;width:1000px;height:602px;}
</style>
</head>
<body>

<webview class="webview" src="https://im.dingtalk.com" partition="persist:googlepluswidgets"></webview>


<script type="text/javascript">
let win = nw.Window.get();
let $wv = document.querySelector('.webview');
let tray = new nw.Tray({ title: '钉钉', icon: 'icon.png' });
let menu = new nw.Menu();
let show = new nw.MenuItem({label: '显示钉钉'})
let quit = new nw.MenuItem({label: '退出钉钉'})
show.click = function(){
win.show()
}
quit.click = function(){
win.close(true)
}
menu.append(show)
menu.append(quit)
tray.menu = menu

tray.on('click', function(){
win.show()
})

$wv.addEventListener('permissionrequest', function(ev) {
ev.request.allow();
});

function dialog(o, ev){
let res = o[ev.messageType](ev.messageText)
if(ev.messageType === 'confirm' || ev.messageType === 'prompt'){
if(res){
ev.dialog.ok(res);
}else{
ev.dialog.cancel();
}
}
}
$wv.addEventListener('dialog', function(ev) {
dialog(window, ev)
});

$wv.addEventListener('newwindow', function(ev){

ev.preventDefault();

if(ev.targetUrl !== 'about:blank'){
nw.Window.open(ev.targetUrl, {width: 1200, height: 700, resizable: true})
}else{
let elem = document.createElement('webview');
elem.className = 'webview';
elem.addEventListener('permissionrequest', function(ev) {
ev.request.allow();
});
elem.setAttribute('partition', 'persist:googlepluswidgets')
ev.window.attach(elem)
nw.Window.open('blank.html', {width: 1200, height: 700, resizable: true, title: '钉钉邮箱'}, function(w){
elem.addEventListener('dialog', function(ev) {
dialog(w.window, ev)
});
w.window.addEventListener('load', function(){
w.window.document.body.appendChild(elem)
})
})
}
})


$wv.addEventListener('contentload', function(ev){
$wv.executeScript({ code: `
nw.gui = nw.gui || nw;
let pwd = localStorage.getItem("pwd") || ''
localStorage.setItem("isBeepOpen", "true");
localStorage.setItem("notification", "true");
localStorage.setItem("newUserState", "secTip");
document.querySelectorAll('.tab-items li')[1].click()
let $form = document.querySelector('form[name=passwordForm]'), $pwd;
for(let i = 0,el;el = $form.elements[i++];){
if(el.type === 'password'){
$pwd = el;
el.value = pwd;
if(el.value){
let ev = document.createEvent('Event')
ev.initEvent('change', false, false)
el.dispatchEvent(ev);
}
}else if(el.type === 'submit'){
el.onclick = function(){
localStorage.setItem('pwd', $pwd.value)
}
// el.click()
}
}
`});
})

win.on('close', function(ev){
this.hide()
})
win.on('maximize', function(ev){
this.restore()
})
</script>
</body>
</html>
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "dtalk",
"main": "index.html",
"domain": "localhost",
"version": "3.2.3",
"description": "钉钉-Linux版",
"window": {
"title": "钉钉-Linux版",
"width": 1000,
"height": 602,
"max_width": 1000,
"max_height": 602,
"min_width": 1000,
"min_height": 602,
"as_desktop": true,
"resizable": false,
"show_in_taskbar": true,
"icon": "icon.png"
},
"webview": {
"partitions": [
{
"name": "trusted",
"accessible_resources": [ "<all_urls>" ]
}
]
}
}

0 comments on commit ad3a1d3

Please sign in to comment.