Skip to content

Commit

Permalink
Merge pull request #389 from terwer/dev
Browse files Browse the repository at this point in the history
fix: fix windows import
  • Loading branch information
terwer authored Aug 30, 2023
2 parents 605c540 + 8d1b248 commit 89c6d9f
Show file tree
Hide file tree
Showing 53 changed files with 1,415 additions and 893 deletions.
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
auto-install-peers = true
"electron_mirror="http://npm.taobao.org/mirrors/electron/\"="
electron_custom_dir=16.0.6
electron_custom_dir=16.0.6
shamefully-hoist=true
Empty file added apps/.gitkeep
Empty file.
113 changes: 113 additions & 0 deletions libs/zhi-blog-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,118 @@
# zhi-blog-api

## 1.34.13

### Patch Changes

- Updated dependencies
- [email protected]

## 1.34.12

### Patch Changes

- feat: add keep title

## 1.34.11

### Patch Changes

- feat: add keepTitle

## 1.34.10

### Patch Changes

- Updated dependencies
- [email protected]

## 1.34.9

### Patch Changes

- fix: remove unused type define

## 1.34.8

### Patch Changes

- Updated dependencies
- [email protected]
- [email protected]

## 1.34.7

### Patch Changes

- Updated dependencies
- [email protected]

## 1.34.6

### Patch Changes

- Updated dependencies
- [email protected]

## 1.34.5

### Patch Changes

- 8a55a296: fix yaml error

## 1.34.4

### Patch Changes

- fix field error

## 1.34.3

### Patch Changes

- fix deps

## 1.34.2

### Patch Changes

- add yamlLinkEnabled

## 1.34.1

### Patch Changes

- fix: fix tag split

## 1.34.0

### Minor Changes

- feat: optimize YAML null handling

## 1.33.1

### Patch Changes

- export PreferenceConfig

## 1.33.0

### Minor Changes

- add removeWidgetTag option

### Patch Changes

- add PreferenceConfig

## 1.32.2

### Patch Changes

- Updated dependencies
- [email protected]

## 1.32.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-blog-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-blog-api",
"version": "1.32.1",
"version": "1.34.13",
"type": "module",
"description": "a common blog interface",
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions libs/zhi-blog-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import WebPlaceholder from "./lib/WebPlaceholder"
import CategoryTypeEnum from "./lib/enums/categoryTypeEnum"
import YamlFormatObj from "./lib/models/yamlFormatObj"
import YamlConvertAdaptor from "./lib/yamlConvertAdaptor"
import PreferenceConfig from "./lib/PreferenceConfig"

export { BlogApi, BlogAdaptor }
export { WebApi, WebAdaptor }
Expand All @@ -28,4 +29,5 @@ export { WebConfig, WebPlaceholder }
export { Post, UserBlog, SiteConfig, CategoryInfo, MediaObject, Attachment }
export { BlogConstants, BlogTypeEnum, PageTypeEnum, CategoryTypeEnum }
export { YamlFormatObj, YamlConvertAdaptor }
export { PreferenceConfig }
export { type ElectronCookie }
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,36 @@
* questions.
*/

import { BlogAdaptor } from "zhi-blog-api"
import { simpleLogger } from "zhi-lib-base"
/**
* 偏好设置
*/
class PreferenceConfig {
/**
* 是否处理标题,主要是去除数字
*/
public fixTitle: boolean

class CommonWechatsyncClient {
private readonly logger
private readonly driver
constructor(driver: BlogAdaptor) {
this.logger = simpleLogger("common-wechatsync-client", "zhi-wechatsync-middleware")
this.driver = driver
}
/**
* 不修改标题
*/
public keepTitle: boolean

/**
* 是否删除正文第一个H1
*/
public removeFirstH1: boolean

/**
* 移除挂件的 HTML
*/
public removeMdWidgetTag: boolean

public async doSync() {
this.logger.info("start sync post...", this.driver)
constructor() {
this.fixTitle = false
this.keepTitle = false
this.removeFirstH1 = false
this.removeMdWidgetTag = false
}
}

export default CommonWechatsyncClient
export default PreferenceConfig
15 changes: 10 additions & 5 deletions libs/zhi-blog-api/src/lib/blogConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import BlogPlaceholder from "./blogPlaceholder"
import PageTypeEnum from "./enums/pageTypeEnum"
import CategoryTypeEnum from "./enums/categoryTypeEnum"
import PreferenceConfig from "./PreferenceConfig"

/**
* 页面类型
Expand Down Expand Up @@ -149,11 +150,9 @@ abstract class BlogConfig {
public placeholder?: BlogPlaceholder | undefined

/**
* 是否处理标题
*
* @protected
* 偏好设置
*/
public fixTitle?: boolean
public preferenceConfig?: PreferenceConfig | undefined

/**
* 跨域代理地址
Expand Down Expand Up @@ -225,6 +224,11 @@ abstract class BlogConfig {
*/
public categoryType: CategoryTypeEnum

/**
* 是否生成YAML永久链接
*/
public yamlLinkEnabled: boolean

protected constructor() {
this.home = ""
this.apiUrl = ""
Expand All @@ -237,7 +241,7 @@ abstract class BlogConfig {
this.previewUrl = ""
this.pageType = PageTypeEnum.Markdown
this.placeholder = undefined
this.fixTitle = false
this.preferenceConfig = new PreferenceConfig()
this.middlewareUrl = ""
this.usernameEnabled = false
this.showTokenTip = false
Expand All @@ -252,6 +256,7 @@ abstract class BlogConfig {
this.cateTitle = "文章分类"
this.allowCateChange = false
this.categoryType = CategoryTypeEnum.CategoryType_None
this.yamlLinkEnabled = true
}
}

Expand Down
105 changes: 25 additions & 80 deletions libs/zhi-blog-api/src/lib/models/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,47 +168,18 @@ class Post {
* @returns {Object} 表示数据的适用于 YAML 的对象
*/
public toYamlObj(): Record<string, any> {
return {
/**
* 创建日期,已转换为中文格式
*/
created: DateUtil.formatIsoToZh(this.dateCreated.toISOString(), true),

/**
* 更新日期,已转换为中文格式。
*/
updated: DateUtil.formatIsoToZh(this.dateUpdated.toISOString(), true),

/**
* 标题。
*/
title: this.title,

/**
* WordPress 别名
*/
slug: this.wp_slug,

/**
* 永久链接
*/
permalink: this.permalink,

/**
* 简短描述
*/
desc: this.shortDesc,

/**
* 标签
*/
tags: this.mt_keywords,

/**
* 分类列表
*/
categories: this.categories,
}
const yamlObj: Record<string, any> = {}

this.dateCreated && (yamlObj.created = DateUtil.formatIsoToZh(this.dateCreated.toISOString(), true))
this.dateUpdated && (yamlObj.updated = DateUtil.formatIsoToZh(this.dateUpdated.toISOString(), true))
this.title && (yamlObj.title = this.title)
this.wp_slug && (yamlObj.slug = this.wp_slug)
this.permalink && (yamlObj.permalink = this.permalink)
this.shortDesc && (yamlObj.desc = this.shortDesc)
this.mt_keywords && (yamlObj.tags = this.mt_keywords?.split(","))
this.categories && (yamlObj.categories = this.categories)

return yamlObj
}

/**
Expand All @@ -217,45 +188,19 @@ class Post {
* @param {Object} yamlObj - 包含要填充对象属性的数据的适用于 YAML 的对象
*/
public fromYaml(yamlObj: Record<string, any>): void {
/**
* 创建日期
*/
this.dateCreated = DateUtil.convertStringToDate(yamlObj.created)

/**
* 更新日期
*/
this.dateUpdated = DateUtil.convertStringToDate(yamlObj.updated)

/**
* 标题
*/
this.title = yamlObj.title

/**
* WordPress 别名
*/
this.wp_slug = yamlObj.slug

/**
* 永久链接
*/
this.permalink = yamlObj.permalink

/**
* 简短描述
*/
this.shortDesc = yamlObj.desc

/**
* 标签
*/
this.mt_keywords = yamlObj.tags

/**
* 分类列表
*/
this.categories = yamlObj.categories
this.dateCreated = yamlObj?.created ? DateUtil.convertStringToDate(yamlObj.created) : this.dateCreated
this.dateUpdated = yamlObj?.updated ? DateUtil.convertStringToDate(yamlObj.updated) : this.dateUpdated
this.title = yamlObj?.title ?? this.title
this.wp_slug = yamlObj?.slug ?? this.wp_slug
this.permalink = yamlObj?.permalink ?? this.permalink
this.shortDesc = yamlObj?.desc ?? this.shortDesc
// 修复历史遗留问题
if (typeof yamlObj?.tags === "string" && yamlObj?.tags.indexOf(",") > -1) {
this.mt_keywords = yamlObj?.tag
} else {
this.mt_keywords = yamlObj?.tags ? yamlObj?.tags.join(",") : this.mt_keywords
}
this.categories = yamlObj?.categories ?? this.categories
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-blog-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": false,

"types": ["node", "vite/client"]
"types": ["vite/client"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
7 changes: 7 additions & 0 deletions libs/zhi-common-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# zhi-common-markdown

## 0.1.6

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-common-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-common-markdown",
"version": "0.1.5",
"version": "0.1.6",
"type": "module",
"description": "a universal Markdown parsing tool",
"main": "./dist/index.js",
Expand Down
Loading

0 comments on commit 89c6d9f

Please sign in to comment.