Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
修复必填项校验出错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yimien committed Feb 1, 2024
1 parent 643e194 commit 2b940c9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.1.7

### 修复

1. 修复必填项判定出错的问题

## v0.1.6

### 新功能
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "plugin-memos-sync",
"author": "Yimien",
"url": "https://github.com/Yimien/plugin-memos-sync.git",
"version": "0.1.6",
"version": "0.1.7",
"minAppVersion": "2.11.3",
"backends": [
"all"
Expand Down
49 changes: 28 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ export default class MemosSync extends Plugin {
async checkRequired() {
let configData = this.data[STORAGE_NAME];

// TODO 必填项补充
let requiredList = [
configData.baseUrl,
configData.accessToken,
configData.lastSyncTime,
configData.syncMode,
configData.notebookId,
configData.markMode,
configData.imageLayout,
configData.superLabelMode,
configData.resourceDownloadMode,
configData.biDirectionalLinksMode,
configData.subjectPath
configData.baseUrl, // 基础路径
configData.accessToken, // 授权码
configData.lastSyncTime, // 上次同步时间
configData.syncMode, // 同步模式
configData.notebookId, // 笔记本
configData.markMode, // 引用处理模式
configData.biDirectionalLinksMode, // 是否识别双向链接
configData.imageLayout, // 图片布局
configData.superLabelMode, // 是否收束标签
configData.resourceDownloadMode // 资源下载模式
]

for (let required of requiredList) {
Expand All @@ -88,20 +88,23 @@ export default class MemosSync extends Plugin {
}
}

// 同步至单份文档时,需校验文档路径是否填写
if (configData.syncMode === sMaps.SYNC_MAP.simple){
if (!configData.pagePath){
await sApi.pushErrMsg("请确认必填项是否全部配置!")
return;
}
}

// 收束标签时,需校验标签名称是否填写
if (configData.superLabelMode === sMaps.IS_USE.yes) {
if (!configData.superLabelText) {
await sApi.pushErrMsg("请确认必填项是否全部配置!")
return false;
}
}

// 识别双向链接时,需校验主题路径是否填写
if (configData.biDirectionalLinksMode === sMaps.IS_USE.yes){
if (!configData.subjectPath){
await sApi.pushErrMsg("请确认必填项是否全部配置!")
Expand Down Expand Up @@ -1378,16 +1381,16 @@ export default class MemosSync extends Plugin {
confirmCallback: async () => {
// 必填项校验
let requiredList = [
baseUrlElement.value,
accessTokenElement.value,
lastSyncTimeElement.value,
syncModeElement.value,
notebookIdElement.value,
markModeElement.value,
imageLayoutElement.value,
superLabelModeElement.value,
resourceDownloadModeElement.value,
biDirectionalLinksModeElement.value
baseUrlElement.value, // 基础路径
accessTokenElement.value, // 授权码
lastSyncTimeElement.value, // 上次同步时间
syncModeElement.value, // 同步模式
notebookIdElement.value, // 笔记本
markModeElement.value, // 引用处理模式
biDirectionalLinksModeElement.value, // 是否识别双向链接
imageLayoutElement.value, // 图片布局
superLabelModeElement.value, // 是否收束标签
resourceDownloadModeElement.value // 资源下载模式
]

for (let required of requiredList) {
Expand All @@ -1397,20 +1400,24 @@ export default class MemosSync extends Plugin {
}
}

// 同步至单份文档时,需校验文档路径是否填写
if (syncModeElement.value === sMaps.SYNC_MAP.simple){
if (!pagePathElement.value){
await sApi.pushErrMsg("请确认必填项是否全部配置!")
return;
}
}


// 收束标签时,需校验标签名称是否填写
if (superLabelModeElement.value === sMaps.IS_USE.yes) {
if (!superLabelTextElement.value) {
await sApi.pushErrMsg("请确认必填项是否全部配置!")
return;
}
}

// 识别双向链接时,需校验主题路径是否填写
if (biDirectionalLinksModeElement.value === sMaps.IS_USE.yes){
if (!subjectPathElement.value){
await sApi.pushErrMsg("请确认必填项是否全部配置!")
Expand Down

0 comments on commit 2b940c9

Please sign in to comment.