Skip to content

Commit

Permalink
Merge pull request #315 from terwer/dev
Browse files Browse the repository at this point in the history
feat: add events support
  • Loading branch information
terwer committed Mar 14, 2024
2 parents dc1b25b + 7d7678e commit cf15229
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 3 additions & 1 deletion libs/Universal-PicGo-Core/src/core/UniversalPicGo.ts
Expand Up @@ -8,17 +8,19 @@
*/

import { simpleLogger } from "zhi-lib-base"
import { EventEmitter } from "../utils/nodePolyfill"

/*
* 思源笔记内部 PicGO 对象定义
*
* @version 1.6.0
* @since 1.4.5
*/
class UniversalPicGo {
class UniversalPicGo extends EventEmitter {
private logger = simpleLogger("universal-picgo-api", "universal-picgo", false)

constructor() {
super()
this.logger.info("UniversalPicGo inited")
}
}
Expand Down
5 changes: 1 addition & 4 deletions libs/Universal-PicGo-Core/src/index.ts
@@ -1,6 +1,3 @@
import { UniversalPicGo } from "./core/UniversalPicGo"

/**
* 思源笔记 PicGO API 入口
*/
export default UniversalPicGo
export { UniversalPicGo }
11 changes: 11 additions & 0 deletions libs/Universal-PicGo-Core/src/utils/nodePolyfill.ts
@@ -0,0 +1,11 @@
/*
* 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.
*/
import { EventEmitter } from "node:events"

export { EventEmitter }
6 changes: 6 additions & 0 deletions libs/Universal-PicGo-Core/vite.config.ts
Expand Up @@ -6,6 +6,7 @@ import { viteStaticCopy } from "vite-plugin-static-copy"
import dts from "vite-plugin-dts"
import minimist from "minimist"
import livereload from "rollup-plugin-livereload"
import { nodePolyfills, PolyfillOptions } from "vite-plugin-node-polyfills"

const args = minimist(process.argv.slice(2))
const isWatch = args.watch || args.w || false
Expand All @@ -20,6 +21,11 @@ export default defineConfig({
plugins: [
dts(),

nodePolyfills({
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}) as any,

viteStaticCopy({
targets: [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/picgo-plugin-app/src/pages/PicGoIndex.vue
Expand Up @@ -8,14 +8,14 @@
-->

<script setup lang="ts">
import SyPicgo from "../../../../libs/Universal-PicGo-Core"
import { UniversalPicGo } from "universal-picgo"
import { createAppLogger } from "@/utils/appLogger.ts"
const logger = createAppLogger("picgo-index")
const handleTest = () => {
const api = new SyPicgo()
logger.debug("api =>", api)
const picgo = new UniversalPicGo()
logger.debug("picgo =>", picgo)
}
</script>

Expand Down

0 comments on commit cf15229

Please sign in to comment.