fix: generateId

This commit is contained in:
ikechan8370 2025-04-10 12:15:01 +08:00
parent 64c77877ac
commit 3c83e270df
6 changed files with 14 additions and 5 deletions

View file

@ -2,6 +2,7 @@ import { ChaiteStorage, Channel } from 'chaite'
import sqlite3 from 'sqlite3'
import path from 'path'
import fs from 'fs'
import { generateId } from '../../../../utils/common.js'
/**
* @extends {ChaiteStorage<import('chaite').Channel>}
@ -250,7 +251,7 @@ export class SQLiteChannelStorage extends ChaiteStorage {
async setItem (id, channel) {
await this.ensureInitialized()
if (!id) {
id = this._generateId()
id = generateId()
}
// 加上时间戳

View file

@ -2,6 +2,7 @@ import { ChaiteStorage, ChatPreset } from 'chaite'
import sqlite3 from 'sqlite3'
import path from 'path'
import fs from 'fs'
import { generateId } from '../../../../utils/common.js'
/**
* @extends {ChaiteStorage<import('chaite').ChatPreset>}
@ -222,7 +223,7 @@ export class SQLiteChatPresetStorage extends ChaiteStorage {
async setItem (id, preset) {
await this.ensureInitialized()
if (!id) {
id = this._generateId()
id = generateId()
}
// 加上时间戳

View file

@ -2,6 +2,7 @@ import { ChaiteStorage, ProcessorDTO } from 'chaite'
import sqlite3 from 'sqlite3'
import path from 'path'
import fs from 'fs'
import { generateId } from '../../../../utils/common.js'
/**
* @extends {ChaiteStorage<import('chaite').ProcessorDTO>}
@ -186,7 +187,7 @@ export class SQLiteProcessorsStorage extends ChaiteStorage {
async setItem (id, processor) {
await this.ensureInitialized()
if (!id) {
id = this._generateId()
id = generateId()
}
// 加上时间戳

View file

@ -2,6 +2,7 @@ import { ChaiteStorage } from 'chaite'
import sqlite3 from 'sqlite3'
import path from 'path'
import fs from 'fs'
import { generateId } from '../../../../utils/common.js'
/**
* @extends {ChaiteStorage<import('chaite').ToolsGroupDTO>}
@ -101,7 +102,7 @@ export class SQLiteToolsGroupStorage extends ChaiteStorage {
async setItem (id, data) {
await this.ensureInitialized()
if (!id) {
id = this._generateId()
id = generateId()
}
// 加上时间戳

View file

@ -2,6 +2,7 @@ import { ChaiteStorage, ToolDTO } from 'chaite'
import sqlite3 from 'sqlite3'
import path from 'path'
import fs from 'fs'
import { generateId } from '../../../../utils/common.js'
/**
* @extends {ChaiteStorage<import('chaite').ToolDTO>}
@ -212,7 +213,7 @@ export class SQLiteToolsStorage extends ChaiteStorage {
await this.ensureInitialized()
if (!id) {
id = this._generateId()
id = generateId()
}
// 加上时间戳

View file

@ -71,3 +71,7 @@ export const dataDir = path.resolve('./plugins/chatgpt-plugin', ChatGPTConfig.ch
if (!fs.existsSync(dataDir)) {
fs.mkdirSync(dataDir, { recursive: true })
}
export function generateId () {
return Date.now().toString(36) + Math.random().toString(36).substring(2, 15)
}