🔧 format (packages/client/src/init.ts)
This commit is contained in:
parent
32b86e7285
commit
5ca74febe1
1 changed files with 39 additions and 25 deletions
|
@ -136,7 +136,7 @@ function checkForSplash() {
|
||||||
"yi",
|
"yi",
|
||||||
].includes((lang ?? "en").split("-")[0])
|
].includes((lang ?? "en").split("-")[0])
|
||||||
? "rtl"
|
? "rtl"
|
||||||
: "ltr",
|
: "ltr"
|
||||||
);
|
);
|
||||||
const writingMode = localStorage.getItem("writingMode");
|
const writingMode = localStorage.getItem("writingMode");
|
||||||
switch (writingMode) {
|
switch (writingMode) {
|
||||||
|
@ -224,7 +224,7 @@ function checkForSplash() {
|
||||||
? defineAsyncComponent(() => import("@/ui/visitor.vue"))
|
? defineAsyncComponent(() => import("@/ui/visitor.vue"))
|
||||||
: ui === "deck"
|
: ui === "deck"
|
||||||
? defineAsyncComponent(() => import("@/ui/deck.vue"))
|
? defineAsyncComponent(() => import("@/ui/deck.vue"))
|
||||||
: defineAsyncComponent(() => import("@/ui/universal.vue")),
|
: defineAsyncComponent(() => import("@/ui/universal.vue"))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_DEV_) {
|
if (_DEV_) {
|
||||||
|
@ -282,10 +282,12 @@ function checkForSplash() {
|
||||||
// ログインしてる場合だけ
|
// ログインしてる場合だけ
|
||||||
if (me) {
|
if (me) {
|
||||||
popup(
|
popup(
|
||||||
defineAsyncComponent(() => import("@/components/MkUpdated.vue")),
|
defineAsyncComponent(
|
||||||
|
() => import("@/components/MkUpdated.vue")
|
||||||
|
),
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
"closed",
|
"closed"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +296,9 @@ function checkForSplash() {
|
||||||
if (
|
if (
|
||||||
isSignedIn(me) &&
|
isSignedIn(me) &&
|
||||||
defaultStore.state.tutorial === -1 &&
|
defaultStore.state.tutorial === -1 &&
|
||||||
!["/announcements", "/announcements/"].includes(window.location.pathname)
|
!["/announcements", "/announcements/"].includes(
|
||||||
|
window.location.pathname
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
api("announcements", { withUnreads: true, limit: 10 })
|
api("announcements", { withUnreads: true, limit: 10 })
|
||||||
.then((announcements) => {
|
.then((announcements) => {
|
||||||
|
@ -304,22 +308,25 @@ function checkForSplash() {
|
||||||
if (unreadAnnouncements.length > 3) {
|
if (unreadAnnouncements.length > 3) {
|
||||||
popup(
|
popup(
|
||||||
defineAsyncComponent(
|
defineAsyncComponent(
|
||||||
() => import("@/components/MkManyAnnouncements.vue"),
|
() => import("@/components/MkManyAnnouncements.vue")
|
||||||
),
|
),
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
"closed",
|
"closed"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
for (const item of unreadAnnouncements) {
|
for (const item of unreadAnnouncements) {
|
||||||
if (item.showPopup)
|
if (item.showPopup)
|
||||||
popup(
|
popup(
|
||||||
defineAsyncComponent(
|
defineAsyncComponent(
|
||||||
() => import("@/components/MkAnnouncement.vue"),
|
() =>
|
||||||
|
import(
|
||||||
|
"@/components/MkAnnouncement.vue"
|
||||||
|
)
|
||||||
),
|
),
|
||||||
{ announcement: item },
|
{ announcement: item },
|
||||||
{},
|
{},
|
||||||
"closed",
|
"closed"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,14 +341,16 @@ function checkForSplash() {
|
||||||
applyTheme(
|
applyTheme(
|
||||||
darkMode
|
darkMode
|
||||||
? ColdDeviceStorage.get("darkTheme")
|
? ColdDeviceStorage.get("darkTheme")
|
||||||
: ColdDeviceStorage.get("lightTheme"),
|
: ColdDeviceStorage.get("lightTheme")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
{ immediate: localStorage.theme == null },
|
{ immediate: localStorage.theme == null }
|
||||||
);
|
);
|
||||||
|
|
||||||
const darkTheme = computed(ColdDeviceStorage.makeGetterSetter("darkTheme"));
|
const darkTheme = computed(ColdDeviceStorage.makeGetterSetter("darkTheme"));
|
||||||
const lightTheme = computed(ColdDeviceStorage.makeGetterSetter("lightTheme"));
|
const lightTheme = computed(
|
||||||
|
ColdDeviceStorage.makeGetterSetter("lightTheme")
|
||||||
|
);
|
||||||
|
|
||||||
watch(darkTheme, (theme) => {
|
watch(darkTheme, (theme) => {
|
||||||
if (defaultStore.state.darkMode) {
|
if (defaultStore.state.darkMode) {
|
||||||
|
@ -381,10 +390,10 @@ function checkForSplash() {
|
||||||
(v) => {
|
(v) => {
|
||||||
document.documentElement.style.setProperty(
|
document.documentElement.style.setProperty(
|
||||||
"--modalBgFilter",
|
"--modalBgFilter",
|
||||||
v ? "blur(4px)" : "none",
|
v ? "blur(4px)" : "none"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -396,7 +405,7 @@ function checkForSplash() {
|
||||||
document.documentElement.style.setProperty("--blur", "none");
|
document.documentElement.style.setProperty("--blur", "none");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
let reloadDialogShowing = false;
|
let reloadDialogShowing = false;
|
||||||
|
@ -427,7 +436,7 @@ function checkForSplash() {
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const plugin of ColdDeviceStorage.get("plugins").filter(
|
for (const plugin of ColdDeviceStorage.get("plugins").filter(
|
||||||
(p) => p.active,
|
(p) => p.active
|
||||||
)) {
|
)) {
|
||||||
import("./plugin").then(({ install }) => {
|
import("./plugin").then(({ install }) => {
|
||||||
install(plugin);
|
install(plugin);
|
||||||
|
@ -460,19 +469,22 @@ function checkForSplash() {
|
||||||
toast(
|
toast(
|
||||||
i18n.t("welcomeBackWithName", {
|
i18n.t("welcomeBackWithName", {
|
||||||
name: me.name || me.username,
|
name: me.name || me.username,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem("lastUsed", Date.now().toString());
|
localStorage.setItem("lastUsed", Date.now().toString());
|
||||||
|
|
||||||
const latestDonationInfoShownAt = localStorage.getItem(
|
const latestDonationInfoShownAt = localStorage.getItem(
|
||||||
"latestDonationInfoShownAt",
|
"latestDonationInfoShownAt"
|
||||||
|
);
|
||||||
|
const neverShowDonationInfo = localStorage.getItem(
|
||||||
|
"neverShowDonationInfo"
|
||||||
);
|
);
|
||||||
const neverShowDonationInfo = localStorage.getItem("neverShowDonationInfo");
|
|
||||||
if (
|
if (
|
||||||
neverShowDonationInfo !== "true" &&
|
neverShowDonationInfo !== "true" &&
|
||||||
new Date(me.createdAt).getTime() < Date.now() - 1000 * 60 * 60 * 24 * 3 &&
|
new Date(me.createdAt).getTime() <
|
||||||
|
Date.now() - 1000 * 60 * 60 * 24 * 3 &&
|
||||||
!location.pathname.startsWith("/miauth")
|
!location.pathname.startsWith("/miauth")
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
|
@ -481,10 +493,12 @@ function checkForSplash() {
|
||||||
Date.now() - 1000 * 60 * 60 * 24 * 30
|
Date.now() - 1000 * 60 * 60 * 24 * 30
|
||||||
) {
|
) {
|
||||||
popup(
|
popup(
|
||||||
defineAsyncComponent(() => import("@/components/MkDonation.vue")),
|
defineAsyncComponent(
|
||||||
|
() => import("@/components/MkDonation.vue")
|
||||||
|
),
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
"closed",
|
"closed"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue