
松弛變量可以為負嗎

Slack still doesn’t have a dark mode. They have dark themes, but those only let you customize the sidebar colors, leaving the main window white. With the release of system-wide dark modes on macOS Mojave and Windows 10, Slack feels very out of place.
Slack仍然沒有暗模式。 它們具有深色主題,但這些主題僅允許您自定義側邊欄顏色,而使主窗口保持白色。 隨著在macOS Mojave和Windows 10上發布的系統范圍內的暗模式,Slack感覺很不合適。
This method is unofficial and involves digging around in the source files for Slack. It’s fairly easy to do, but since it will be overwritten every time you update, you will have to do this multiple times.
此方法是非官方的,涉及在Slack的源文件中進行挖掘。 這很容易做到,但是由于每次更新都會被覆蓋,因此您必須多次執行此操作。
下載主題 (Downloading a Theme)
Since Slack runs on Electron, a framework for developing desktop Node.js apps, you can edit the styles for it like you’d edit the CSS of a website. But the CSS files for Slack are buried in the source, so you’ll have to load your own themes.
由于Slack在Electron(用于開發桌面Node.js應用程序的框架)上運行,因此您可以像編輯網站CSS一樣為其編輯樣式。 但是SlackCSS文件被隱藏在源代碼中,因此您必須加載自己的主題。
The most popular true dark mode theme is slack-black-theme by Widget. And since Electron shares code across platforms, this theme will work on Windows and Linux as well. We found there were some issues with the theme on macOS Mojave though, so if it doesn’t work then you can try this fork, which says it works on macOS only but may work for Windows users as well.
最受歡迎的真正黑暗模式主題是Widget的“ slack-black-theme” 。 由于Electron跨平臺共享代碼,因此該主題也將在Windows和Linux上運行。 我們發現macOS Mojave上的主題存在一些問題,因此,如果該主題不起作用,則可以嘗試使用fork ,它說它僅適用于macOS,但也可能適用于Windows用戶。
修補松弛 (Patching Slack)

This part, you’ll have to do again every time Slack updates. On macOS, you can get to Slack’s source directory by right-clicking on the app itself and selecting “Show Package Contents”. On Windows, you’ll find it at?~\AppData\Local\slack\
.
這部分,每次Slack更新時,您都必須再次執行。 在macOS上,您可以通過右鍵單擊應用程序本身并選擇“顯示軟件包內容”來進入Slack的源目錄。 在Windows上,您可以在~\AppData\Local\slack\
找到它。
Then, navigate a few folders down to resources/app.asar.unpacked/src/static/
. You’re going to want to find the ssb-interop.js
file, where you’ll edit the code. Make sure Slack is closed, open that file in your favorite text editor, and scroll to the bottom:
然后,將幾個文件夾導航到resources/app.asar.unpacked/src/static/
。 您將要找到ssb-interop.js
文件,您將在其中編輯代碼。 確保關閉了Slack,在您喜歡的文本編輯器中打開該文件,然后滾動到底部:

Copy and paste the following code at the very end of the ssb-interop.js
file:
將以下代碼復制并粘貼到ssb-interop.js
文件的末尾:
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://cdn.rawgit.com/widget-/slack-black-theme/master/custom.css';
let cssPromise = fetch(cssPath).then(response => response.text());
let customCustomCSS = `
:root {
/* Modify these to change your theme colors: */
--primary: #09F;
--text: #CCC;
--background: #080808;
--background-elevated: #222;
}
`
// Insert a style tag into the wrapper view
cssPromise.then(css => {
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = css + customCustomCSS;
document.head.appendChild(s);
});
// Wait for each webview to load
webviews.forEach(webview => {
webview.addEventListener('ipc-message', message => {
if (message.channel == 'didFinishLoading')
// Finally add the CSS into the webview
cssPromise.then(css => {
let script = `
let s = document.createElement('style');
s.type = 'text/css';
s.id = 'slack-custom-css';
s.innerHTML = \`${css + customCustomCSS}\`;
document.head.appendChild(s);
`
webview.executeJavaScript(script);
})
});
});
});
You’ll probably want to duplicate this file and save it in a different location, so you don’t have to edit the code every time. This way, you can just drag it into the directory to overwrite the newest version:
您可能需要復制此文件并將其保存在其他位置,因此您不必每次都編輯代碼。 這樣,您可以將其拖到目錄中以覆蓋最新版本:

After you’re done, reopen Slack, and after a few seconds the dark mode should kick in. The loading screen will still be white, but the main app window will blend in much better with the rest of your system:
完成后,重新打開Slack,幾秒鐘后,將進入黑暗模式。加載屏幕仍為白色,但主應用程序窗口將與系統的其余部分更好地融合在一起:

添加自己的主題 (Adding Your Own Themes)
If you don’t like the look of it, you can edit the CSS with any styles you want. All this code does is load custom styles from?https://cdn.rawgit.com/widget-/slack-black-theme/master/custom.css; you can download that file, edit it with your changes, and replace the URL with your own code. Save, relaunch Slack, and your changes will be visible. If you don’t know CSS, or just want to make a minor change, there are four color variables defined before loading the CSS, so you can just edit those with your own colors.
如果您不喜歡它的外觀,則可以使用所需的任何樣式來編輯CSS。 這些代碼所做的只是從https://cdn.rawgit.com/widget-/slack-black-theme/master/custom.css加載自定義樣式; 您可以下載該文件,進行更改后進行編輯,然后將URL替換為自己的代碼。 保存并重新啟動Slack,您的更改將可見。 如果您不了解CSS,或者只是想作一些小的更改,則在加載CSS之前定義了四個顏色變量,因此您可以使用自己的顏色進行編輯。
翻譯自: https://www.howtogeek.com/368976/how-to-install-the-unofficial-dark-mode-for-slack/
松弛變量可以為負嗎