diff --git a/src/main/backend/entities/plugin.ts b/src/main/backend/entities/plugin.ts index 63d1605..3d16861 100644 --- a/src/main/backend/entities/plugin.ts +++ b/src/main/backend/entities/plugin.ts @@ -128,7 +128,7 @@ export function initPlugin(sequelize: Sequelize) { }, version: { type: DataTypes.STRING(255), - defaultValue: '1.2.0-beta.1', + defaultValue: '1.2.0', allowNull: true, }, source: { diff --git a/src/main/backend/ormconfig.ts b/src/main/backend/ormconfig.ts index 594bd5c..08f83d0 100644 --- a/src/main/backend/ormconfig.ts +++ b/src/main/backend/ormconfig.ts @@ -8,7 +8,7 @@ import { Sequelize } from 'sequelize'; import { Config, initConfig } from './entities/config'; import { initSession } from './entities/session'; import { initMessage } from './entities/message'; -import { initPlugin } from './entities/plugin'; +import { Plugin, initPlugin } from './entities/plugin'; import { initInstance } from './entities/instance'; import { Keyword, initKeyword } from './entities/keyword'; import { TransferKeyword, initTransfer } from './entities/transfer'; @@ -247,6 +247,13 @@ async function initDb(): Promise { ]; await ReplaceKeyword.bulkCreate(replaces); } + + // 因为 Plugin 1.0.0 版本不支持了,这里直接删除 + await Plugin.destroy({ + where: { + version: '1.0.0', + }, + }); } (async () => { diff --git a/src/renderer/common/utils/constants/index.ts b/src/renderer/common/utils/constants/index.ts index 5e89a9b..b67ad86 100644 --- a/src/renderer/common/utils/constants/index.ts +++ b/src/renderer/common/utils/constants/index.ts @@ -1,17 +1,22 @@ export const PluginExtraLib = ` type AppContext = { - app_name: string; // 当前应用名称 - app_id: string; // 当前应用 ID - instance_id: string; // 当前客服实例 ID - username?: string; // 当前操作的用户名 - platform?: string; // 当前所在平台 - has_new_message?: boolean; // 是否有新消息 - has_group_message?: boolean; // 是否有群消息 + CTX_APP_NAME: string; // 当前应用名称 + CTX_APP_ID: string; // 当前应用 ID + CTX_INSTANCE_ID: string; // 当前客服实例 ID + CTX_USERNAME?: string; // 当前操作的用户名 + CTX_PLATFORM?: string; // 当前所在平台 + CTX_HAS_NEW_MESSAGE?: boolean; // 是否有新消息 + CTX_HAS_GROUP_MESSAGE?: boolean; // 是否有群消息 CTX_CURRENT_GOODS?: string; // 当前商品 CTX_CURRENT_GOODS_ID?: string; // 当前商品 ID CTX_MEMBER_TAG?: string; // 会员标签 CTX_FAN_TAG?: string; // 粉丝标签 CTX_NEW_CUSTOMER_TAG?: string; // 新客标签 + CTX_ORDER_STATUS?: string; // 订单状态 + CTX_ORDER_ID?: string; // 订单 ID + CTX_ORDER_AMOUNT?: string; // PDD 平台特有 [订单金额] + CTX_GOODS_SPEC?: string; // PDD 平台特有 [商品规格] + CTX_LOGISTICS_STATUS?: string; // 物流状态 }; type RoleType = 'SELF' | 'OTHER' | 'SYSTEM'; diff --git a/src/renderer/settings-window/components/MessageModal/index.tsx b/src/renderer/settings-window/components/MessageModal/index.tsx index f61bd8e..43b5cb2 100644 --- a/src/renderer/settings-window/components/MessageModal/index.tsx +++ b/src/renderer/settings-window/components/MessageModal/index.tsx @@ -66,6 +66,12 @@ const MessageModal = ({ isOpen, onClose }: MessageModalProps) => { const handleSetDefault = () => { // MockCtx 是一个 Map 对象 + // 先清空所有上下文 + // eslint-disable-next-line no-restricted-syntax + for (const key of ContextKeys) { + setContext(key, ''); + } + // eslint-disable-next-line no-restricted-syntax for (const [key, value] of MockCtx) { setContext(key, value);