🔊 完善基础页面的 log #83

This commit is contained in:
目棃
2024-01-23 18:20:23 +08:00
parent 150755cbef
commit 8aaf18dbe2
15 changed files with 167 additions and 70 deletions

View File

@@ -13,7 +13,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { app, event, fs, tauri, window as TauriWindow } from "@tauri-apps/api"; import { app, event, fs, tauri, window as TauriWindow } from "@tauri-apps/api";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { computed, onBeforeMount, onMounted, ref } from "vue"; import { computed, onBeforeMount, onMounted, onUnmounted, ref } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import TBackTop from "./components/app/t-backTop.vue"; import TBackTop from "./components/app/t-backTop.vue";
@@ -36,6 +36,8 @@ const vuetifyTheme = computed(() => {
return appStore.theme === "dark" ? "dark" : "light"; return appStore.theme === "dark" ? "dark" : "light";
}); });
let themeListener: () => void;
onBeforeMount(async () => { onBeforeMount(async () => {
const win = TauriWindow.getCurrent(); const win = TauriWindow.getCurrent();
isMain.value = win.label === "TeyvatGuide"; isMain.value = win.label === "TeyvatGuide";
@@ -49,19 +51,14 @@ onBeforeMount(async () => {
onMounted(async () => { onMounted(async () => {
document.documentElement.className = theme.value; document.documentElement.className = theme.value;
await listenOnTheme(); themeListener = await event.listen("readTheme", async (e) => {
});
// 监听主题变化
async function listenOnTheme(): Promise<void> {
await event.listen("readTheme", async (e) => {
const themeGet = <string>e.payload; const themeGet = <string>e.payload;
if (theme.value !== themeGet) { if (theme.value !== themeGet) {
theme.value = themeGet; theme.value = themeGet;
document.documentElement.className = theme.value; document.documentElement.className = theme.value;
} }
}); });
} });
// 启动后只执行一次的监听 // 启动后只执行一次的监听
async function listenOnInit(): Promise<void> { async function listenOnInit(): Promise<void> {
@@ -230,6 +227,10 @@ async function checkUpdate(): Promise<void> {
window.open("https://app.btmuli.ink/docs/Changelogs.html"); window.open("https://app.btmuli.ink/docs/Changelogs.html");
} }
} }
onUnmounted(() => {
themeListener();
});
</script> </script>
<style lang="css"> <style lang="css">
.app-container { .app-container {

View File

@@ -228,11 +228,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import { event, window as TauriWindow } from "@tauri-apps/api"; import { event, window as TauriWindow } from "@tauri-apps/api";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { computed, onMounted, ref } from "vue"; import { computed, onMounted, ref, watch } from "vue";
import { useAppStore } from "../../store/modules/app"; import { useAppStore } from "../../store/modules/app";
import { useUserStore } from "../../store/modules/user"; import { useUserStore } from "../../store/modules/user";
import mhyClient from "../../utils/TGClient"; import mhyClient from "../../utils/TGClient";
import TGLogger from "../../utils/TGLogger";
import showSnackbar from "../func/snackbar"; import showSnackbar from "../func/snackbar";
const appStore = useAppStore(); const appStore = useAppStore();
@@ -262,6 +263,10 @@ const themeTitle = computed(() => {
return themeGet.value === "default" ? "夜间模式" : "日间模式"; return themeGet.value === "default" ? "夜间模式" : "日间模式";
}); });
watch(themeTitle, async (val) => {
await TGLogger.Info(`[App][theme] 已切换到${val}`);
});
function collapse(): void { function collapse(): void {
rail.value = !rail.value; rail.value = !rail.value;
appStore.sidebar.collapse = rail.value; appStore.sidebar.collapse = rail.value;

View File

@@ -162,7 +162,7 @@ async function openPath(type: "db" | "user" | "log"): Promise<void> {
break; break;
} }
await dialog.open({ await dialog.open({
directory: type !== "db", directory: false,
defaultPath: targetPath, defaultPath: targetPath,
multiple: false, multiple: false,
}); });

View File

@@ -7,6 +7,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
// utils // utils
import TGLogger from "../../utils/TGLogger";
import { generateShareImg } from "../../utils/TGShare"; import { generateShareImg } from "../../utils/TGShare";
interface TShareBtnProps { interface TShareBtnProps {
@@ -21,6 +22,7 @@ const props = defineProps<TShareBtnProps>();
const emit = defineEmits<TShareBtnEmits>(); const emit = defineEmits<TShareBtnEmits>();
async function shareContent(): Promise<void> { async function shareContent(): Promise<void> {
await TGLogger.Info("[TShareBtn][shareContent] 开始生成分享图片");
emit("update:loading", true); emit("update:loading", true);
props.modelValue.querySelectorAll("details").forEach((item) => { props.modelValue.querySelectorAll("details").forEach((item) => {
if (item.open) { if (item.open) {
@@ -38,6 +40,7 @@ async function shareContent(): Promise<void> {
} }
}); });
emit("update:loading", false); emit("update:loading", false);
await TGLogger.Info("[TShareBtn][shareContent] 生成分享图片完成");
} }
</script> </script>
<style lang="css" scoped> <style lang="css" scoped>

View File

@@ -4,7 +4,9 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { toRaw } from "vue"; import { onMounted, toRaw } from "vue";
import TGLogger from "../../utils/TGLogger";
interface TpUnknownProps { interface TpUnknownProps {
data: TGApp.Plugins.Mys.SctPost.Empty; data: TGApp.Plugins.Mys.SctPost.Empty;
@@ -13,6 +15,12 @@ interface TpUnknownProps {
const props = defineProps<TpUnknownProps>(); const props = defineProps<TpUnknownProps>();
console.warn("tpUnknown", toRaw(props.data.insert)); console.warn("tpUnknown", toRaw(props.data.insert));
onMounted(async () => {
await TGLogger.Warn(
`[tpUnknown][onMounted] 未知的插件数据 ${JSON.stringify(toRaw(props.data))}}`,
);
});
</script> </script>
<style lang="css" scoped> <style lang="css" scoped>
.tp-unknown-box { .tp-unknown-box {

View File

@@ -114,6 +114,7 @@ import ToNamecard from "../../components/overlay/to-namecard.vue";
import { AppAchievementSeriesData, AppNameCardsData } from "../../data"; import { AppAchievementSeriesData, AppNameCardsData } from "../../data";
import TGSqlite from "../../plugins/Sqlite"; import TGSqlite from "../../plugins/Sqlite";
import { useAchievementsStore } from "../../store/modules/achievements"; import { useAchievementsStore } from "../../store/modules/achievements";
import TGLogger from "../../utils/TGLogger";
import { getNowStr } from "../../utils/toolFunc"; import { getNowStr } from "../../utils/toolFunc";
import { getUiafHeader, readUiafData, verifyUiafData } from "../../utils/UIAF"; import { getUiafHeader, readUiafData, verifyUiafData } from "../../utils/UIAF";
@@ -145,10 +146,6 @@ const renderSelect = computed(() => {
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
onBeforeMount(async () => {
await flushOverview();
});
// 更改是否隐藏已完成 // 更改是否隐藏已完成
async function switchHideFin() { async function switchHideFin() {
const text = hideFin.value ? "显示已完成" : "隐藏已完成"; const text = hideFin.value ? "显示已完成" : "隐藏已完成";
@@ -177,8 +174,12 @@ async function flushOverview(): Promise<void> {
} }
onMounted(async () => { onMounted(async () => {
await TGLogger.Info("[Achievements][onMounted] 打开成就页面");
await TGLogger.Info(`[Achievements][onMounted] 当前版本:${achievementsStore.lastVersion}`);
loading.value = true; loading.value = true;
loadingTitle.value = "正在获取成就系列数据"; loadingTitle.value = "正在获取成就系列数据";
await flushOverview();
await TGLogger.Info(`[Achievements][onMounted] ${title.value}`);
allSeriesData.value = await getSeriesData(); allSeriesData.value = await getSeriesData();
achievementsStore.lastVersion = await TGSqlite.getLatestAchievementVersion(); achievementsStore.lastVersion = await TGSqlite.getLatestAchievementVersion();
loadingTitle.value = "正在获取成就数据"; loadingTitle.value = "正在获取成就数据";
@@ -247,10 +248,10 @@ async function searchCard(): Promise<void> {
selectedSeries.value = -1; selectedSeries.value = -1;
loadingTitle.value = "正在搜索"; loadingTitle.value = "正在搜索";
loading.value = true; loading.value = true;
await TGLogger.Info(`[Achievements][searchCard] 搜索内容:${search.value}`);
selectedAchievement.value = await getAchiData("search", search.value); selectedAchievement.value = await getAchiData("search", search.value);
await nextTick(() => { await nextTick(() => {
loading.value = false; loading.value = false;
// 等 500ms 动画
setTimeout(() => { setTimeout(() => {
if (renderSelect.value.length === 0) { if (renderSelect.value.length === 0) {
showSnackbar({ showSnackbar({
@@ -264,10 +265,12 @@ async function searchCard(): Promise<void> {
}); });
}, 500); }, 500);
}); });
await TGLogger.Info(`[Achievements][searchCard] 搜索到 ${renderSelect.value.length} 条成就数据`);
} }
// 导入 UIAF 数据,进行数据合并、刷新 // 导入 UIAF 数据,进行数据合并、刷新
async function importJson(): Promise<void> { async function importJson(): Promise<void> {
await TGLogger.Info("[Achievements][importJson] 导入 UIAF 数据");
const selectedFile = await dialog.open({ const selectedFile = await dialog.open({
title: "选择 UIAF 数据文件", title: "选择 UIAF 数据文件",
multiple: false, multiple: false,
@@ -285,6 +288,7 @@ async function importJson(): Promise<void> {
color: "cancel", color: "cancel",
text: "已取消文件选择", text: "已取消文件选择",
}); });
await TGLogger.Info("[Achievements][importJson] 已取消文件选择");
return; return;
} }
if (!(await verifyUiafData(<string>selectedFile))) { if (!(await verifyUiafData(<string>selectedFile))) {
@@ -292,9 +296,15 @@ async function importJson(): Promise<void> {
color: "error", color: "error",
text: "读取 UIAF 数据失败,请检查文件是否符合规范", text: "读取 UIAF 数据失败,请检查文件是否符合规范",
}); });
await TGLogger.Error("[Achievements][importJson] 读取 UIAF 数据失败,请检查文件是否符合规范");
return; return;
} }
const remoteRaw = await readUiafData(<string>selectedFile); const remoteRaw = await readUiafData(<string>selectedFile);
await TGLogger.Info("[Achievements][importJson] 读取 UIAF 数据成功");
await TGLogger.Info(`[Achievements][importJson] 导入来源:${remoteRaw.info.export_app}`);
await TGLogger.Info(`[Achievements][importJson] 导入版本:${remoteRaw.info.export_app_version}`);
await TGLogger.Info(`[Achievements][importJson] 导入时间:${remoteRaw.info.export_timestamp}`);
await TGLogger.Info(`[Achievements][importJson] 导入数据:${remoteRaw.list.length}`);
loadingTitle.value = "正在解析数据"; loadingTitle.value = "正在解析数据";
loading.value = true; loading.value = true;
loadingTitle.value = "正在合并成就数据"; loadingTitle.value = "正在合并成就数据";
@@ -307,12 +317,14 @@ async function importJson(): Promise<void> {
// 导出 // 导出
async function exportJson(): Promise<void> { async function exportJson(): Promise<void> {
await TGLogger.Info("[Achievements][exportJson] 导出 UIAF 数据");
// 判断是否有数据 // 判断是否有数据
if (achievementsStore.finAchievements === 0) { if (achievementsStore.finAchievements === 0) {
showSnackbar({ showSnackbar({
color: "error", color: "error",
text: "没有可导出的数据", text: "没有可导出的数据",
}); });
await TGLogger.Warn("[Achievements][exportJson] 没有可导出的数据");
return; return;
} }
// 获取本地数据 // 获取本地数据
@@ -331,15 +343,18 @@ async function exportJson(): Promise<void> {
], ],
defaultPath: `${await path.downloadDir()}${path.sep}${fileName}.json`, defaultPath: `${await path.downloadDir()}${path.sep}${fileName}.json`,
}); });
if (isSave) { if (isSave === null) {
await fs.writeTextFile(isSave, JSON.stringify(UiafData));
showSnackbar({ text: "导出成功" });
} else {
showSnackbar({ showSnackbar({
color: "warn", color: "warn",
text: "导出已取消", text: "已取消导出",
}); });
await TGLogger.Info("[Achievements][exportJson] 已取消导出");
return;
} }
await fs.writeTextFile(isSave, JSON.stringify(UiafData));
showSnackbar({ text: "导出成功" });
await TGLogger.Info("[Achievements][exportJson] 导出成功");
await TGLogger.Info(`[Achievements][exportJson] 导出路径:${isSave}`);
} }
function getIcon(series: number): string | undefined { function getIcon(series: number): string | undefined {
@@ -348,6 +363,7 @@ function getIcon(series: number): string | undefined {
// 处理外部导入 // 处理外部导入
async function handleImportOuter(app: string): Promise<void> { async function handleImportOuter(app: string): Promise<void> {
await TGLogger.Info(`[Achievements][handleImportOuter] 导入来源:${app}`);
const confirm = await showConfirm({ const confirm = await showConfirm({
title: "是否导入祈愿数据?", title: "是否导入祈愿数据?",
text: `来源APP${app}`, text: `来源APP${app}`,
@@ -357,6 +373,7 @@ async function handleImportOuter(app: string): Promise<void> {
color: "warn", color: "warn",
text: "已取消导入", text: "已取消导入",
}); });
await TGLogger.Info("[Achievements][handleImportOuter] 已取消导入");
return; return;
} }
// 读取 剪贴板 // 读取 剪贴板
@@ -373,8 +390,11 @@ async function handleImportOuter(app: string): Promise<void> {
color: "success", color: "success",
text: "导入成功,即将刷新页面", text: "导入成功,即将刷新页面",
}); });
await TGLogger.Info("[Achievements][handleImportOuter] 导入成功");
} catch (e) { } catch (e) {
console.error(e); if (e instanceof Error)
await TGLogger.Error(`[Achievements][handleImportOuter] 导入失败 ${e.name}: ${e.message}`);
else console.error(e);
showSnackbar({ showSnackbar({
color: "error", color: "error",
text: "读取 UIAF 数据失败,请检查文件是否符合规范", text: "读取 UIAF 数据失败,请检查文件是否符合规范",
@@ -411,6 +431,11 @@ async function setAchi(
target ? "已完成" : "未完成" target ? "已完成" : "未完成"
}`, }`,
}); });
await TGLogger.Info(
`[Achievements][setAchi] 已将成就 ${newAchievement.name}[${newAchievement.id}] 标记为 ${
target ? "已完成" : "未完成"
}`,
);
} }
/* 以下为数据库操作 */ /* 以下为数据库操作 */

View File

@@ -42,6 +42,7 @@ import { nextTick, onMounted, ref } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import ToLoading from "../../components/overlay/to-loading.vue"; import ToLoading from "../../components/overlay/to-loading.vue";
import TGLogger from "../../utils/TGLogger";
import { createTGWindow } from "../../utils/TGWindow"; import { createTGWindow } from "../../utils/TGWindow";
import TGRequest from "../../web/request/TGRequest"; import TGRequest from "../../web/request/TGRequest";
import TGUtils from "../../web/utils/TGUtils"; import TGUtils from "../../web/utils/TGUtils";
@@ -74,6 +75,7 @@ const annoCards = ref<AnnoCard>({
const annoData = ref<TGApp.BBS.Announcement.ListData>(<TGApp.BBS.Announcement.ListData>{}); const annoData = ref<TGApp.BBS.Announcement.ListData>(<TGApp.BBS.Announcement.ListData>{});
onMounted(async () => { onMounted(async () => {
await TGLogger.Info("[Announcements][onMounted] 打开公告页面");
loadingTitle.value = "正在获取公告数据"; loadingTitle.value = "正在获取公告数据";
loading.value = true; loading.value = true;
annoData.value = await TGRequest.Anno.getList(); annoData.value = await TGRequest.Anno.getList();
@@ -84,7 +86,7 @@ onMounted(async () => {
game: listCards.filter((item) => item.typeLabel === AnnoType.game), game: listCards.filter((item) => item.typeLabel === AnnoType.game),
}; };
loadingTitle.value = "正在渲染公告数据"; loadingTitle.value = "正在渲染公告数据";
await nextTick(() => { await nextTick(async () => {
loading.value = false; loading.value = false;
}); });
}); });
@@ -96,13 +98,16 @@ function parseTitle(title: string): string {
} }
async function switchNews(): Promise<void> { async function switchNews(): Promise<void> {
await TGLogger.Info("[Announcements][switchNews] 切换米游社咨讯");
await router.push("/news/2"); await router.push("/news/2");
} }
function createAnno(item: TGApp.App.Announcement.ListCard): void { function createAnno(item: TGApp.App.Announcement.ListCard): void {
const annoPath = `/anno_detail/${item.id}`; const annoPath = `/anno_detail/${item.id}`;
const annoTitle = `Anno_${item.id} ${item.title}`; const annoTitle = `Anno_${item.id} ${item.title}`;
createTGWindow(annoPath, "Sub_window", annoTitle, 960, 720, false, false); TGLogger.Info(`[Announcements][createAnno][${item.id}] 打开公告窗口`).then(() =>
createTGWindow(annoPath, "Sub_window", annoTitle, 960, 720, false, false),
);
} }
</script> </script>

View File

@@ -67,6 +67,7 @@ import { useAppStore } from "../../store/modules/app";
import { useHomeStore } from "../../store/modules/home"; import { useHomeStore } from "../../store/modules/home";
import { backUpUserData, restoreUserData } from "../../utils/dataBS"; import { backUpUserData, restoreUserData } from "../../utils/dataBS";
import { getBuildTime } from "../../utils/TGBuild"; import { getBuildTime } from "../../utils/TGBuild";
import TGLogger from "../../utils/TGLogger";
import { bytesToSize, getCacheDir, getDeviceInfo, getRandomString } from "../../utils/toolFunc"; import { bytesToSize, getCacheDir, getDeviceInfo, getRandomString } from "../../utils/toolFunc";
import TGRequest from "../../web/request/TGRequest"; import TGRequest from "../../web/request/TGRequest";
@@ -83,7 +84,10 @@ const loadingTitle = ref<string>("正在加载...");
const loadingSub = ref<string>(""); const loadingSub = ref<string>("");
const showReset = ref<boolean>(false); const showReset = ref<boolean>(false);
onMounted(() => (loading.value = false)); onMounted(async () => {
await TGLogger.Info("[Config] 打开设置页面");
loading.value = false;
});
// 备份数据 // 备份数据
async function confirmBackup(): Promise<void> { async function confirmBackup(): Promise<void> {
@@ -112,6 +116,7 @@ async function confirmBackup(): Promise<void> {
}); });
return; return;
} }
await TGLogger.Info(`[Config][confirmBackup] 选择备份路径 ${dir.toString()}`);
if (typeof dir !== "string") { if (typeof dir !== "string") {
showSnackbar({ showSnackbar({
color: "error", color: "error",
@@ -120,6 +125,8 @@ async function confirmBackup(): Promise<void> {
return; return;
} }
saveDir = dir; saveDir = dir;
} else {
await TGLogger.Info(`[Config][confirmBackup] 备份到默认路径 ${saveDir}`);
} }
loadingTitle.value = "正在备份数据..."; loadingTitle.value = "正在备份数据...";
loading.value = true; loading.value = true;
@@ -127,6 +134,7 @@ async function confirmBackup(): Promise<void> {
await backUpUserData(saveDir); await backUpUserData(saveDir);
loading.value = false; loading.value = false;
showSnackbar({ text: "数据已备份!" }); showSnackbar({ text: "数据已备份!" });
await TGLogger.Info("[Config][confirmBackup] 备份完成");
} }
// 恢复数据 // 恢复数据
@@ -156,6 +164,7 @@ async function confirmRestore(): Promise<void> {
}); });
return; return;
} }
await TGLogger.Info(`[Config][confirmRestore] 选择恢复路径 ${dir.toString()}`);
if (typeof dir !== "string") { if (typeof dir !== "string") {
showSnackbar({ showSnackbar({
color: "error", color: "error",
@@ -164,12 +173,16 @@ async function confirmRestore(): Promise<void> {
return; return;
} }
saveDir = dir; saveDir = dir;
} else {
await TGLogger.Info(`[Config][confirmRestore] 恢复到默认路径 ${saveDir}`);
} }
loadingTitle.value = "正在恢复数据..."; loadingTitle.value = "正在恢复数据...";
loading.value = true; loading.value = true;
loadingSub.value = "祈愿数据需单独恢复"; loadingSub.value = "祈愿数据需单独恢复";
await restoreUserData(saveDir); await restoreUserData(saveDir);
loading.value = false; loading.value = false;
showSnackbar({ text: "数据已恢复!" });
await TGLogger.Info("[Config][confirmRestore] 恢复完成");
} }
// 更新数据 // 更新数据
@@ -194,6 +207,7 @@ async function confirmUpdate(title?: string): Promise<void> {
showSnackbar({ showSnackbar({
text: "数据库已更新!", text: "数据库已更新!",
}); });
await TGLogger.Info("[Config][confirmUpdate] 数据库更新完成");
// 刷新 // 刷新
window.location.reload(); window.location.reload();
} }
@@ -201,6 +215,7 @@ async function confirmUpdate(title?: string): Promise<void> {
// 更新设备信息 // 更新设备信息
async function confirmUpdateDevice(force?: boolean): Promise<void> { async function confirmUpdateDevice(force?: boolean): Promise<void> {
if (force !== undefined && force) { if (force !== undefined && force) {
await TGLogger.Info("[Config][confirmUpdateDevice][force] 开始强制更新设备信息");
const resF = await showConfirm({ const resF = await showConfirm({
title: "确认强制更新设备信息吗?", title: "确认强制更新设备信息吗?",
text: `DeviceFp:${appStore.deviceInfo.device_fp}`, text: `DeviceFp:${appStore.deviceInfo.device_fp}`,
@@ -210,6 +225,7 @@ async function confirmUpdateDevice(force?: boolean): Promise<void> {
text: "已取消强制更新设备信息", text: "已取消强制更新设备信息",
color: "cancel", color: "cancel",
}); });
await TGLogger.Info("[Config][confirmUpdateDevice][force] 取消强制更新设备信息");
return; return;
} }
appStore.deviceInfo = await TGRequest.Device.getFp(); appStore.deviceInfo = await TGRequest.Device.getFp();
@@ -219,13 +235,17 @@ async function confirmUpdateDevice(force?: boolean): Promise<void> {
text: `设备信息获取失败!已使用随机值 ${appStore.deviceInfo.device_fp} 代替`, text: `设备信息获取失败!已使用随机值 ${appStore.deviceInfo.device_fp} 代替`,
color: "warn", color: "warn",
}); });
await TGLogger.Warn("[Config][confirmUpdateDevice][force] 设备信息获取失败!已使用随机值代替");
} else { } else {
showSnackbar({ showSnackbar({
text: "设备信息已更新! DeviceFp: " + appStore.deviceInfo.device_fp, text: "设备信息已更新! DeviceFp: " + appStore.deviceInfo.device_fp,
}); });
} }
await TGSqlite.saveAppData("deviceInfo", JSON.stringify(appStore.deviceInfo));
await TGLogger.Info("[Config][confirmUpdateDevice][force] 设备信息更新完成");
return; return;
} }
await TGLogger.Info("[Config][confirmUpdateDevice] 开始更新设备信息");
const localFp = getDeviceInfo("device_fp"); const localFp = getDeviceInfo("device_fp");
if (localFp !== "0000000000000") { if (localFp !== "0000000000000") {
const res = await showConfirm({ const res = await showConfirm({
@@ -237,6 +257,7 @@ async function confirmUpdateDevice(force?: boolean): Promise<void> {
text: "已取消更新设备信息", text: "已取消更新设备信息",
color: "cancel", color: "cancel",
}); });
await TGLogger.Info("[Config][confirmUpdateDevice] 取消更新设备信息");
return; return;
} }
} }
@@ -248,16 +269,19 @@ async function confirmUpdateDevice(force?: boolean): Promise<void> {
showSnackbar({ showSnackbar({
text: "设备信息获取失败!已使用随机值代替", text: "设备信息获取失败!已使用随机值代替",
}); });
await TGLogger.Warn("[Config][confirmUpdateDevice] 设备信息获取失败!已使用随机值代替");
return; return;
} }
showSnackbar({ showSnackbar({
text: "设备信息已更新! DeviceFp: " + appStore.deviceInfo.device_fp, text: "设备信息已更新! DeviceFp: " + appStore.deviceInfo.device_fp,
}); });
await TGSqlite.saveAppData("deviceInfo", JSON.stringify(appStore.deviceInfo)); await TGSqlite.saveAppData("deviceInfo", JSON.stringify(appStore.deviceInfo));
await TGLogger.Info("[Config][confirmUpdateDevice] 设备信息更新完成");
} }
// 清除用户缓存 // 清除用户缓存
async function confirmDelCache(): Promise<void> { async function confirmDelCache(): Promise<void> {
await TGLogger.Info("[Config][confirmDelCache] 开始清除缓存");
const CacheDir = await getCacheDir(); const CacheDir = await getCacheDir();
if (CacheDir === false) { if (CacheDir === false) {
showSnackbar({ showSnackbar({
@@ -276,6 +300,7 @@ async function confirmDelCache(): Promise<void> {
cacheBSize += size; cacheBSize += size;
} }
const cacheSize = bytesToSize(cacheBSize); const cacheSize = bytesToSize(cacheBSize);
await TGLogger.Info(`[Config][confirmDelCache] 当前缓存大小为 ${cacheSize}`);
loading.value = false; loading.value = false;
const timeEnd = Date.now(); const timeEnd = Date.now();
const res = await showConfirm({ const res = await showConfirm({
@@ -287,6 +312,7 @@ async function confirmDelCache(): Promise<void> {
color: "cancel", color: "cancel",
text: "已取消清除缓存", text: "已取消清除缓存",
}); });
await TGLogger.Info("[Config][confirmDelCache] 取消清除缓存");
return; return;
} }
for (const dir of CacheDir) { for (const dir of CacheDir) {
@@ -295,15 +321,13 @@ async function confirmDelCache(): Promise<void> {
showSnackbar({ showSnackbar({
text: "缓存已清除!请重新启动应用!", text: "缓存已清除!请重新启动应用!",
}); });
await new Promise(() => { await TGLogger.Info("[Config][confirmDelCache] 缓存清除完成");
setTimeout(async () => {
await TauriProcess.exit(); await TauriProcess.exit();
}, 1500);
});
} }
// 恢复默认设置 // 恢复默认设置
async function confirmResetApp(): Promise<void> { async function confirmResetApp(): Promise<void> {
await TGLogger.Info("[Config][confirmResetApp] 开始恢复默认设置");
const res = await showConfirm({ const res = await showConfirm({
title: "确认恢复默认设置吗?", title: "确认恢复默认设置吗?",
}); });
@@ -312,11 +336,13 @@ async function confirmResetApp(): Promise<void> {
color: "cancel", color: "cancel",
text: "已取消恢复默认设置", text: "已取消恢复默认设置",
}); });
await TGLogger.Info("[Config][confirmResetApp] 取消恢复默认设置");
return; return;
} }
appStore.init(); appStore.init();
homeStore.init(); homeStore.init();
achievementsStore.init(); achievementsStore.init();
await TGLogger.Info("[Config][confirmResetApp] 恢复默认设置完成");
showSnackbar({ text: "已恢复默认配置!即将刷新页面..." }); showSnackbar({ text: "已恢复默认配置!即将刷新页面..." });
setTimeout(() => { setTimeout(() => {
window.location.reload(); window.location.reload();
@@ -354,6 +380,7 @@ async function tryShowReset(): Promise<void> {
// 重置数据库 // 重置数据库
async function confirmResetDB(title?: string): Promise<void> { async function confirmResetDB(title?: string): Promise<void> {
await TGLogger.Info("[Config][confirmResetDB] 开始重置数据库");
const res = await showConfirm({ const res = await showConfirm({
title: title ?? "确认重置数据库吗?", title: title ?? "确认重置数据库吗?",
text: "请确认已经备份关键数据", text: "请确认已经备份关键数据",
@@ -363,11 +390,13 @@ async function confirmResetDB(title?: string): Promise<void> {
color: "cancel", color: "cancel",
text: "已取消重置数据库", text: "已取消重置数据库",
}); });
await TGLogger.Info("[Config][confirmResetDB] 取消重置数据库");
return; return;
} }
loadingTitle.value = "正在重置数据库..."; loadingTitle.value = "正在重置数据库...";
loading.value = true; loading.value = true;
await TGSqlite.reset(); await TGSqlite.reset();
await TGLogger.Info("[Config][confirmResetDB] 数据库重置完成");
loading.value = false; loading.value = false;
showSnackbar({ showSnackbar({
text: "数据库已重置!请进行再次检查。", text: "数据库已重置!请进行再次检查。",

View File

@@ -17,16 +17,16 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, markRaw, onMounted, onUnmounted, onUpdated, ref, watch } from "vue"; import { markRaw, onMounted, onUnmounted, onUpdated, ref } from "vue";
import showSnackbar from "../../components/func/snackbar"; import showSnackbar from "../../components/func/snackbar";
import TCalendar from "../../components/home/t-calendar.vue"; import TCalendar from "../../components/home/t-calendar.vue";
import TPool from "../../components/home/t-pool.vue"; import TPool from "../../components/home/t-pool.vue";
import TPosition from "../../components/home/t-position.vue"; import TPosition from "../../components/home/t-position.vue";
import TUserBadge from "../../components/home/t-userBadge.vue";
import ToLoading from "../../components/overlay/to-loading.vue"; import ToLoading from "../../components/overlay/to-loading.vue";
import { useAppStore } from "../../store/modules/app"; import { useAppStore } from "../../store/modules/app";
import { useHomeStore } from "../../store/modules/home"; import { useHomeStore } from "../../store/modules/home";
import TGLogger from "../../utils/TGLogger";
// store // store
const appStore = useAppStore(); const appStore = useAppStore();
@@ -62,6 +62,8 @@ function readLoading(): void {
} }
onMounted(async () => { onMounted(async () => {
const items = showHome.value.join("、");
await TGLogger.Info(`[Home][onMounted] 打开首页,当前显示:${items}`);
loadingTitle.value = "正在加载首页"; loadingTitle.value = "正在加载首页";
const isProdEnv = import.meta.env.MODE === "production"; const isProdEnv = import.meta.env.MODE === "production";
// 获取当前环境 // 获取当前环境
@@ -85,7 +87,7 @@ onMounted(async () => {
timer.value = setInterval(readLoading, 100); timer.value = setInterval(readLoading, 100);
}); });
function submitHome(): void { async function submitHome(): Promise<void> {
// 获取已选 // 获取已选
const show = showHome.value; const show = showHome.value;
if (show.length < 1) { if (show.length < 1) {
@@ -100,6 +102,7 @@ function submitHome(): void {
color: "success", color: "success",
text: "设置成功!", text: "设置成功!",
}); });
await TGLogger.Info("[Home][submitHome] 首页设置成功,当前显示:" + show.join("、"));
setTimeout(() => { setTimeout(() => {
window.location.reload(); window.location.reload();
}, 1000); }, 1000);
@@ -107,7 +110,11 @@ function submitHome(): void {
// 监听定时器 // 监听定时器
onUpdated(() => { onUpdated(() => {
if (!loading.value) clearInterval(timer.value); if (!loading.value && timer.value !== null) {
TGLogger.Info("[Home][onMounted] 首页加载完成");
clearInterval(timer.value);
timer.value = null;
}
}); });
onUnmounted(() => { onUnmounted(() => {

View File

@@ -97,6 +97,7 @@ import ToChannel from "../../components/overlay/to-channel.vue";
import ToLoading from "../../components/overlay/to-loading.vue"; import ToLoading from "../../components/overlay/to-loading.vue";
import TpAvatar from "../../components/post/tp-avatar.vue"; import TpAvatar from "../../components/post/tp-avatar.vue";
import Mys from "../../plugins/Mys"; import Mys from "../../plugins/Mys";
import TGLogger from "../../utils/TGLogger";
import { createPost } from "../../utils/TGWindow"; import { createPost } from "../../utils/TGWindow";
// 类型定义 // 类型定义
@@ -158,6 +159,7 @@ const rawData = ref<RawData>({
}); });
onMounted(async () => { onMounted(async () => {
await TGLogger.Info(`[News][${gid}][onMounted] 打开咨讯页面`);
tab.value = "notice"; tab.value = "notice";
await firstLoad("notice"); await firstLoad("notice");
}); });
@@ -176,9 +178,11 @@ async function firstLoad(key: NewsKey): Promise<void> {
await nextTick(() => { await nextTick(() => {
loading.value = false; loading.value = false;
}); });
await TGLogger.Info(`[News][${gid}][firstLoad] 获取${rawData.value[key].name}数据成功`);
} }
async function switchAnno(): Promise<void> { async function switchAnno(): Promise<void> {
await TGLogger.Info(`[News][${gid}][switchAnno] 切换公告`);
await router.push("/announcements"); await router.push("/announcements");
} }

View File

@@ -98,6 +98,7 @@ import ToLoading from "../../components/overlay/to-loading.vue";
import TpAvatar from "../../components/post/tp-avatar.vue"; import TpAvatar from "../../components/post/tp-avatar.vue";
import Mys from "../../plugins/Mys"; import Mys from "../../plugins/Mys";
import TGClient from "../../utils/TGClient"; import TGClient from "../../utils/TGClient";
import TGLogger from "../../utils/TGLogger";
import { createPost } from "../../utils/TGWindow"; import { createPost } from "../../utils/TGWindow";
const loading = ref<boolean>(true); const loading = ref<boolean>(true);
@@ -201,6 +202,9 @@ const nav = ref<TGApp.BBS.Navigator.Navigator[]>([]);
const search = ref<string>(); const search = ref<string>();
onMounted(async () => { onMounted(async () => {
await TGLogger.Info(
`[Posts][${curGameLabel.value}][onMounted][${curForumLabel.value}] 打开帖子列表`,
);
loading.value = true; loading.value = true;
await freshNavData(); await freshNavData();
await freshPostData(); await freshPostData();
@@ -287,10 +291,14 @@ function toBBS(link: URL): void {
} }
async function freshNavData(): Promise<void> { async function freshNavData(): Promise<void> {
await TGLogger.Info(`[Posts][${curGameLabel.value}][freshNavData] 获取网页活动`);
nav.value = await Mys.Posts.nav(curGid.value); nav.value = await Mys.Posts.nav(curGid.value);
} }
async function freshPostData(): Promise<void> { async function freshPostData(): Promise<void> {
await TGLogger.Info(
`[Posts][${curGameLabel.value}][freshPostData][${curForumLabel.value}] 刷新帖子列表`,
);
loading.value = true; loading.value = true;
loadingTitle.value = `正在加载 ${curGameLabel.value}-${curForumLabel.value}-${curSortLabel.value} 的数据`; loadingTitle.value = `正在加载 ${curGameLabel.value}-${curForumLabel.value}-${curSortLabel.value} 的数据`;
const postsGet = await Mys.Posts.get(curForum.value, curSortType.value); const postsGet = await Mys.Posts.get(curForum.value, curSortType.value);

View File

@@ -1,7 +1,7 @@
/** /**
* @file utils/TGClient.ts * @file utils/TGClient.ts
* @desc 负责米游社客户端的 callback 处理 * @desc 负责米游社客户端的 callback 处理
* @since Beta v0.4.0 * @since Beta v0.4.2
*/ */
import { event, invoke } from "@tauri-apps/api"; import { event, invoke } from "@tauri-apps/api";
@@ -9,6 +9,7 @@ import type { Event } from "@tauri-apps/api/event";
import { appWindow, WebviewWindow } from "@tauri-apps/api/window"; import { appWindow, WebviewWindow } from "@tauri-apps/api/window";
import { parseLink } from "./linkParser"; import { parseLink } from "./linkParser";
import TGLogger from "./TGLogger";
import { createPost } from "./TGWindow"; import { createPost } from "./TGWindow";
import { getDeviceInfo } from "./toolFunc"; import { getDeviceInfo } from "./toolFunc";
import showSnackbar from "../components/func/snackbar"; import showSnackbar from "../components/func/snackbar";
@@ -89,7 +90,7 @@ class TGClient {
/** /**
* @func callback * @func callback
* @since Beta v0.3.4 * @since Beta v0.4.2
* @desc 回调函数 * @desc 回调函数
* @param {string} callback - 回调函数名 * @param {string} callback - 回调函数名
* @param {object} data - 回调数据 * @param {object} data - 回调数据
@@ -103,7 +104,6 @@ class TGClient {
}; };
const js = `javascript:mhyWebBridge("${callback}", ${JSON.stringify(response)});`; const js = `javascript:mhyWebBridge("${callback}", ${JSON.stringify(response)});`;
console.info(`[callback] ${js}`); console.info(`[callback] ${js}`);
await invoke("create_mhy_client", { func: "execute_js", url: "" });
await invoke("execute_js", { label: "mhy_client", js }); await invoke("execute_js", { label: "mhy_client", js });
} }
@@ -167,7 +167,7 @@ class TGClient {
/** /**
* @func handleCallback * @func handleCallback
* @since Beta v0.3.9 * @since Beta v0.4.2
* @desc 处理米游社客户端的 callback * @desc 处理米游社客户端的 callback
* @param {Event<string>} arg - 事件参数 * @param {Event<string>} arg - 事件参数
* @returns {Promise<void>} - 返回值 * @returns {Promise<void>} - 返回值
@@ -178,7 +178,10 @@ class TGClient {
await this.handleCustomCallback(argParse); await this.handleCustomCallback(argParse);
return; return;
} }
console.warn(`[${argParse.method}] ${JSON.stringify(argParse.payload)}`); await TGLogger.Warn(`[TGClient][handleCallback] ${JSON.stringify(argParse)}`, false);
await TGLogger.Info(
`[TGClient][handleCallback] 处理回调 ${argParse.method}${argParse.callback}`,
);
await this.hideSideBar(); await this.hideSideBar();
await this.hideOverlay(); await this.hideOverlay();
switch (argParse.method) { switch (argParse.method) {
@@ -275,6 +278,7 @@ class TGClient {
* @returns {Promise<void>} - 返回值 * @returns {Promise<void>} - 返回值
*/ */
async handleCustomCallback(arg: TGApp.Plugins.JSBridge.Arg<any>): Promise<void> { async handleCustomCallback(arg: TGApp.Plugins.JSBridge.Arg<any>): Promise<void> {
await TGLogger.Info(`[TGClient][handleCustomCallback] ${JSON.stringify(arg)}`);
switch (arg.method) { switch (arg.method) {
case "teyvat_open": case "teyvat_open":
createPost(<string>arg.payload); createPost(<string>arg.payload);
@@ -454,16 +458,13 @@ class TGClient {
await this.window.close(); await this.window.close();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
await invoke<InvokeArg>("create_mhy_client", { await invoke<InvokeArg>("create_mhy_client", { func: "default", url: "" });
func: "default",
url: "https://api-static.mihoyo.com/",
});
await this.open(func, url); await this.open(func, url);
} }
} }
if (url === undefined) url = this.getUrl(func); if (url === undefined) url = this.getUrl(func);
this.route = [url]; this.route = [url];
console.log(`[open] ${url}`); await TGLogger.Info(`[TGClient][open][${func}] ${url}`);
await invoke<InvokeArg>("create_mhy_client", { func, url }); await invoke<InvokeArg>("create_mhy_client", { func, url });
this.window = WebviewWindow.getByLabel("mhy_client"); this.window = WebviewWindow.getByLabel("mhy_client");
await this.window?.show(); await this.window?.show();

View File

@@ -1,19 +1,20 @@
/** /**
* @file utils/TGShare.ts * @file utils/TGShare.ts
* @description 生成分享截图并保存到本地 * @description 生成分享截图并保存到本地
* @since Beta v0.3.9 * @since Beta v0.4.2
*/ */
import { dialog, fs, http, path } from "@tauri-apps/api"; import { dialog, fs, http, path } from "@tauri-apps/api";
import html2canvas from "html2canvas"; import html2canvas from "html2canvas";
import TGLogger from "./TGLogger";
import { bytesToSize } from "./toolFunc"; import { bytesToSize } from "./toolFunc";
import showConfirm from "../components/func/confirm"; import showConfirm from "../components/func/confirm";
import showSnackbar from "../components/func/snackbar"; import showSnackbar from "../components/func/snackbar";
/** /**
* @description 保存图片-canvas * @description 保存图片-canvas
* @since Beta v0.3.7 * @since Beta v0.4.2
* @param {Uint8Array} buffer - 图片数据 * @param {Uint8Array} buffer - 图片数据
* @param {string} filename - 文件名 * @param {string} filename - 文件名
* @returns {Promise<void>} 无返回值 * @returns {Promise<void>} 无返回值
@@ -32,6 +33,7 @@ async function saveCanvasImg(buffer: Uint8Array, filename: string): Promise<void
contents: buffer, contents: buffer,
}); });
}); });
await TGLogger.Info(`[saveCanvasImg][${filename}] 已将图像保存到本地`);
} }
/** /**
@@ -72,7 +74,7 @@ function getShareImgBgColor(): string {
/** /**
* @description 生成分享截图 * @description 生成分享截图
* @since Beta v0.3.9 * @since Beta v0.4.2
* @param {string} fileName - 文件名 * @param {string} fileName - 文件名
* @param {HTMLElement} element - 元素 * @param {HTMLElement} element - 元素
* @param {number} scale - 缩放比例 * @param {number} scale - 缩放比例
@@ -108,6 +110,7 @@ export async function generateShareImg(
); );
const size = buffer.length; const size = buffer.length;
const sizeStr = bytesToSize(size); const sizeStr = bytesToSize(size);
await TGLogger.Info(`[generateShareImg][${fileName}] 图像大小为 ${sizeStr}`);
if (size > 80000000) { if (size > 80000000) {
showSnackbar({ showSnackbar({
text: `图像大小为 ${sizeStr},过大,无法保存`, text: `图像大小为 ${sizeStr},过大,无法保存`,
@@ -136,6 +139,7 @@ export async function generateShareImg(
showSnackbar({ showSnackbar({
text: `已将 ${fileName} 复制到剪贴板,大小为 ${sizeStr}`, text: `已将 ${fileName} 复制到剪贴板,大小为 ${sizeStr}`,
}); });
await TGLogger.Info(`[generateShareImg][${fileName}] 已将图像复制到剪贴板`);
} catch (e) { } catch (e) {
await saveCanvasImg(buffer, fileName); await saveCanvasImg(buffer, fileName);
} }

View File

@@ -1,12 +1,14 @@
/** /**
* @file utils/TGWindow.ts * @file utils/TGWindow.ts
* @description 窗口创建相关工具函数 * @description 窗口创建相关工具函数
* @since Beta v0.3.8 * @since Beta v0.4.2
*/ */
import { invoke, window as TauriWindow } from "@tauri-apps/api"; import { invoke, window as TauriWindow } from "@tauri-apps/api";
import type { WindowOptions } from "@tauri-apps/api/types/window"; import type { WindowOptions } from "@tauri-apps/api/types/window";
import TGLogger from "./TGLogger";
/** /**
* @description 创建TG窗口 * @description 创建TG窗口
* @since Beta v0.3.4 * @since Beta v0.3.4
@@ -71,7 +73,7 @@ export function createTGWindow(
/** /**
* @description 打开帖子 * @description 打开帖子
* @since Beta v0.3.8 * @since Beta v0.4.2
* @param {TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard} item 帖子内容或ID * @param {TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard} item 帖子内容或ID
* @param {string} title 帖子标题 * @param {string} title 帖子标题
* @returns {void} * @returns {void}
@@ -80,7 +82,7 @@ export function createPost(
item: TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard, item: TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard,
title?: string, title?: string,
): void { ): void {
let postId, postTitle; let postId: string, postTitle: string;
if (typeof item === "string" || typeof item === "number") { if (typeof item === "string" || typeof item === "number") {
postId = item.toString(); postId = item.toString();
postTitle = title ? `Post_${postId} ${title}` : `Post_${postId}`; postTitle = title ? `Post_${postId} ${title}` : `Post_${postId}`;
@@ -90,17 +92,7 @@ export function createPost(
} }
const postPath = `/post_detail/${postId}`; const postPath = `/post_detail/${postId}`;
createTGWindow(postPath, "Sub_window", postTitle, 960, 720, false, false); createTGWindow(postPath, "Sub_window", postTitle, 960, 720, false, false);
} TGLogger.Info(`[createPost][${postId}] 打开帖子`).catch((err) => {
console.error(err);
/** });
* @description 打开 Wiki
* @since Beta v0.3.8
* @param {string} dir 目录
* @param {string} name 文件名
* @returns {void}
*/
export function createWiki(dir: string, name: string): void {
const dirName = dir === "GCG" ? dir : dir.toLowerCase();
const wikiPath = `/wiki/detail/${dirName}/${name}`;
createTGWindow(wikiPath, "Sub_window", `Wiki_${dirName}_${name}`, 960, 720, false, false);
} }

View File

@@ -124,7 +124,7 @@ onMounted(async () => {
loadingEmpty.value = true; loadingEmpty.value = true;
loadingTitle.value = "未找到数据"; loadingTitle.value = "未找到数据";
await appWindow.setTitle("未找到数据"); await appWindow.setTitle("未找到数据");
await TGLogger.Error("[t-post.vue] PostID 不存在"); await TGLogger.Error("[t-post][onMounted] PostID 不存在");
return; return;
} }
// 获取数据 // 获取数据
@@ -137,7 +137,7 @@ onMounted(async () => {
await appWindow.setTitle(`Post_${postId} ${postData.value.post.subject}`); await appWindow.setTitle(`Post_${postId} ${postData.value.post.subject}`);
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
await TGLogger.Error(`[t-post.vue] ${error.name}: ${error.message}`); await TGLogger.Error(`[t-post][${postId}] ${error.name}: ${error.message}`);
loadingTitle.value = error.name; loadingTitle.value = error.name;
loadingSub.value = error.message; loadingSub.value = error.message;
} else { } else {
@@ -149,9 +149,13 @@ onMounted(async () => {
await appWindow.setTitle(`Post_${postId} Parsing Error`); await appWindow.setTitle(`Post_${postId} Parsing Error`);
return; return;
} }
await TGLogger.Info(`[t-post][${postId}][onMounted] ${postData.value.post.subject}`);
// 打开 json // 打开 json
const isDev = useAppStore().devMode ?? false; const isDev = useAppStore().devMode ?? false;
if (isDev) createPostJson(postId); if (isDev) {
await TGLogger.Info(`[t-post][${postId}][onMounted] 打开 JSON 窗口`);
createPostJson(postId);
}
await nextTick(() => { await nextTick(() => {
shareTimeTimer.value = setInterval(() => { shareTimeTimer.value = setInterval(() => {
shareTime.value = Math.floor(Date.now() / 1000); shareTime.value = Math.floor(Date.now() / 1000);
@@ -161,15 +165,17 @@ onMounted(async () => {
}); });
}); });
watch(loadShare, (value) => { watch(loadShare, async (value) => {
if (value) { if (value) {
shareTime.value = Math.floor(Date.now() / 1000); shareTime.value = Math.floor(Date.now() / 1000);
loadingTitle.value = "正在生成分享图片"; loadingTitle.value = "正在生成分享图片";
loadingSub.value = `${shareTitle.value}.png`; loadingSub.value = `${shareTitle.value}.png`;
loading.value = true; loading.value = true;
await TGLogger.Info(`[t-post.vue][${postId}][share] 生成分享图片:${shareTitle.value}.png`);
} else { } else {
loadingSub.value = ""; loadingSub.value = "";
loading.value = false; loading.value = false;
await TGLogger.Info(`[t-post.vue][${postId}][share] 生成分享图片完成:${shareTitle.value}.png`);
} }
}); });
@@ -191,8 +197,7 @@ function getRenderPost(data: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys
jsonParse = parseContent(data.post.content); jsonParse = parseContent(data.post.content);
} catch (e) { } catch (e) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
console.error(e); TGLogger.Warn(`[t-post][${postId}] ${e.name}: ${e.message}`);
TGLogger.Warn(`[t-post.vue] ${e.name}: ${e.message}`);
} }
jsonParse = data.post.structured_content; jsonParse = data.post.structured_content;
} }
@@ -221,7 +226,7 @@ function parseContent(content: string): string {
}); });
break; break;
default: default:
console.warn(`[MysPostParser] Unknown key: ${key}`); TGLogger.Warn(`[t-post][${postId}][parseContent] Unknown key: ${key}`);
result.push({ result.push({
insert: data[key], insert: data[key],
}); });