Skip to content

Commit

Permalink
feat: #101 错误处理
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Sep 26, 2022
1 parent f3444dc commit b19b813
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
27 changes: 13 additions & 14 deletions src/components/tab/main/CommonBlogMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,22 @@ import {
formatNumToZhDate,
getPublishStatus,
isEmptyObject,
isEmptyString, jiebaToHotWords,
pathJoin, pingyinSlugify,
isEmptyString,
jiebaToHotWords,
pathJoin,
pingyinSlugify,
zhSlugify
} from "../../../lib/util";
import {SIYUAN_PAGE_ATTR_KEY} from "../../../lib/constants/siyuanPageConstants";
import logUtil from "../../../lib/logUtil";
import {ElMessage} from "element-plus/es";
import shortHash from "shorthash2";
import {
mdToHtml,
mdToPlainText,
parseHtml,
removeMdWidgetTag,
removeTitleNumber,
removeWidgetTag
} from "../../../lib/htmlUtil";
import {mdToHtml, mdToPlainText, parseHtml, removeMdWidgetTag, removeTitleNumber} from "../../../lib/htmlUtil";
import {CONSTANTS} from "../../../lib/constants/constants";
import {ElMessageBox} from "element-plus";
import {API} from "../../../lib/api";
import {IMetaweblogCfg, PageType} from "../../../lib/platform/metaweblog/IMetaweblogCfg";
import {render} from "../../../lib/markdownUtil";
import {PageType} from "../../../lib/platform/metaweblog/IMetaweblogCfg";
import {Post} from "../../../lib/common/post";
import {API_TYPE_CONSTANTS} from "../../../lib/constants/apiTypeConstants";
const {t} = useI18n()
Expand Down Expand Up @@ -250,7 +243,13 @@ const initPage = async () => {
// 思源笔记数据
siyuanData.pageId = pageId;
siyuanData.meta = await getPageAttrs(pageId)
const page = await getPage(pageId)
let page
try {
page = await getPage(pageId)
} catch (e) {
logUtil.logError("页面信息获取失败", e)
throw new Error("页面信息获取失败")
}
if (!page) {
ElMessage.error(t('config.error.msg') + "_" + props.apiType)
throw new Error(t('config.error.msg') + "_" + props.apiType)
Expand Down
19 changes: 12 additions & 7 deletions src/components/tab/main/MetaweblogMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,18 @@ const initPage = async () => {
// 路径组合
previewUrl.value = pathJoin(metaweblogCfg.home, postUrl)
// 如果文章选择了分类,初始化分类
const post: Post = await api.getPost(formData.postid.toString())
catData = post.categories
logUtil.logInfo("postid=>", formData.postid)
logUtil.logInfo("post=>", post)
logUtil.logInfo("初始化选择过的分类,catData=>", catData)
try {
// 如果文章选择了分类,初始化分类
const post: Post = await api.getPost(formData.postid.toString())
catData = post.categories
logUtil.logInfo("postid=>", formData.postid)
logUtil.logInfo("post=>", post)
logUtil.logInfo("初始化选择过的分类,catData=>", catData)
} catch (e) {
isInitLoadding.value = false
logUtil.logError("文章新获取失败", e)
}
}
// 全部文章分类请求
Expand Down

0 comments on commit b19b813

Please sign in to comment.