Merge branch 'develop' of https://github.com/ciderapp/Cider into develop

This commit is contained in:
vapormusic 2022-02-03 05:56:43 +07:00
commit dd5ee599f5
7 changed files with 71 additions and 14 deletions

View file

@ -150,6 +150,20 @@ export class BrowserWindow {
res.render("main", this.EnvironmentVariables); res.render("main", this.EnvironmentVariables);
}); });
app.get("/themes/:theme", (req, res) => {
const theme = req.params.theme.toLowerCase();
const themePath = path.join(utils.getPath('srcPath'), "./renderer/themes/", theme);
const userThemePath = path.join(utils.getPath('themes'), theme);
if (fs.existsSync(userThemePath)) {
res.sendFile(userThemePath);
} else if (fs.existsSync(themePath)) {
res.sendFile(themePath);
} else {
res.send(`// Theme not found - ${userThemePath}`);
}
});
app.get("/audio.webm", (req, res) => { app.get("/audio.webm", (req, res) => {
try { try {
req.socket.setTimeout(Number.MAX_SAFE_INTEGER); req.socket.setTimeout(Number.MAX_SAFE_INTEGER);
@ -276,6 +290,14 @@ export class BrowserWindow {
event.returnValue = process.platform; event.returnValue = process.platform;
}); });
ipcMain.on("get-themes", (event, key) => {
if (fs.existsSync(utils.getPath("themes"))) {
event.returnValue = fs.readdirSync(utils.getPath("themes"));
} else {
event.returnValue = [];
}
});
ipcMain.on("get-i18n", (event, key) => { ipcMain.on("get-i18n", (event, key) => {
event.returnValue = utils.getLocale(key); event.returnValue = utils.getLocale(key);
}); });

View file

@ -586,6 +586,9 @@ const app = new Vue({
}, },
async init() { async init() {
let self = this let self = this
if(this.cfg.visual.theme != "default.less" || this.cfg.visual.theme != "") {
this.setTheme()
}
this.setLz(this.cfg.general.language) this.setLz(this.cfg.general.language)
this.setLzManual() this.setLzManual()
clearTimeout(this.hangtimer) clearTimeout(this.hangtimer)
@ -840,6 +843,18 @@ const app = new Vue({
this.$forceUpdate() this.$forceUpdate()
}, 500) }, 500)
}, },
setTheme(theme = "") {
if(this.cfg.visual.theme == "") {
this.cfg.visual.theme = "default.less"
}
if(theme == ""){
theme = this.cfg.visual.theme
}else{
this.cfg.visual.theme = theme
}
document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}`
document.querySelectorAll(`[id*='less']`).forEach(el => { el.remove() });less.refresh()
},
unauthorize() { unauthorize() {
this.mk.unauthorize() this.mk.unauthorize()
document.location.reload() document.location.reload()

View file

@ -502,6 +502,7 @@ input[type=range].web-slider::-webkit-slider-runnable-track {
} }
.app-sidebar-footer { .app-sidebar-footer {
border-top: 1px solid rgba(200, 200, 200, 0.15);
padding: 11px; padding: 11px;
.app-playback-controls { .app-playback-controls {
@ -1392,7 +1393,7 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb {
} }
/* Window is smaller <= 1023px width */ /* Window is smaller <= 1023px width */
@media only screen and (max-width: 1023px) { @media only screen and (max-width: 1120px) {
.display--small { .display--small {
display: inherit !important;; display: inherit !important;;
@ -4579,7 +4580,7 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb {
height: 50vh; height: 50vh;
} }
@media only screen and (max-width: 1023px) { @media only screen and (max-width: 1121px) {
.display--large { .display--large {
display: flex !important; display: flex !important;
} }
@ -4970,7 +4971,7 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb {
height: 50vh; height: 50vh;
} }
@media only screen and (max-width: 1023px) { @media only screen and (max-width: 1121px) {
.display--large { .display--large {
display: flex !important; display: flex !important;
} }

View file

@ -0,0 +1,14 @@
# Themes (WIP)
## Making a theme
* If one does not already exist, create a new theme directory in the user data folder.
* **Windows:** `%appdata%/Cider/themes`
* **Mac:** `~/Library/Application Support/Cider/themes`
* **Linux:** `~/.config/Cider/themes`
* Create a `theme.less` file with the name of the theme.
* In Cider, select the theme in the settings.
* To enable hot reloading for the theme, open the DevTools and enter `less.watch()` in the console.
## Resources
* The default styles.less can be found in: [src/renderer/style.less](https://github.com/ciderapp/Cider/tree/main/src/renderer/style.less)
* [Less.js documentation](https://lesscss.org/)

View file

@ -0,0 +1 @@
// Default theme

View file

@ -16,6 +16,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Cider</title> <title>Cider</title>
<link rel="stylesheet/less" type="text/css" href="style.less"/> <link rel="stylesheet/less" type="text/css" href="style.less"/>
<link rel="stylesheet/less" type="text/css" id="userTheme" href="themes/default.less"/>
<script src="./js/less.js"></script> <script src="./js/less.js"></script>
<script src="<%- (env.dev ? "./js/vue.js" : "./js/vue.dev.js") %>"></script> <script src="<%- (env.dev ? "./js/vue.js" : "./js/vue.dev.js") %>"></script>
<script src="./js/vuex.min.js"></script> <script src="./js/vuex.min.js"></script>

View file

@ -97,6 +97,17 @@
<span>{{$root.getLz('settings.header.visual')}}</span> <span>{{$root.getLz('settings.header.visual')}}</span>
</div> </div>
<div class="settings-option-body"> <div class="settings-option-body">
<div class="md-option-line">
<div class="md-option-segment">
Theme
</div>
<div class="md-option-segment md-option-segment_auto">
<select class="md-select" @change="$root.setTheme($root.cfg.visual.theme)" v-model="$root.cfg.visual.theme">
<option value="default.less">Cider</option>
<option v-for="theme in themes" :value="theme">{{ theme }}</option>
</select>
</div>
</div>
<div class="md-option-line"> <div class="md-option-line">
<div class="md-option-segment"> <div class="md-option-segment">
{{$root.getLz('settings.option.visual.windowBackgroundStyle')}} {{$root.getLz('settings.option.visual.windowBackgroundStyle')}}
@ -623,16 +634,7 @@
<span>{{$root.getLz('settings.header.unfinished')}}</span> <span>{{$root.getLz('settings.header.unfinished')}}</span>
</div> </div>
<div class="settings-option-body"> <div class="settings-option-body">
<div class="md-option-line">
<div class="md-option-segment">
Theme
</div>
<div class="md-option-segment md-option-segment_auto">
<select class="md-select">
<option value="0">Cider</option>
</select>
</div>
</div>
<div class="md-option-line"> <div class="md-option-line">
<div class="md-option-segment"> <div class="md-option-segment">
Theme Options Theme Options
@ -694,7 +696,8 @@
props: [], props: [],
data: function () { data: function () {
return { return {
app: this.$root app: this.$root,
themes: ipcRenderer.sendSync("get-themes")
} }
}, },
mounted: function () { mounted: function () {