🎈 perf(eslint): 第二次 eslint

剩下的全给过了,明天起来跑 devtool 改 bug

Signed-off-by: BTMuli <BT-Muli@outlook.com>
(cherry picked from commit 59baf08cf897d31cabce4741910ea83c1a3a52d9)
This commit is contained in:
BTMuli
2023-04-06 03:08:40 +08:00
parent 6ec12bf664
commit 3c3df24f7d
24 changed files with 1968 additions and 2090 deletions

View File

@@ -1,13 +1,17 @@
<template>
<div v-if="loading">
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else class="dev-json">
<div class="anno-title">活动列表 JSON</div>
<json-viewer :value="jsonList" copyable boxed />
<div class="anno-title">活动内容 JSON</div>
<json-viewer :value="jsonContent" copyable boxed />
</div>
<div v-if="loading">
<TLoading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else class="dev-json">
<div class="anno-title">
活动列表 JSON
</div>
<JsonViewer :value="jsonList" copyable boxed />
<div class="anno-title">
活动内容 JSON
</div>
<JsonViewer :value="jsonContent" copyable boxed />
</div>
</template>
<script lang="ts" setup>
// vue
@@ -33,28 +37,25 @@ let jsonList = reactive({});
let jsonContent = reactive({});
onMounted(async () => {
await appWindow.show();
// 检查数据
if (!anno_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
const listData = await GenshinOper.Announcement.getList();
listData.list.map((item: Announcement) => {
return item.list.map((single: AnnoListItem) => {
if (single.ann_id === anno_id) {
jsonList = single;
return;
}
});
});
jsonContent = await GenshinOper.Announcement.getContent(anno_id);
setTimeout(() => {
loading.value = false;
}, 200);
await appWindow.show();
// 检查数据
if (!anno_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
const listData = await GenshinOper.Announcement.getList();
listData.list.map((item: Announcement) => {
return item.list.map((single: AnnoListItem) => {
return single.ann_id === anno_id ? (jsonList = single) : null;
});
});
jsonContent = await GenshinOper.Announcement.getContent(anno_id);
setTimeout(() => {
loading.value = false;
}, 200);
});
</script>
<style lang="css" scoped>

View File

@@ -1,13 +1,18 @@
<!-- eslint-disable vue/no-v-html -->
<template>
<div v-if="loading" class="loading">
<t-loading :title="loadingTitle" :empty="loadingEmpty" />
</div>
<div v-else class="anno-body">
<div class="anno-title">{{ annoData.title }}</div>
<div class="anno-subtitle">{{ annoData.subtitle }}</div>
<img :src="annoData.banner" alt="cover" class="anno-img" />
<div v-html="annoHtml" class="anno-content" />
</div>
<div v-if="loading" class="loading">
<TLoading :title="loadingTitle" :empty="loadingEmpty" />
</div>
<div v-else class="anno-body">
<div class="anno-title">
{{ annoData.title }}
</div>
<div class="anno-subtitle">
{{ annoData.subtitle }}
</div>
<img :src="annoData.banner" alt="cover" class="anno-img">
<div class="anno-content" v-html="annoHtml" />
</div>
</template>
<script lang="ts" setup>
// vue
@@ -32,27 +37,27 @@ const annoData = ref({} as AnnoContentItem);
const annoHtml = ref("");
onMounted(async () => {
await appWindow.show();
// 检查数据
if (!anno_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
try {
annoData.value = await GenshinOper.Announcement.getContent(anno_id);
loadingTitle.value = "正在渲染数据...";
annoHtml.value = GenshinOper.Announcement.parser(annoData.value.content);
} catch (error) {
loadingEmpty.value = true;
loadingTitle.value = "公告不存在或解析失败";
return;
}
setTimeout(() => {
loading.value = false;
}, 200);
await appWindow.show();
// 检查数据
if (!anno_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
try {
annoData.value = await GenshinOper.Announcement.getContent(anno_id);
loadingTitle.value = "正在渲染数据...";
annoHtml.value = GenshinOper.Announcement.parser(annoData.value.content);
} catch (error) {
loadingEmpty.value = true;
loadingTitle.value = "公告不存在或解析失败";
return;
}
setTimeout(() => {
loading.value = false;
}, 200);
});
</script>
<style lang="css" src="../assets/css/anno-parser.css" scoped />

View File

@@ -1,59 +1,69 @@
<template>
<div v-if="loading">
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else>
<div class="lottery-div">
<div class="lottery-title">抽奖详情 {{ timeStatus }}</div>
<v-list class="lottery-list">
<v-list-item>
<template v-slot:prepend>
<v-avatar>
<v-img :src="lotteryCard.creator.avatar_url" />
</v-avatar>
</template>
{{ lotteryCard.creator.nickname }}
<v-list-item-subtitle>{{ lotteryCard.creator.introduce }}</v-list-item-subtitle>
<template v-slot:append>发起人</template>
</v-list-item>
<v-list-item>
<v-list-item-title>{{ lotteryCard.participantWay }}</v-list-item-title>
<v-list-item-subtitle>{{ lotteryCard.id }}</v-list-item-subtitle>
<template v-slot:append>抽奖 ID</template>
</v-list-item>
</v-list>
<v-btn class="lottery-back" @click="backPost">返回</v-btn>
<v-btn @click="showJson = true" class="card-dev-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" />
</template>
JSON
</v-btn>
</div>
<div class="dev-json" v-show="showJson">
<json-viewer :value="jsonData" copyable boxed />
</div>
<div class="lottery-div">
<div class="lottery-title">奖品详情</div>
<div v-for="reward in lotteryCard.rewards">
<v-list class="lottery-list">
<v-list-item :title="reward.rewardName" :subtitle="'中奖人数' + reward.winnerNumber" />
</v-list>
<div class="lottery-grid">
<v-list v-for="user in reward.users" class="lottery-sub-list">
<v-list-item>
<template v-slot:prepend>
<v-avatar>
<v-img :src="user.avatar_url" />
</v-avatar>
</template>
{{ user.nickname }}
</v-list-item>
</v-list>
</div>
</div>
</div>
</div>
<div v-if="loading">
<TLoading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else>
<div class="lottery-div">
<div class="lottery-title">
抽奖详情 {{ timeStatus }}
</div>
<v-list class="lottery-list">
<v-list-item>
<template #prepend>
<v-avatar>
<v-img :src="lotteryCard.creator.avatar_url" />
</v-avatar>
</template>
{{ lotteryCard.creator.nickname }}
<v-list-item-subtitle>{{ lotteryCard.creator.introduce }}</v-list-item-subtitle>
<template #append>
发起人
</template>
</v-list-item>
<v-list-item>
<v-list-item-title>{{ lotteryCard.participantWay }}</v-list-item-title>
<v-list-item-subtitle>{{ lotteryCard.id }}</v-list-item-subtitle>
<template #append>
抽奖 ID
</template>
</v-list-item>
</v-list>
<v-btn class="lottery-back" @click="backPost">
返回
</v-btn>
<v-btn v-show="appStore.devMode" class="card-dev-btn" @click="showJson = true">
<template #prepend>
<img src="../assets/icons/arrow-right.svg" alt="right">
</template>
JSON
</v-btn>
</div>
<div v-show="showJson" class="dev-json">
<JsonViewer :value="jsonData" copyable boxed />
</div>
<div class="lottery-div">
<div class="lottery-title">
奖品详情
</div>
<div v-for="reward in lotteryCard.rewards" :key="reward.rewardName">
<v-list class="lottery-list">
<v-list-item :title="reward.rewardName" :subtitle="'中奖人数' + reward.winnerNumber" />
</v-list>
<div class="lottery-grid">
<v-list v-for="user in reward.users" :key="user.uid" class="lottery-sub-list">
<v-list-item>
<template #prepend>
<v-avatar>
<v-img :src="user.avatar_url" />
</v-avatar>
</template>
{{ user.nickname }}
</v-list-item>
</v-list>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
// vue
@@ -85,50 +95,50 @@ const showJson = ref(false as boolean);
let jsonData = reactive({} as LotteryData);
const timeStatus = ref("未知" as string);
function backPost() {
window.history.back();
function backPost () {
window.history.back();
}
onMounted(async () => {
await appWindow.show();
// 检查数据
if (!lottery_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
jsonData = await MysOper.Lottery.get(lottery_id);
if (!jsonData) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
await appWindow.setTitle("抽奖详情 " + jsonData.lottery_entity_summary);
loadingTitle.value = "正在渲染数据...";
lotteryCard.value = MysOper.Lottery.card.lottery(jsonData);
if (jsonData.status === "Settled") {
timeStatus.value = "已开奖";
} else {
await setInterval(() => {
const timeNow = new Date().getTime();
const timeDiff = Number(jsonData.draw_time) * 1000 - timeNow;
if (timeDiff <= 0) {
timeStatus.value = "已开奖";
clearInterval(this);
} else {
const day = Math.floor(timeDiff / (24 * 3600 * 1000));
const hour = Math.floor((timeDiff % (24 * 3600 * 1000)) / (3600 * 1000));
const minute = Math.floor((timeDiff % (3600 * 1000)) / (60 * 1000));
const second = Math.floor((timeDiff % (60 * 1000)) / 1000);
timeStatus.value = `${day}${hour}小时${minute}${second}`;
}
}, 1000);
}
setTimeout(() => {
loading.value = false;
}, 200);
await appWindow.show();
// 检查数据
if (!lottery_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
jsonData = await MysOper.Lottery.get(lottery_id);
if (!jsonData) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
await appWindow.setTitle("抽奖详情 " + jsonData.lottery_entity_summary);
loadingTitle.value = "正在渲染数据...";
lotteryCard.value = MysOper.Lottery.card.lottery(jsonData);
if (jsonData.status === "Settled") {
timeStatus.value = "已开奖";
} else {
await setInterval(() => {
const timeNow = new Date().getTime();
const timeDiff = Number(jsonData.draw_time) * 1000 - timeNow;
if (timeDiff <= 0) {
timeStatus.value = "已开奖";
clearInterval(this);
} else {
const day = Math.floor(timeDiff / (24 * 3600 * 1000));
const hour = Math.floor((timeDiff % (24 * 3600 * 1000)) / (3600 * 1000));
const minute = Math.floor((timeDiff % (3600 * 1000)) / (60 * 1000));
const second = Math.floor((timeDiff % (60 * 1000)) / 1000);
timeStatus.value = `${day}${hour}小时${minute}${second}`;
}
}, 1000);
}
setTimeout(() => {
loading.value = false;
}, 200);
});
</script>
<style lang="css">

View File

@@ -1,142 +1,143 @@
<template>
<div v-if="loading">
<t-loading :title="loadingTitle" />
</div>
<div v-else>
<v-tabs v-model="tab" align-tabs="start" class="news-tabs">
<v-tab value="notice" title="公告" />
<v-tab value="activity" title="活动" />
<v-tab value="news" title="新闻" v-if="showNews" />
<v-spacer></v-spacer>
<v-btn class="switch-btn" @click="switchAnno" v-if="showSwitch">
<template v-slot:prepend>
<v-icon>mdi-bullhorn</v-icon>
</template>
切换游戏内公告
</v-btn>
<v-text-field
v-show="appStore.devMode"
v-model="search"
append-icon="mdi-magnify"
label="搜索"
single-line
hide-details
@click:append="searchPost"
@keyup.enter="searchPost"
></v-text-field>
</v-tabs>
<v-window v-model="tab">
<v-window-item value="notice">
<div class="news-grid">
<v-card v-for="item in postData.notice" class="news-card" width="340">
<div class="news-cover" @click="toPost(item)">
<img :src="item.cover" alt="cover" />
</div>
<v-card-title>{{ item.title }}</v-card-title>
<v-card-actions>
<v-btn @click="toPost(item)" class="card-btn">
<template v-slot:prepend>
<img src="../assets/icons/circle-check.svg" alt="check" />查看
</template>
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn @click="toJson(item)" class="card-dev-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" />
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
<div class="load-news">
<v-btn @click="loadMore('notice')" :loading="loadingSub">
<template v-slot:append>
<img src="../assets/icons/arrow-left.svg" alt="right" />
</template>
已加载{{ rawData.notice.last_id }}加载更多
</v-btn>
</div>
</v-window-item>
<v-window-item value="activity">
<div class="news-grid">
<v-card class="news-card" v-for="item in postData.activity" width="340">
<div class="news-cover" @click="toPost(item)">
<img :src="item.cover" alt="cover" />
</div>
<v-card-title>{{ item.title }}</v-card-title>
<v-card-subtitle>{{ item.subtitle }}</v-card-subtitle>
<v-card-actions>
<v-btn @click="toPost(item)" class="card-btn">
<template v-slot:prepend>
<img src="../assets/icons/circle-check.svg" alt="check" />查看
</template>
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<div v-show="!appStore.devMode">
<v-btn
:style="{
background: item.status?.colorCss,
color: '#faf7e8 !important',
}"
>{{ item.status?.status }}</v-btn
>
</div>
<v-btn @click="toJson(item)" class="card-dev-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" />
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
<div class="load-news">
<v-btn @click="loadMore('activity')" :loading="loadingSub">
<template v-slot:append>
<img src="../assets/icons/arrow-left.svg" alt="right" />
</template>
已加载:{{ rawData.activity.last_id }}加载更多
</v-btn>
</div>
</v-window-item>
<v-window-item value="news" v-if="showNews">
<div class="news-grid">
<v-card class="news-card" v-for="item in postData.news" width="340">
<div class="news-cover" @click="toPost(item)">
<img :src="item.cover" alt="cover" />
</div>
<v-card-title>{{ item.title }}</v-card-title>
<v-card-actions>
<v-btn @click="toPost(item)" class="card-btn">
<template v-slot:prepend>
<img src="../assets/icons/circle-check.svg" alt="check" />查看
</template>
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn @click="toJson(item)" class="card-dev-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" />
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
<div class="load-news">
<v-btn @click="loadMore('news')" :loading="loadingSub">
<template v-slot:append>
<img src="../assets/icons/arrow-left.svg" alt="right" />
</template>
已加载{{ rawData.news.last_id }}加载更多
</v-btn>
</div>
</v-window-item>
</v-window>
<v-snackbar v-model="snackbar" timeout="1500" :color="snackbarColor">
{{ snackbarText }}
</v-snackbar>
</div>
<div v-if="loading">
<TLoading :title="loadingTitle" />
</div>
<div v-else>
<v-tabs v-model="tab" align-tabs="start" class="news-tabs">
<v-tab value="notice" title="公告" />
<v-tab value="activity" title="活动" />
<v-tab v-if="showNews" value="news" title="新闻" />
<v-spacer />
<v-btn v-if="showSwitch" class="switch-btn" @click="switchAnno">
<template #prepend>
<v-icon>mdi-bullhorn</v-icon>
</template>
切换游戏内公告
</v-btn>
<v-text-field
v-show="appStore.devMode"
v-model="search"
append-icon="mdi-magnify"
label="搜索"
single-line
hide-details
@click:append="searchPost"
@keyup.enter="searchPost"
/>
</v-tabs>
<v-window v-model="tab">
<v-window-item value="notice">
<div class="news-grid">
<v-card v-for="item in postData.notice" :key="item.post_id" class="news-card" width="340">
<div class="news-cover" @click="toPost(item)">
<img :src="item.cover" alt="cover">
</div>
<v-card-title>{{ item.title }}</v-card-title>
<v-card-actions>
<v-btn class="card-btn" @click="toPost(item)">
<template #prepend>
<img src="../assets/icons/circle-check.svg" alt="check">查看
</template>
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn v-show="appStore.devMode" class="card-dev-btn" @click="toJson(item)">
<template #prepend>
<img src="../assets/icons/arrow-right.svg" alt="right">
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
<div class="load-news">
<v-btn :loading="loadingSub" @click="loadMore('notice')">
<template #append>
<img src="../assets/icons/arrow-left.svg" alt="right">
</template>
已加载{{ rawData.notice.last_id }}加载更多
</v-btn>
</div>
</v-window-item>
<v-window-item value="activity">
<div class="news-grid">
<v-card v-for="item in postData.activity" :key="item.post_id" class="news-card" width="340">
<div class="news-cover" @click="toPost(item)">
<img :src="item.cover" alt="cover">
</div>
<v-card-title>{{ item.title }}</v-card-title>
<v-card-subtitle>{{ item.subtitle }}</v-card-subtitle>
<v-card-actions>
<v-btn class="card-btn" @click="toPost(item)">
<template #prepend>
<img src="../assets/icons/circle-check.svg" alt="check">查看
</template>
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<div v-show="!appStore.devMode">
<v-btn
:style="{
background: item.status?.colorCss,
color: '#faf7e8 !important',
}"
>
{{ item.status?.status }}
</v-btn>
</div>
<v-btn v-show="appStore.devMode" class="card-dev-btn" @click="toJson(item)">
<template #prepend>
<img src="../assets/icons/arrow-right.svg" alt="right">
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
<div class="load-news">
<v-btn :loading="loadingSub" @click="loadMore('activity')">
<template #append>
<img src="../assets/icons/arrow-left.svg" alt="right">
</template>
已加载:{{ rawData.activity.last_id }}加载更多
</v-btn>
</div>
</v-window-item>
<v-window-item v-if="showNews" value="news">
<div class="news-grid">
<v-card v-for="item in postData.news" :key="item.post_id" class="news-card" width="340">
<div class="news-cover" @click="toPost(item)">
<img :src="item.cover" alt="cover">
</div>
<v-card-title>{{ item.title }}</v-card-title>
<v-card-actions>
<v-btn class="card-btn" @click="toPost(item)">
<template #prepend>
<img src="../assets/icons/circle-check.svg" alt="check">查看
</template>
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn v-show="appStore.devMode" class="card-dev-btn" @click="toJson(item)">
<template #prepend>
<img src="../assets/icons/arrow-right.svg" alt="right">
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
<div class="load-news">
<v-btn :loading="loadingSub" @click="loadMore('news')">
<template #append>
<img src="../assets/icons/arrow-left.svg" alt="right">
</template>
已加载{{ rawData.news.last_id }}加载更多
</v-btn>
</div>
</v-window-item>
</v-window>
<v-snackbar v-model="snackbar" timeout="1500" :color="snackbarColor">
{{ snackbarText }}
</v-snackbar>
</div>
</template>
<script lang="ts" setup>
@@ -177,170 +178,167 @@ const search = ref("" as string);
// 数据
const tab = ref("" as string);
const postData = ref({
notice: [] as NewsCard[],
activity: [] as NewsCard[],
news: [] as NewsCard[],
notice: [] as NewsCard[],
activity: [] as NewsCard[],
news: [] as NewsCard[],
});
const rawData = ref({
notice: {
is_last: false,
last_id: 0,
},
activity: {
is_last: false,
last_id: 0,
},
news: {
is_last: false,
last_id: 0,
},
notice: {
is_last: false,
last_id: 0,
},
activity: {
is_last: false,
last_id: 0,
},
news: {
is_last: false,
last_id: 0,
},
});
onMounted(async () => {
loadingTitle.value = "正在获取公告数据...";
const noticeData = await MysOper.News.get.notice(gid);
rawData.value.notice.is_last = noticeData.is_last;
rawData.value.notice.last_id = noticeData.list.length;
loadingTitle.value = "正在获取活动数据...";
const activityData = await MysOper.News.get.activity(gid);
rawData.value.activity.is_last = activityData.is_last;
rawData.value.activity.last_id = activityData.list.length;
if (showNews.value) {
loadingTitle.value = "正在获取新闻数据...";
const newsData = await MysOper.News.get.news(gid);
rawData.value.news.is_last = newsData.is_last;
rawData.value.news.last_id = newsData.list.length;
postData.value = {
notice: MysOper.News.card.notice(noticeData),
activity: MysOper.News.card.activity(activityData),
news: MysOper.News.card.news(newsData),
};
} else {
postData.value = {
notice: MysOper.News.card.notice(noticeData),
activity: MysOper.News.card.activity(activityData),
news: [],
};
}
tab.value = "notice";
loading.value = false;
loadingTitle.value = "正在获取公告数据...";
const noticeData = await MysOper.News.get.notice(gid);
rawData.value.notice.is_last = noticeData.is_last;
rawData.value.notice.last_id = noticeData.list.length;
loadingTitle.value = "正在获取活动数据...";
const activityData = await MysOper.News.get.activity(gid);
rawData.value.activity.is_last = activityData.is_last;
rawData.value.activity.last_id = activityData.list.length;
if (showNews.value) {
loadingTitle.value = "正在获取新闻数据...";
const newsData = await MysOper.News.get.news(gid);
rawData.value.news.is_last = newsData.is_last;
rawData.value.news.last_id = newsData.list.length;
postData.value = {
notice: MysOper.News.card.notice(noticeData),
activity: MysOper.News.card.activity(activityData),
news: MysOper.News.card.news(newsData),
};
} else {
postData.value = {
notice: MysOper.News.card.notice(noticeData),
activity: MysOper.News.card.activity(activityData),
news: [],
};
}
tab.value = "notice";
loading.value = false;
});
function switchAnno() {
router.push("/announcements");
async function switchAnno () {
await router.push("/announcements");
}
// 加载更多
async function loadMore(data: string) {
loadingSub.value = true;
switch (data) {
case "notice":
if (rawData.value.notice.is_last) {
snackbarText.value = "已经是最后一页了";
snackbarColor.value = "#35acce";
snackbar.value = true;
loadingSub.value = false;
return;
}
const getNotice = await MysOper.News.get.notice(gid, 20, rawData.value.notice.last_id);
rawData.value.notice.last_id = rawData.value.notice.last_id + getNotice.list.length;
rawData.value.notice.is_last = getNotice.is_last;
const noticeCard = MysOper.News.card.notice(getNotice);
postData.value.notice = postData.value.notice.concat(noticeCard);
loadingSub.value = false;
break;
case "activity":
if (rawData.value.activity.is_last) {
snackbarText.value = "已经是最后一页了";
snackbarColor.value = "#35acce";
snackbar.value = true;
loadingSub.value = false;
return;
}
const getActivity = await MysOper.News.get.activity(gid, 20, rawData.value.activity.last_id);
rawData.value.activity.last_id = rawData.value.activity.last_id + getActivity.list.length;
rawData.value.activity.is_last = getActivity.is_last;
const activityCard = MysOper.News.card.activity(getActivity);
postData.value.activity = postData.value.activity.concat(activityCard);
loadingSub.value = false;
break;
case "news":
if (rawData.value.news.is_last) {
snackbarText.value = "已经是最后一页了";
snackbarColor.value = "#35acce";
snackbar.value = true;
loadingSub.value = false;
return;
}
const getNews = await MysOper.News.get.news(gid, 20, rawData.value.news.last_id);
rawData.value.news.last_id = rawData.value.news.last_id + getNews.list.length;
rawData.value.news.is_last = getNews.is_last;
const newsCard = MysOper.News.card.news(getNews);
postData.value.news = postData.value.news.concat(newsCard);
loadingSub.value = false;
break;
default:
break;
}
async function loadMore (data: string) {
loadingSub.value = true;
switch (data) {
case "notice":
if (rawData.value.notice.is_last) {
snackbarText.value = "已经是最后一页了";
snackbarColor.value = "#35acce";
snackbar.value = true;
loadingSub.value = false;
return;
}
const getNotice = await MysOper.News.get.notice(gid, 20, rawData.value.notice.last_id);
rawData.value.notice.last_id = rawData.value.notice.last_id + getNotice.list.length;
rawData.value.notice.is_last = getNotice.is_last;
const noticeCard = MysOper.News.card.notice(getNotice);
postData.value.notice = postData.value.notice.concat(noticeCard);
loadingSub.value = false;
break;
case "activity":
if (rawData.value.activity.is_last) {
snackbarText.value = "已经是最后一页了";
snackbarColor.value = "#35acce";
snackbar.value = true;
loadingSub.value = false;
return;
}
const getActivity = await MysOper.News.get.activity(gid, 20, rawData.value.activity.last_id);
rawData.value.activity.last_id = rawData.value.activity.last_id + getActivity.list.length;
rawData.value.activity.is_last = getActivity.is_last;
const activityCard = MysOper.News.card.activity(getActivity);
postData.value.activity = postData.value.activity.concat(activityCard);
loadingSub.value = false;
break;
case "news":
if (rawData.value.news.is_last) {
snackbarText.value = "已经是最后一页了";
snackbarColor.value = "#35acce";
snackbar.value = true;
loadingSub.value = false;
return;
}
const getNews = await MysOper.News.get.news(gid, 20, rawData.value.news.last_id);
rawData.value.news.last_id = rawData.value.news.last_id + getNews.list.length;
rawData.value.news.is_last = getNews.is_last;
const newsCard = MysOper.News.card.news(getNews);
postData.value.news = postData.value.news.concat(newsCard);
loadingSub.value = false;
break;
default:
break;
}
}
async function toPost(item: NewsCard | string) {
if (typeof item === "string") {
const path = router.resolve({
name: "帖子详情",
params: {
post_id: item,
},
}).href;
createTGWindow(path, "帖子-Dev", item, 960, 720, false);
} else {
const path = router.resolve({
name: "帖子详情",
params: {
post_id: item.post_id.toString(),
},
}).href;
createTGWindow(path, "帖子", item.title, 960, 720, false);
}
async function toPost (item: NewsCard | string) {
if (typeof item === "string") {
const path = router.resolve({
name: "帖子详情",
params: {
post_id: item,
},
}).href;
createTGWindow(path, "帖子-Dev", item, 960, 720, false);
} else {
const path = router.resolve({
name: "帖子详情",
params: {
post_id: item.post_id.toString(),
},
}).href;
createTGWindow(path, "帖子", item.title, 960, 720, false);
}
}
async function toJson(item: NewsCard | string) {
if (typeof item === "string") {
const path = router.resolve({
name: "帖子详情JSON",
params: {
post_id: item,
},
}).href;
createTGWindow(path, "帖子-JSON-Dev", `${item}-JSON`, 960, 720, false);
return;
} else {
const path = router.resolve({
name: "帖子详情JSON",
params: {
post_id: item.post_id.toString(),
},
}).href;
createTGWindow(path, "帖子-JSON", `${item.title}-JSON`, 960, 720, false);
return;
}
async function toJson (item: NewsCard | string) {
if (typeof item === "string") {
const path = router.resolve({
name: "帖子详情JSON",
params: {
post_id: item,
},
}).href;
createTGWindow(path, "帖子-JSON-Dev", `${item}-JSON`, 960, 720, false);
} else {
const path = router.resolve({
name: "帖子详情JSON",
params: {
post_id: item.post_id.toString(),
},
}).href;
createTGWindow(path, "帖子-JSON", `${item.title}-JSON`, 960, 720, false);
}
}
async function searchPost() {
if (search.value === "") {
snackbarText.value = "请输入搜索内容";
snackbarColor.value = "error";
snackbar.value = true;
return;
}
if (!isNaN(Number(search.value))) {
await toPost(search.value);
await toJson(search.value);
} else {
snackbarText.value = "请输入搜索内容";
snackbarColor.value = "error";
snackbar.value = true;
return;
}
async function searchPost () {
if (search.value === "") {
snackbarText.value = "请输入搜索内容";
snackbarColor.value = "error";
snackbar.value = true;
return;
}
if (!isNaN(Number(search.value))) {
await toPost(search.value);
await toJson(search.value);
} else {
snackbarText.value = "请输入搜索内容";
snackbarColor.value = "error";
snackbar.value = true;
}
}
</script>
@@ -380,6 +378,7 @@ async function searchPost() {
height: 150px;
transition: all 0.3s linear;
}
/* switch */
.switch-btn {
font-family: Genshin, serif;
@@ -389,6 +388,7 @@ async function searchPost() {
margin-top: 5px;
color: #546d8b;
}
/* load more */
.load-news {
font-family: Genshin, serif;

View File

@@ -1,10 +1,10 @@
<template>
<div v-if="loading">
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else class="dev-json">
<json-viewer :value="jsonData" copyable boxed />
</div>
<div v-if="loading">
<TLoading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else class="dev-json">
<JsonViewer :value="jsonData" copyable boxed />
</div>
</template>
<script lang="ts" setup>
// vue
@@ -27,18 +27,18 @@ const post_id = Number(useRoute().params.post_id);
let jsonData = reactive({});
onMounted(async () => {
await appWindow.show();
// 检查数据
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
jsonData = await MysOper.Post.get(post_id);
setTimeout(() => {
loading.value = false;
}, 200);
await appWindow.show();
// 检查数据
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
jsonData = await MysOper.Post.get(post_id);
setTimeout(() => {
loading.value = false;
}, 200);
});
</script>

View File

@@ -1,8 +1,9 @@
<!-- eslint-disable vue/no-v-html -->
<template>
<div v-if="loading">
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else v-html="postHtml" class="mys-post-body" />
<div v-if="loading">
<TLoading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else class="mys-post-body" v-html="postHtml" />
</template>
<script lang="ts" setup>
// vue
@@ -24,31 +25,31 @@ const post_id = Number(useRoute().params.post_id);
const postHtml = ref("");
onMounted(async () => {
await appWindow.show();
// 检查数据
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
await appWindow.setTitle("未找到数据");
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
try {
const postData = await MysOper.Post.get(post_id);
loadingTitle.value = "正在渲染数据...";
postHtml.value = MysOper.Post.parser(postData);
await appWindow.setTitle(postData.post.subject);
} catch (error) {
console.error(error);
loadingEmpty.value = true;
loadingTitle.value = "帖子不存在或解析失败";
await appWindow.setTitle("帖子不存在或解析失败");
return;
}
setTimeout(() => {
loading.value = false;
}, 200);
await appWindow.show();
// 检查数据
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
await appWindow.setTitle("未找到数据");
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
try {
const postData = await MysOper.Post.get(post_id);
loadingTitle.value = "正在渲染数据...";
postHtml.value = MysOper.Post.parser(postData);
await appWindow.setTitle(postData.post.subject);
} catch (error) {
console.error(error);
loadingEmpty.value = true;
loadingTitle.value = "帖子不存在或解析失败";
await appWindow.setTitle("帖子不存在或解析失败");
return;
}
setTimeout(() => {
loading.value = false;
}, 200);
});
</script>
<style lang="css" scoped src="../assets/css/post-parser.css"></style>