Skip to content

Commit

Permalink
feat: upload list
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 21, 2024
1 parent f105b1d commit ee955b0
Show file tree
Hide file tree
Showing 26 changed files with 1,744 additions and 71 deletions.
6 changes: 5 additions & 1 deletion libs/zhi-siyuan-picgo/package.json
Expand Up @@ -29,8 +29,12 @@
"@terwer/vite-config-custom": "^0.7.6"
},
"dependencies": {
"js-md5": "^0.8.3",
"universal-picgo": "workspace:*",
"zhi-common": "^1.31.0",
"zhi-device": "^2.11.0",
"zhi-lib-base": "^0.8.0",
"universal-picgo": "workspace:*"
"zhi-siyuan-api": "^2.18.6"
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 3 additions & 2 deletions libs/zhi-siyuan-picgo/src/index.spec.ts
@@ -1,7 +1,8 @@
import { describe, it } from "vitest"
import { getFileHash } from "./lib/utils/md5Util"

describe("index", () => {
it("test index", () => {
console.log("hello")
console.log(getFileHash("hello"))
})
})
})
5 changes: 3 additions & 2 deletions libs/zhi-siyuan-picgo/src/index.ts
Expand Up @@ -19,8 +19,9 @@ import {
PicgoTypeEnum,
PluginLoaderDb,
} from "universal-picgo"
import { SiyuanConfig as SiyuanPicgoConfig } from "zhi-siyuan-api"

export { SiyuanPicgoPostApi }
export { SiyuanPicgoConfig, SiyuanPicgoPostApi }
export { ConfigDb, PluginLoaderDb, ExternalPicgoConfigDb }
export { PicgoTypeEnum }
export { type IPicGo, type IImgInfo, type IPicgoDb, type IConfig, type IExternalPicgoConfig }
export { type IPicGo, type IImgInfo, type IPicgoDb, type IConfig, type IExternalPicgoConfig }
54 changes: 54 additions & 0 deletions libs/zhi-siyuan-picgo/src/lib/models/ImageItem.ts
@@ -0,0 +1,54 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2023-2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

import { getFileHash } from "../utils/md5Util"

/**
* 图片信息
*/
export class ImageItem {
/**
* 文件,
*/
name: string
/**
* 文件名称的Hash,构造函数指定
*/
hash: string
/**
* 原始资源地址
*/
originUrl: string
/**
* 资源地址
*/
url: string
/**
* 资源备注
*/
alt?: string
/**
* 标题
*/
title?: string
/**
* 是否本地
*/
isLocal: boolean

constructor(originUrl: string, url: string, isLocal: boolean, alt?: string, title?: string) {
this.originUrl = originUrl
this.name = originUrl.substring(originUrl.lastIndexOf("/") + 1)
this.hash = getFileHash(this.name)
this.url = url
this.isLocal = isLocal
this.alt = alt ?? ""
this.title = title ?? ""
}
}
40 changes: 40 additions & 0 deletions libs/zhi-siyuan-picgo/src/lib/models/ParsedImage.ts
@@ -0,0 +1,40 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

/**
* 解析的图片
*
* @author terwer
* @since 0.8.0
*/
export class ParsedImage {
/**
* 链接
*/
url: string
/**
* 备注
*/
alt: string
/**
* 标题
*/
title: string
/**
* 是否本地
*/
isLocal: boolean

constructor() {
this.url = ""
this.isLocal = false
this.alt = ""
this.title = ""
}
}
37 changes: 37 additions & 0 deletions libs/zhi-siyuan-picgo/src/lib/models/PicgoPostResult.ts
@@ -0,0 +1,37 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2022-2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

/**
* Picgo处理文章统一返回结果
*/
export class PicgoPostResult {
/**
* 是否成功
*/
flag: boolean
/**
* 是否有图片
*/
hasImages: boolean
/**
* 处理后的文章链接
*/
mdContent: string
/**
* 错误信息
*/
errmsg: string

constructor() {
this.flag = false
this.hasImages = false
this.mdContent = ""
this.errmsg = ""
}
}

0 comments on commit ee955b0

Please sign in to comment.