@bigbinary/neeto-activities-frontend

中文文档
2.3.1发布于 2026/11/01UNLICENSEDTypeScriptESM + CJS近 30 天下载 2376

一个回波作为新纳米结构,配置,数据等的真理来源.

中文使用文档
文档目录6 节
  1. 示例
  2. 关切
  3. 复杂执行
  4. 使用不同的提供者
  5. 在特殊情况下跳过活动?
  6. 父日志活动

需要活动-无

管理活动后端结构的纳米.

司马

create_table :neeto_activities_engine_activities, id: :uuid do |t|

   # Parent association for the activity, example: Ticket
   t.references :trackable, polymorphic: true, index: true, type: :uuid

   # Performer of the activity, example: User
   t.references :performer, polymorphic: true, type: :uuid

   # Unique key per activity that can be used in translations to render on UI
   t.string :key

   # Any additional details that might be helpful for building the translations or debugging purpose
   t.jsonb :metadata, default: {}

   t.timestamps

end

使用量

示例

检查为 更新车票状况 {\fn华文仿宋\fs16\1cHD1D1D1}在德克岛.

#<NeetoActivitiesEngine::Activity:0x000000013237f158> {
                :id => "d0458158-68d1-423f-b364-d22a8916f6d0",
               :key => "activity.ticket.update.status",
    :trackable_type => "Ticket",
      :trackable_id => "c5104a50-2eff-49a3-accb-f2fa8f4fc1f7",
    :performer_type => "User",
      :performer_id => "b028d29e-f40a-4c09-9222-357cfe84e2c3",
        :created_at => Mon, 30 Oct 2023 10:23:26.705884000 UTC +00:00,
        :updated_at => Mon, 30 Oct 2023 10:23:26.705884000 UTC +00:00,
          :metadata => {
        "new_value" => "trash",
        "old_value" => "open"
    }
}

关切

我们有一个关切,可以列入需要跟踪这些活动的模式, 这一关切增加了协会和帮助者的方法,使创建活动变得容易.

参考: 新活动引擎:可追踪

示例

class User
   include NeetoActivitiesEngine::Trackable

   after_save :log_account_block_activity!, if: :blocked?

   private

      def log_account_block_activity!
         old_value, new_value = saved_change_to_blocked_at

         key = new_value ? "activity.user.blocked" : "activity.user.unblocked"
         metadata = { performer_name: User.current&.name }

         log_activity!(key:, metadata:, performer: User.current)
      end
end

复杂执行

netoDesk需要很多定制的机票活动, 为了实现它, 我们制造了另一个令人关切的问题,除了上述关切之外,还起作用.

参考: 应用程序/模型/关切/可追踪/盘点

用法 :

class Ticket
   include NeetoActivitiesEngine::Trackable
   include Trackable::Tickets # Depends on NeetoActivitiesEngine::Trackable
end

使用不同的提供者

使用 User.current 这不是一个好的做法, 它也不适合所有的地方.

例: 在neetoDesk,自动化规则可以更新入场券, 艺人来了 Automation::Rule 没有 User。 。 。 .

为了克服这个问题,我们 activity_performer attr 访问器.

class Ticket
   include NeetoActivitiesEngine::Trackable

   after_save :log_status_activity!, if: :saved_change_to_status?

   private

      def log_status_activity!
         old_value, new_value = saved_change_to_status

         key = "activity.ticket.status.update"
         metadata = { old_value:, new_value: }

         log_activity!(key: , metadata:, performer: activity_performer)
      end
end

ticket.activity_performer = Automation::Rule.first
ticket.update(status: :closed)

在特殊情况下跳过活动?

职业上,商业逻辑要求跳出活动. 为此,我们增加了 skip_activity 关心的用户.

示例 假设您在更新 Rails 控制台的票时想要跳过活动 .

class Ticket
   include NeetoActivitiesEngine::Trackable

   after_save :log_status_activity!, if: :saved_change_to_status?

   private

      def log_status_activity!
         old_value, new_value = saved_change_to_status

         key = "activity.ticket.status.update"
         metadata = { old_value:, new_value: }

         log_activity!(key: , metadata:, performer: activity_performer)
      end
end

# rails c
ticket.skip_activity = true
ticket.update(status: :closed)

父日志活动

有时某项活动属于母资源或另一种资源,而不是活动所触发的模型.

示例:任务可以属于协议,任务活动应当记录在协议上.

class Deal
   include NeetoActivitiesEngine::Trackable
    ...
end

class Task
   include NeetoActivitiesEngine::Trackable
   belongs_to :deal

   after_update :log_task_activity!, if: :saved_change_to_status?

   private

      def log_task_activity!
         old_value, new_value = saved_change_to_status

         key = "activity.task.status_updated"
         metadata = { old_value:, new_value: }

         log_activity_on_parent!(
            key:,
            parent: deal,
            metadata:,
            performer: User.current
         )
      end
end

版本与发布记录

@bigbinary/neeto-activities-frontend 共发布 41 个版本,首次发布于 2023/10/27;过去 12 个月发布了 20 个版本。

版本发布日期距今
2.3.1latest2026/11/017 天前
2.3.1-beta1beta2026/11/017 天前
2.3.02026/10/309 天前
2.3.0-beta12026/10/309 天前
2.2.12026/10/309 天前
2.2.1-beta12026/10/309 天前

关于 @bigbinary/neeto-activities-frontend 的常见问题

@bigbinary/neeto-activities-frontend 是什么?

一个回波作为新纳米结构,配置,数据等的真理来源.

如何安装 @bigbinary/neeto-activities-frontend?

在项目目录运行 npm install @bigbinary/neeto-activities-frontend,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:qs(6.16.2)、url(0.11.4)、yup(0.32.11)、antd(5.22.1)、util(^0.12.5)、axios(1.20.0)、ramda(0.29.0)、react(18.3.1)、buffer(^6.0.3)、formik(2.4.6)、i18next(22.5.1)、zustand(4.4.2)、dompurify(3.4.17)、js-logger(1.6.1)、react-dom(18.3.1)、classnames(2.5.1)、stream-http(3.2.0)、tailwindcss(3.4.14)、react-helmet(^6.1.0)、os-browserify(0.3.0)、react-i18next(12.3.1)、vm-browserify(1.1.2)、@babel/runtime(7.29.7)、react-toastify(8.0.2)、tty-browserify(0.0.1)、path-browserify(^1.0.1)、https-browserify(1.0.0)、mixpanel-browser(^2.45.0)、react-router-dom(5.3.3)、crypto-browserify(3.12.1)、source-map-loader(4.0.1)、stream-browserify(^3.0.0)、@bigbinary/neetoui(8.8.3)、@honeybadger-io/js(6.10.1)、@bigbinary/neeto-cist(1.0.17)、@honeybadger-io/react(6.1.25)、@tanstack/react-query(5.59.20)、@bigbinary/neeto-icons(1.20.89)、@bigbinary/neeto-molecules(5.9.13)、@tanstack/react-query-devtools(5.59.20)、@bigbinary/neeto-commons-frontend(4.14.8)、@bigbinary/neeto-filters-frontend(4.6.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bigbinary/neeto-activities-frontend 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bigbinary/neeto-activities-frontend 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bigbinary/neeto-activities-frontend 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bigbinary/neeto-activities-frontend 可以商用吗?

@bigbinary/neeto-activities-frontend 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@bigbinary/neeto-activities-frontend 的下载量有多少?

根据 npm 官方下载统计,@bigbinary/neeto-activities-frontend 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,376 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bigbinary/neeto-activities-frontend 还在维护吗?

最新版本 2.3.1 发布于 2026/11/01(7 天前);至今共发布 41 个版本,其中过去 12 个月发布了 20 个;首次发布于 2023/10/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。