Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add picbed service type support #400

Merged
merged 24 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/zhi-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# zhi-cli

## 1.8.1

### Patch Changes

- zhi-log@1.14.21

## 1.8.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/zhi-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-cli",
"version": "1.8.0",
"version": "1.8.1",
"description": "a tool for generating zhi framework related projects",
"type": "module",
"bin": {
Expand Down
43 changes: 43 additions & 0 deletions apps/zhi-infra/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# zhi-infra

## 0.21.6

### Patch Changes

- Updated dependencies
- zhi-common@1.33.0

## 0.21.5

### Patch Changes

- Updated dependencies
- zhi-common@1.32.0

## 0.21.4

### Patch Changes

- Updated dependencies
- zhi-device@2.11.0
- zhi-cmd@0.8.1

## 0.21.3

### Patch Changes

- Updated dependencies
- zhi-common@1.31.0

## 0.21.2

### Patch Changes

- Updated dependencies
- zhi-common@1.30.0

## 0.21.1

### Patch Changes

- Updated dependencies
- zhi-common@1.29.0

## 0.21.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/zhi-infra/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-infra",
"version": "0.21.0",
"version": "0.21.6",
"type": "module",
"description": "basic issues for zhi",
"main": "./dist/index.cjs",
Expand Down
77 changes: 77 additions & 0 deletions libs/zhi-blog-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,82 @@
# zhi-blog-api

## 1.58.0

### Minor Changes

- feat: add picbed service type support

## 1.57.0

### Minor Changes

- feat: add picbed flags support

## 1.56.4

### Patch Changes

- Updated dependencies
- zhi-common@1.33.0

## 1.56.3

### Patch Changes

- Updated dependencies
- zhi-common@1.32.0

## 1.56.2

### Patch Changes

- fix: empty cate error

## 1.56.1

### Patch Changes

- feat: add cors cookie support

## 1.56.0

### Minor Changes

- feat: add cors cookie support

## 1.55.0

### Minor Changes

- feat: add corsAnywhereUrl

## 1.54.1

### Patch Changes

- Updated dependencies
- zhi-common@1.31.0

## 1.54.0

### Minor Changes

- feat: add metadataMap

## 1.53.2

### Patch Changes

- Updated dependencies
- zhi-common@1.30.0

## 1.53.1

### Patch Changes

- Updated dependencies
- zhi-common@1.29.0

## 1.53.0

### Minor 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.53.0",
"version": "1.58.0",
"type": "module",
"description": "a common blog interface",
"main": "./dist/index.js",
Expand Down
3 changes: 2 additions & 1 deletion libs/zhi-blog-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import PostUtil from "./lib/PostUtil"
import TagInfo from "./lib/models/tagInfo"
import PageEditMode from "./lib/models/pageEditMode"
import YamlStrategy from "./lib/models/yamlStrategy"
import PicbedServiceTypeEnum from "./lib/enums/picbedServiceTypeEnum"

export { BlogApi, BlogAdaptor }
export { WebApi, WebAdaptor }
export { BlogConfig, BlogPlaceholder, PasswordType, PageType, PostStatusEnum }
export { WebConfig, WebPlaceholder }
export { Post, UserBlog, SiteConfig, CategoryInfo, TagInfo, MediaObject, Attachment }
export { BlogConstants, BlogTypeEnum, PageTypeEnum, CategoryTypeEnum }
export { BlogConstants, BlogTypeEnum, PageTypeEnum, CategoryTypeEnum, PicbedServiceTypeEnum }
export { YamlFormatObj, YamlConvertAdaptor }
export { PostUtil }
export { PreferenceConfig }
Expand Down
5 changes: 4 additions & 1 deletion libs/zhi-blog-api/src/lib/PostUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ class PostUtil {
// 分类合并
if (yamlObj?.categories && yamlObj.categories.length > 0) {
const combinedCategories = [
...new Set([...post.categories.map((cate) => cate.trim()), ...yamlObj.categories.map((cate) => cate.trim())]),
...new Set([
...(post?.categories ?? []).map((cate) => cate.trim()),
...yamlObj.categories.map((cate) => cate.trim()),
]),
].filter((cate) => cate.trim() !== "")

post.categories = combinedCategories.length > 0 ? combinedCategories : []
Expand Down
25 changes: 25 additions & 0 deletions libs/zhi-blog-api/src/lib/blogConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import BlogPlaceholder from "./blogPlaceholder"
import PageTypeEnum from "./enums/pageTypeEnum"
import CategoryTypeEnum from "./enums/categoryTypeEnum"
import PreferenceConfig from "./PreferenceConfig"
import PicbedServiceTypeEnum from "./enums/picbedServiceTypeEnum"

/**
* 页面类型
Expand Down Expand Up @@ -164,6 +165,16 @@ abstract class BlogConfig {
*/
public middlewareUrl?: string

/**
* 新跨域代理地址
*/
public corsAnywhereUrl?: string

/**
* cookie数组
*/
public corsCookieArray: string[]

/**
* 是否启用用户名
*/
Expand Down Expand Up @@ -254,6 +265,16 @@ abstract class BlogConfig {
*/
public cateSearchEnabled?: boolean

/**
* 是否支持图片上传
*/
public bundledPicbedSupported?: boolean

/**
* 图床服务类型
*/
public picbedService?: PicbedServiceTypeEnum

protected constructor() {
this.home = ""
this.apiUrl = ""
Expand All @@ -269,6 +290,8 @@ abstract class BlogConfig {
this.placeholder = undefined
this.preferenceConfig = new PreferenceConfig()
this.middlewareUrl = ""
this.corsAnywhereUrl = ""
this.corsCookieArray = []
this.usernameEnabled = false
this.showTokenTip = false
this.allowPreviewUrlChange = true
Expand All @@ -287,6 +310,8 @@ abstract class BlogConfig {
this.useMdFilename = false
this.usePathCategory = false
this.cateSearchEnabled = false
this.bundledPicbedSupported = false
this.picbedService = PicbedServiceTypeEnum.None
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* Copyright (c) 2024, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,16 +23,22 @@
* questions.
*/

import { SiyuanDevice } from "zhi-device"

/**
* 加载 Electron 内部的依赖
*
* @param module
* 图片床服务类型枚举
*/
const electronRequire = (module: string) => {
const win = SiyuanDevice.siyuanWindow()
return win.require(module)
enum PicbedServiceTypeEnum {
/**
* PicGo 插件
*/
PicGo = "picgo",
/**
* 内置
*/
Bundled = "bundled",
/**
* 无
*/
None = "none",
}

export { electronRequire }
export default PicbedServiceTypeEnum
7 changes: 7 additions & 0 deletions libs/zhi-blog-api/src/lib/models/userBlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,18 @@ class UserBlog {
* xmlrpc地址
*/
xmlrpc?: string
/**
* 元数据映射,用于存储其他的元数据。可能不在上面的字段之内的
*
* 存储之后会字段映射到 BlogConfig 的字段里面去
*/
metadataMap: Record<string, any>

constructor() {
this.blogid = ""
this.url = ""
this.blogName = ""
this.metadataMap = {}
}
}

Expand Down
7 changes: 7 additions & 0 deletions libs/zhi-cmd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# zhi-cmd

## 0.8.1

### Patch Changes

- Updated dependencies
- zhi-device@2.11.0

## 0.8.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-cmd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-cmd",
"version": "0.8.0",
"version": "0.8.1",
"type": "module",
"description": "commond utils for siyuan-note",
"main": "./dist/index.cjs",
Expand Down
30 changes: 30 additions & 0 deletions libs/zhi-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# zhi-common

## 1.33.0

### Minor Changes

- feat: add time zone support

## 1.32.0

### Minor Changes

- feat: add asset api

## 1.31.0

### Minor Changes

- feat: add hasKey

## 1.30.0

### Minor Changes

- fix title handle error

## 1.29.0

### Minor Changes

- fix title handle

## 1.28.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-common",
"version": "1.28.0",
"version": "1.33.0",
"type": "module",
"description": "a collection of util tools",
"main": "./dist/index.js",
Expand Down
Loading