Compare commits
2
Commits
49df839254
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd9a31e301
|
||
|
|
11c69bf012
|
+8
-1
@@ -21,8 +21,15 @@ export function formatBytes(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compact for the panel: "2.4M", "120K", "0".
|
// Compact for the panel: "2.4M", "120K", "0".
|
||||||
|
// Keeps the mantissa under three integer digits so a value is at most four
|
||||||
|
// characters wide ("999K", "9.9M", "1023") — the panel field has a fixed width
|
||||||
|
// and must never overflow it (see .sbx-speed-label in stylesheet.css).
|
||||||
export function formatBytesShort(n) {
|
export function formatBytesShort(n) {
|
||||||
const [v, i] = scale(n);
|
let [v, i] = scale(n);
|
||||||
|
if (i > 0 && v >= 1000 && i < SHORT_UNITS.length - 1) {
|
||||||
|
v /= 1024;
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
if (i === 0)
|
if (i === 0)
|
||||||
return `${Math.round(v)}`;
|
return `${Math.round(v)}`;
|
||||||
const digits = v < 10 ? 1 : 0;
|
const digits = v < 10 ? 1 : 0;
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import { formatSpeed, formatSpeedShort } from './format.js';
|
|||||||
export const SingBoxIndicator = GObject.registerClass(
|
export const SingBoxIndicator = GObject.registerClass(
|
||||||
class SingBoxIndicator extends PanelMenu.Button {
|
class SingBoxIndicator extends PanelMenu.Button {
|
||||||
_init(extension) {
|
_init(extension) {
|
||||||
super._init(0.0, 'sing-box Status', false);
|
super._init(0.5, 'sing-box Status', false);
|
||||||
|
|
||||||
this._extension = extension;
|
this._extension = extension;
|
||||||
this._settings = extension.getSettings();
|
this._settings = extension.getSettings();
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
.sbx-speed-label {
|
.sbx-speed-label {
|
||||||
font-feature-settings: "tnum";
|
font-feature-settings: "tnum";
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
|
/* Fixed width so the panel widget doesn't shift as speed values change.
|
||||||
|
Sized for the widest field: "↓1023 ↑1023" (see formatBytesShort). */
|
||||||
|
min-width: 7.5em;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sbx-status-item {
|
.sbx-status-item {
|
||||||
|
|||||||
Reference in New Issue
Block a user