Skip to content
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ The countdown clock hasn't been tested enough though. Probably work if your conf

The `format` field is a date-time format string used to display the clock. To create a custom date-time format, please refer to [this formatting guide](https://momentjs.com/docs/#/parsing/string-format/).

#### format2

The `format2` field is same as `format`. These are switched each other by clicking the mclocks. The `format2` is optional field.

#### locale

The `locale` field determines the language settings for displaying the date-time. You can find [a list of supported locales here](https://github.com/kawanet/cdate-locale/blob/main/locales.yml).
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct AppConfig {
#[serde(default)]
format: String,
#[serde(default)]
format2: String,
#[serde(default)]
locale: String,
#[serde(default)]
forefront: bool,
Expand Down Expand Up @@ -120,6 +122,7 @@ fn merge_configs(old: OldAppConfig, new: AppConfig) -> AppConfig {
} else {
"MM-DD ddd HH:mm".to_string()
},
format2: new.format2,
locale: if new.locale != "" {
new.locale
} else if old.locale_date_time != "" {
Expand Down
15 changes: 14 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ const currentPlatform = platform();
let elClocks = document.querySelector("#mclocks");
let Config;
let ignoreOnMoved = false
let switchFormat = false

window.addEventListener("DOMContentLoaded", async () => {
elClocks.addEventListener("mousedown", async () => {
await getCurrentWindow().startDragging();
})

elClocks.addEventListener("click", async () => {
if (!Config || !Config.format2) {
return
}
switchFormat = !switchFormat
adjustWindowSize()
})

await getCurrentWindow().onMoved(() => {
// Not support to save window-state onMoved for macOS.
// Just save window-state on quit mclocks for macOS.
Expand Down Expand Up @@ -95,7 +104,11 @@ function tock(clock) {
if (clock.target) {
clock.el.innerHTML = escapeHTML(buildCountdown(clock.target, clock.timezone, clock.countdown));
} else {
clock.el.innerHTML = escapeHTML(clock.fn().format(Config.format));
let format = Config.format
if (switchFormat) {
format = Config.format2
}
clock.el.innerHTML = escapeHTML(clock.fn().format(format));
}
}

Expand Down