diff --git a/.gitignore b/.gitignore
index abe85d8..f07b5ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
.DS_Store
# json config
-backend/src/sub-store.json
-backend/src/root.json
+sub-store.json
+root.json
# Logs
logs
diff --git a/web/src/App.vue b/web/src/App.vue
index a2a1034..9638852 100644
--- a/web/src/App.vue
+++ b/web/src/App.vue
@@ -5,32 +5,16 @@
-
+
{{ successMessage }}
-
+
{{ errorMessage }}
-
+
@@ -39,7 +23,7 @@
import TopToolbar from "@/components/TopToolbar";
import BottomNav from "@/components/BottomNav";
-import {showError} from "@/utils";
+import { showError } from "@/utils";
async function initStore(store) {
@@ -68,13 +52,18 @@ export default {
created() {
initStore(this.$store);
- this.$store.watch(
- (state => state.settings.theme.darkMode),
- (value => {
- this.$vuetify.theme.dark = value;
- window.localStorage.setItem("darkMode", value);
- })
- )
+
+ const vuetify = this.$vuetify;
+
+ if (window.matchMedia) {
+ 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: {
diff --git a/web/src/components/ProxyList.vue b/web/src/components/ProxyList.vue
index 92bae7d..988fe0c 100644
--- a/web/src/components/ProxyList.vue
+++ b/web/src/components/ProxyList.vue
@@ -110,14 +110,11 @@ export default {
methods: {
async fetch() {
try {
- this.$store.commit("SET_LOADING", true);
await axios.get(this.raw ? `${this.url}?raw=true` : this.url).then(resp => {
let {data} = resp;
// eslint-disable-next-line no-debugger
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 => {
const {data} = resp;
@@ -130,8 +127,8 @@ export default {
this.uris.splice(idx, 0, null);
}
})
- } finally {
- this.$store.commit("SET_LOADING", false);
+ } catch (err) {
+ this.$store.commit("SET_ERROR_MESSAGE", err);
}
},
diff --git a/web/src/store/index.js b/web/src/store/index.js
index 3ee1b6a..65649e1 100644
--- a/web/src/store/index.js
+++ b/web/src/store/index.js
@@ -18,11 +18,7 @@ const store = new Vuex.Store({
collections: {},
artifacts: {},
env: {},
- settings: {
- theme: {
- darkMode: window.localStorage.getItem("darkMode") || false
- }
- }
+ settings: {}
},
mutations: {
@@ -48,10 +44,6 @@ const store = new Vuex.Store({
SET_ERROR_MESSAGE(state, msg) {
state.errorMessage = msg;
- },
-
- SET_DARK_MODE(state, on) {
- state.settings.theme.darkMode = on;
}
},
diff --git a/web/src/views/Cloud.vue b/web/src/views/Cloud.vue
index fa1ac90..72b94c3 100644
--- a/web/src/views/Cloud.vue
+++ b/web/src/views/Cloud.vue
@@ -352,7 +352,7 @@ export default {
},
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() {
diff --git a/web/src/views/SubEditor.vue b/web/src/views/SubEditor.vue
index 86b334c..de4c202 100644
--- a/web/src/views/SubEditor.vue
+++ b/web/src/views/SubEditor.vue
@@ -473,7 +473,7 @@ export default {
},
methods: {
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() {
if (this.isCollection) {
diff --git a/web/src/views/Subscription.vue b/web/src/views/Subscription.vue
index 22ca594..7f2c2ed 100644
--- a/web/src/views/Subscription.vue
+++ b/web/src/views/Subscription.vue
@@ -291,7 +291,7 @@ export default {
}
},
getIconClass(url) {
- return url.indexOf('#invert') !== -1 && !this.$store.state.settings.theme.darkMode ? 'invert' : ''
+ return url.indexOf('#invert') !== -1 && !this.$vuetify.theme.dark ? 'invert' : ''
}
}
}
diff --git a/web/src/views/User.vue b/web/src/views/User.vue
index f9586f3..24d257e 100644
--- a/web/src/views/User.vue
+++ b/web/src/views/User.vue
@@ -67,20 +67,6 @@
-
- 外观
-
-
- 夜间模式 (实验性支持)
-
-
-
-
-
@@ -89,22 +75,6 @@
保存
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-