Skip to content
This repository has been archived by the owner on Nov 12, 2018. It is now read-only.

Adding zoom support. 添加缩放支持。 #644

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ Common.MENTION_MENU_HINT_TEXT = 'Mention:';
Common.MESSAGE_PREVENT_RECALL = 'Blocked a message recall.';
Common.EMOJI_MAXIUM_SIZE = 120;

Common.languageTitle = 'Language(Need to Restart';
Common.languageTitle = 'Language (Restart Required)';
Common.languageDesc = 'Select a default language for WeChat!';
Common.recallTitle = 'Prevent Message Recall';
Common.recallDesc = 'Message recall feature might be annoying';
Common.instanceTitle = 'Allow Multiple Instance';
Common.instanceDesc = 'Multiple instance can login with different accounts';
Common.iconTitle = 'File Path (In Development)';
Common.iconDesc = 'Set a default file path';
Common.zoomTitle = 'Zoom (Restart Required)';
Common.zoomDesc = 'Set the size of the interface.'
Common.zoomSmall = 'Small';
Common.zoomNormal = 'Normal';
Common.trayTitle = 'Tray Icon color (Black/White)';
Common.trayDesc = 'Select a color to match your desktop theme';

Expand Down
1 change: 0 additions & 1 deletion src/inject/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Injector {
this.lastUser = null;
this.initIPC();
webFrame.setZoomLevelLimits(1, 1);

new MenuHandler().create();
}

Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ElectronicWeChat {
AppConfig.saveSettings('language', 'en');
AppConfig.saveSettings('prevent-recall', 'on');
AppConfig.saveSettings('icon', 'black');
AppConfig.saveSettings('zoom', 'normal');
AppConfig.saveSettings('multi-instance','on');
}
});
Expand Down
6 changes: 6 additions & 0 deletions src/windows/controllers/wechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class WeChatWindow {
}

createWindow() {
const zoom = AppConfig.readSettings('zoom');
var zoomFactor = 1.0;
if (zoom && zoom == 'small') {
zoomFactor = 0.85;
}
this.wechatWindow = new BrowserWindow({
title: Common.ELECTRONIC_WECHAT,
resizable: true,
Expand All @@ -65,6 +70,7 @@ class WeChatWindow {
nodeIntegration: false,
webSecurity: false,
preload: path.join(__dirname, '../../inject/preload.js'),
zoomFactor: zoomFactor,
},
});

Expand Down
34 changes: 32 additions & 2 deletions src/windows/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ <h4 id="app-recall-desc">选择是否阻止微信的消息撤回功能</h4>
</li>
</ul>
</section>
<section>
<ul>
<li class="menu-title">
<h3 id="app-zoom-title">缩放(重启生效)</h3>
</li>
<li class="menu-desc">
<h4 id="app-zoom-desc">设置界面大小</h4>
</li>
<li class="menu-button">
<select class="" id="app-zoom-select">
<option id="app-zoom-small" value="small">较小</option>
<option id="app-zoom-normal" value="normal">正常</option>
</select>
</li>
</ul>
</section>
<section>
<ul>
<li class="menu-title">
Expand Down Expand Up @@ -115,6 +131,12 @@ <h4 id="app-tray-desc">选择一个适合当前主题的颜色</h4>

const lan = AppConfig.readSettings('language');
const recall = AppConfig.readSettings('prevent-recall');
const icon = AppConfig.readSettings('icon');
const zoom = AppConfig.readSettings('zoom');

const lanSelect = $('app-language-select');
const recallSelect = $('app-recall-select');
const zoomSelect = $('app-zoom-select');
const instance = AppConfig.readSettings('multi-instance');
const trayColor = AppConfig.readSettings('tray-color');

Expand Down Expand Up @@ -145,10 +167,13 @@ <h4 id="app-tray-desc">选择一个适合当前主题的颜色</h4>

function setListeners() {
lanSelect.addEventListener('change', function() {
AppConfig.saveSettings('language', lanSelect.value)
AppConfig.saveSettings('language', lanSelect.value);
})
recallSelect.addEventListener('change', function() {
AppConfig.saveSettings('prevent-recall', recallSelect.value)
AppConfig.saveSettings('prevent-recall', recallSelect.value);
})
zoomSelect.addEventListener('change', function() {
AppConfig.saveSettings('zoom', zoomSelect.value);
})
instanceSelect.addEventListener('change', function() {
AppConfig.saveSettings('multi-instance', instanceSelect.value)
Expand All @@ -162,6 +187,7 @@ <h4 id="app-tray-desc">选择一个适合当前主题的颜色</h4>
function setConfig() {
$('app-language-select').value = lan;
$('app-recall-select').value = recall;
$('app-zoom-select').value = zoom;
$('app-instance-select').value = instance;
$('app-tray-select').value = trayColor;
}
Expand All @@ -179,6 +205,10 @@ <h4 id="app-tray-desc">选择一个适合当前主题的颜色</h4>
$('app-tray-desc').innerHTML = Common.trayDesc;
$('upgrade-btn').innerHTML = Common.UPGRADE;
$('feedback-btn').innerHTML = Common.FEEDBACK;
$('app-zoom-title').innerHTML = Common.zoomTitle;
$('app-zoom-desc').innerHTML = Common.zoomDesc;
$('app-zoom-small').innerHTML = Common.zoomSmall;
$('app-zoom-normal').innerHTML = Common.zoomNormal;
}

function feedback() {
Expand Down