Skip to content

Commit

Permalink
修复循环依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
ikenxuan committed Nov 29, 2024
1 parent 699ded0 commit 86e9350
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const haha = new amagi({
})
Config.app.APIServer && haha.startClient(Config.app.APIServerPort)

common.mkdir(`${Version.karinPath}/data/${Version.pluginName}`)
common.mkdir(`${Version.karinPath}/temp/${Version.pluginName}/kkkdownload/video/`)
common.mkdir(`${Version.karinPath}/temp/${Version.pluginName}/kkkdownload/images/`)
logger.info(`${logger.green(`[插件:${Version.pluginName}]`)} ${logger.violet(`${Version.pluginVersion}`)} 初始化完成~`)
21 changes: 0 additions & 21 deletions src/module/db/base.ts

This file was deleted.

13 changes: 11 additions & 2 deletions src/module/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { Model } from 'sequelize'
import { join } from 'node:path'

import { DataTypes, sequelize } from './base'
import { DataTypes, Sequelize } from 'sequelize'

/** 创建 Sequelize 实例,需要传入配置对象。 */
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: join((process.cwd()).replace(/\\/g, '/'), 'data', 'karin-plugin-kkk', 'push.db'),
logging: false
})

/** 测试数据库连接是否成功 */
await sequelize.authenticate()

export interface BilibiliDBType {
/** UP主UID */
Expand Down
4 changes: 3 additions & 1 deletion src/module/utils/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import fs from 'node:fs'

import { KarinMessage, logger } from 'node-karin'

import { Config, Version } from '@/module/utils'
import { Config } from '@/module/utils'

import { Version } from './Version'

/** 常用工具合集 */
export const Common = {
Expand Down
24 changes: 18 additions & 6 deletions src/module/utils/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ const __dirname = dirname(__filename)

const pluginPath = join(__dirname, '..', '..', '..').replace(/\\/g, '/')

export const Version = {
class version {
/** 插件名字 */
pluginName: basename(pluginPath),
get pluginName () {
return basename(pluginPath)
}
/** 插件版本号 */
pluginVersion: common.pkgJson('karin-plugin-kkk')?.version,
get pluginVersion () {
return common.pkgJson('karin-plugin-kkk')?.version
}
/** 插件路径 */
pluginPath: join(__dirname, '..', '..', '..').replace(/\\/g, '/'),
get pluginPath () {
return join(__dirname, '..', '..', '..').replace(/\\/g, '/')
}
/** Karin版本 */
karinVersion: Cfg.package.version,
get karinVersion () {
return Cfg.package.version
}
/** Karin程序/客户端路径 */
karinPath: (process.cwd()).replace(/\\/g, '/')
get karinPath () {
return (process.cwd()).replace(/\\/g, '/')
}
}

export const Version = new version()

0 comments on commit 86e9350

Please sign in to comment.