ダークモードの同期を強化
This commit is contained in:
parent
eb461481ed
commit
b44e1820a2
@ -163,7 +163,6 @@ import { v4 as uuid } from 'uuid';
|
|||||||
import i18n from './i18n';
|
import i18n from './i18n';
|
||||||
import { host, instanceName } from './config';
|
import { host, instanceName } from './config';
|
||||||
import { search } from './scripts/search';
|
import { search } from './scripts/search';
|
||||||
import { isDeviceDarkmode } from './scripts/is-device-darkmode';
|
|
||||||
import MkToast from './components/toast.vue';
|
import MkToast from './components/toast.vue';
|
||||||
|
|
||||||
const DESKTOP_THRESHOLD = 1100;
|
const DESKTOP_THRESHOLD = 1100;
|
||||||
@ -224,10 +223,6 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
if (this.$store.state.device.syncDeviceDarkMode) {
|
|
||||||
this.$store.commit('device/set', { key: 'darkMode', value: isDeviceDarkmode() });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.$store.getters.isSignedIn) {
|
if (this.$store.getters.isSignedIn) {
|
||||||
this.connection = this.$root.stream.useSharedConnection('main');
|
this.connection = this.$root.stream.useSharedConnection('main');
|
||||||
this.connection.on('notification', this.onNotification);
|
this.connection.on('notification', this.onNotification);
|
||||||
|
@ -144,6 +144,12 @@ os.init(async () => {
|
|||||||
}
|
}
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', mql => {
|
||||||
|
if (os.store.state.device.syncDeviceDarkMode) {
|
||||||
|
os.store.commit('device/set', { key: 'darkMode', value: mql.matches });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if ('Notification' in window && os.store.getters.isSignedIn) {
|
if ('Notification' in window && os.store.getters.isSignedIn) {
|
||||||
// 許可を得ていなかったらリクエスト
|
// 許可を得ていなかったらリクエスト
|
||||||
if (Notification.permission === 'default') {
|
if (Notification.permission === 'default') {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export function isDeviceDarkmode() {
|
export function isDeviceDarkmode() {
|
||||||
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user