mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-12 19:39:03 +08:00
Auto darkmode
This commit is contained in:
parent
975b53db41
commit
46e37df110
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
# json config
|
# json config
|
||||||
backend/src/sub-store.json
|
sub-store.json
|
||||||
backend/src/root.json
|
root.json
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
|
@ -5,32 +5,16 @@
|
|||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</v-main>
|
</v-main>
|
||||||
<BottomNav></BottomNav>
|
<BottomNav></BottomNav>
|
||||||
<v-snackbar
|
<v-snackbar :value="successMessage" app bottom color="success" elevation="20">
|
||||||
:value="successMessage"
|
|
||||||
app
|
|
||||||
bottom
|
|
||||||
color="success"
|
|
||||||
elevation="20"
|
|
||||||
>
|
|
||||||
{{ successMessage }}
|
{{ successMessage }}
|
||||||
</v-snackbar>
|
</v-snackbar>
|
||||||
|
|
||||||
<v-snackbar
|
<v-snackbar :value="errorMessage" app bottom color="error" elevation="20">
|
||||||
:value="errorMessage"
|
|
||||||
app
|
|
||||||
bottom
|
|
||||||
color="error"
|
|
||||||
elevation="20"
|
|
||||||
>
|
|
||||||
{{ errorMessage }}
|
{{ errorMessage }}
|
||||||
</v-snackbar>
|
</v-snackbar>
|
||||||
|
|
||||||
<v-overlay :value="isLoading">
|
<v-overlay :value="isLoading">
|
||||||
<v-progress-circular
|
<v-progress-circular indeterminate size="64" color="primary"></v-progress-circular>
|
||||||
indeterminate
|
|
||||||
size="64"
|
|
||||||
color="primary"
|
|
||||||
></v-progress-circular>
|
|
||||||
</v-overlay>
|
</v-overlay>
|
||||||
</v-app>
|
</v-app>
|
||||||
</template>
|
</template>
|
||||||
@ -39,7 +23,7 @@
|
|||||||
|
|
||||||
import TopToolbar from "@/components/TopToolbar";
|
import TopToolbar from "@/components/TopToolbar";
|
||||||
import BottomNav from "@/components/BottomNav";
|
import BottomNav from "@/components/BottomNav";
|
||||||
import {showError} from "@/utils";
|
import { showError } from "@/utils";
|
||||||
|
|
||||||
|
|
||||||
async function initStore(store) {
|
async function initStore(store) {
|
||||||
@ -68,13 +52,18 @@ export default {
|
|||||||
|
|
||||||
created() {
|
created() {
|
||||||
initStore(this.$store);
|
initStore(this.$store);
|
||||||
this.$store.watch(
|
|
||||||
(state => state.settings.theme.darkMode),
|
const vuetify = this.$vuetify;
|
||||||
(value => {
|
|
||||||
this.$vuetify.theme.dark = value;
|
if (window.matchMedia) {
|
||||||
window.localStorage.setItem("darkMode", value);
|
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
})
|
vuetify.theme.dark = true;
|
||||||
)
|
}
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
||||||
|
console.log(`changed to ${e.matches ? "dark" : "light"} mode`)
|
||||||
|
vuetify.theme.dark = e.matches ? true : false;
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -110,14 +110,11 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async fetch() {
|
async fetch() {
|
||||||
try {
|
try {
|
||||||
this.$store.commit("SET_LOADING", true);
|
|
||||||
await axios.get(this.raw ? `${this.url}?raw=true` : this.url).then(resp => {
|
await axios.get(this.raw ? `${this.url}?raw=true` : this.url).then(resp => {
|
||||||
let {data} = resp;
|
let {data} = resp;
|
||||||
// eslint-disable-next-line no-debugger
|
// eslint-disable-next-line no-debugger
|
||||||
this.proxies = data;
|
this.proxies = data;
|
||||||
}).catch(err => {
|
})
|
||||||
this.$store.commit("SET_ERROR_MESSAGE", err);
|
|
||||||
});
|
|
||||||
|
|
||||||
await axios.get(this.raw ? `${this.url}?target=URI&raw=true` : `${this.url}?target=URI`).then(resp => {
|
await axios.get(this.raw ? `${this.url}?target=URI&raw=true` : `${this.url}?target=URI`).then(resp => {
|
||||||
const {data} = resp;
|
const {data} = resp;
|
||||||
@ -130,8 +127,8 @@ export default {
|
|||||||
this.uris.splice(idx, 0, null);
|
this.uris.splice(idx, 0, null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} finally {
|
} catch (err) {
|
||||||
this.$store.commit("SET_LOADING", false);
|
this.$store.commit("SET_ERROR_MESSAGE", err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -18,11 +18,7 @@ const store = new Vuex.Store({
|
|||||||
collections: {},
|
collections: {},
|
||||||
artifacts: {},
|
artifacts: {},
|
||||||
env: {},
|
env: {},
|
||||||
settings: {
|
settings: {}
|
||||||
theme: {
|
|
||||||
darkMode: window.localStorage.getItem("darkMode") || false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
@ -48,10 +44,6 @@ const store = new Vuex.Store({
|
|||||||
|
|
||||||
SET_ERROR_MESSAGE(state, msg) {
|
SET_ERROR_MESSAGE(state, msg) {
|
||||||
state.errorMessage = msg;
|
state.errorMessage = msg;
|
||||||
},
|
|
||||||
|
|
||||||
SET_DARK_MODE(state, on) {
|
|
||||||
state.settings.theme.darkMode = on;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getIconClass(url) {
|
getIconClass(url) {
|
||||||
return url.indexOf('#invert') !== -1 && !this.$store.state.settings.theme.darkMode ? 'invert' : ''
|
return url.indexOf('#invert') !== -1 && !this.$vuetify.theme.dark ? 'invert' : ''
|
||||||
},
|
},
|
||||||
|
|
||||||
openGist() {
|
openGist() {
|
||||||
|
@ -473,7 +473,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getIconClass(url) {
|
getIconClass(url) {
|
||||||
return url.indexOf('#invert') !== -1 && !this.$store.state.settings.theme.darkMode ? 'invert' : ''
|
return url.indexOf('#invert') !== -1 && !this.$vuetify.theme.dark ? 'invert' : ''
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
if (this.isCollection) {
|
if (this.isCollection) {
|
||||||
|
@ -291,7 +291,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getIconClass(url) {
|
getIconClass(url) {
|
||||||
return url.indexOf('#invert') !== -1 && !this.$store.state.settings.theme.darkMode ? 'invert' : ''
|
return url.indexOf('#invert') !== -1 && !this.$vuetify.theme.dark ? 'invert' : ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,20 +67,6 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-divider></v-divider>
|
|
||||||
<v-subheader>外观</v-subheader>
|
|
||||||
<v-list-item>
|
|
||||||
<v-list-item-content>
|
|
||||||
夜间模式 (实验性支持)
|
|
||||||
</v-list-item-content>
|
|
||||||
<v-list-item-action>
|
|
||||||
<v-switch
|
|
||||||
v-model="settings.theme.darkMode"
|
|
||||||
hide-details
|
|
||||||
label=""
|
|
||||||
/>
|
|
||||||
</v-list-item-action>
|
|
||||||
</v-list-item>
|
|
||||||
</v-list>
|
</v-list>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
@ -89,22 +75,6 @@
|
|||||||
<v-btn color="primary" small text @click="save()">保存</v-btn>
|
<v-btn color="primary" small text @click="save()">保存</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
<!-- <v-card>-->
|
|
||||||
<!-- <v-card-title>-->
|
|
||||||
<!-- <v-icon left>-->
|
|
||||||
<!-- mdi-star-->
|
|
||||||
<!-- </v-icon>-->
|
|
||||||
<!-- 关于-->
|
|
||||||
<!-- </v-card-title>-->
|
|
||||||
<!-- <v-card-text>-->
|
|
||||||
<!-- <v-list>-->
|
|
||||||
<!-- <v-list-item>-->
|
|
||||||
<!-- <v-list-item-title>GitHub</v-list-item-title>-->
|
|
||||||
<!-- </v-list-item>-->
|
|
||||||
<!-- </v-list>-->
|
|
||||||
<!-- </v-card-text>-->
|
|
||||||
<!-- </v-card>-->
|
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user