@bigbinary/neeto-unlisted-links-frontend

中文文档
0.1.5发布于 2026/08/06UNLICENSEDTypeScriptESM + CJS近 30 天下载 2777

前端模式和钩子,用于管理横跨neto产品的未上市链接.

中文使用文档
文档目录5 节
  1. 目录
  2. 用主机应用程序开发
  3. 发动机
  4. 前端软件包
  5. 出版指令

需要挂出链接引擎

这个 neeto-unlisted-links-engine 管理横跨 neto 的未上市公共链接 产品。 未列出的链接是一个秘密的,非索引的 URL,它只允许读取 访问特定资源(例如文章、项目、板子)而不制作 全球公众的资源。 链接可以选择自动过期.

目录

  1. 用主机应用程序开发
  2. 出版指令

用主机应用程序开发

发动机

安装

  1. 将宝石添加到主机应用程序 Gemfile数字 :
    gem "neeto-unlisted-links-engine"
    
  2. 安装它 :
    bundle install
    
  3. 将迁移文件复制到您的主机应用程序 :
    bin/rails generate neeto_unlisted_links_engine:install
    
  4. 运行迁移 :
    bin/rails db:migrate
    

使用量

包含 Unlistable 记录可未列入清单的模型 链接。 模型应该 belong_to 组织(或任何响应的物体) 改为 root_url:

class Article < ApplicationRecord
  include NeetoUnlistedLinksEngine::Unlistable
  belongs_to :organization
end

关注线 a has_one :unlisted_link 协会。 您可以读取/复制 链接通过 NeetoUnlistedLinksEngine::LinksService数字 :

service = NeetoUnlistedLinksEngine::LinksService.new(article)
service.generate_link
service.regenerate_link(expiration_type: "thirty_days",
  expiration_date: 30.days.from_now)
service.update(status: "inactive")
管理路线

主机应用程序负责曝光经认证的, 筑巢 show编号 :regenerate 无法列出的资源的路由——这是 这是什么 前端软件包是因为 resourceUrl 点在, 还有什么 LinksService sit坐后. 举例来说 Document窝 在一个项目下:

resources :projects, param: :sid do
  # ...
  resources :documents, module: :projects, param: :sid do
    resource :unlisted_link, only: %i[show], module: :documents, param: :sid do
      member do
        post :regenerate
      end
    end
    # ...
  end
end

这与下列公共宣传路线不同: 上方是用于查看/重生链接的认证内应用 API (并驱动 UnlistedLinks 模式),而公共路线是 有秘密URL的人的路由不正确 实际上访问.

公众获取

发动机载着一个抽象的 NeetoUnlistedLinksEngine::UnlistedLinksController 用于主机应用程序的子类, 而不是写公开的 控制器从零开始。 它处理未列出的资源(及其 附件)使用捆绑的视图和布局,只需要主机 执行单一方法的控制器 : #load_record。 。 。 .

# frozen_string_literal: true
class UnlistedLinksController < NeetoUnlistedLinksEngine::UnlistedLinksController
  private
    def load_record
      return nil if @organization.nil?

      unlisted_link = NeetoUnlistedLinksEngine::Link.resolve(params[:unlisted_link_identifier])
      document = unlisted_link&.unlistable
      return nil unless document.is_a?(Document)
      return nil unless document.organization_id == @organization.id

      @record = document
      @content = NeetoEditorEngine.sanitize(@record.body).html_safe
      @attachments = @record.attachments
    end
end
# config/routes.rb
get "/public/:unlisted_link_identifier", to: "unlisted_links#show"

一些值得举出的例子:

  • #load_record 将当前搜索范围 @organization (设置于 随便啦 before_action 主机应用程序已经用于解决租户) 并提前返回 @record 如果没有组织,则未设置 如果解析的资源不是预期模式,链接就不会解决 (单位:千美元)Document 或者它不属于那个组织 任何一项 这些案件涉及: #render_not_found。 。 。 .
  • @content 已经通过 NeetoEditorEngine.sanitize 标记 html_safe 之前交给观众,因为 @record.body 持有 丰富的,用户授权的HTML,不应被解密.
  • 路由参数的命名是为了匹配主机应用程序所称的 (单位:千美元):unlisted_link_identifier 上面),只要确保 #load_record 读取 同一个参数名称.

如何运作

  • #show 电话 #load_record,然后使 neeto_unlisted_links_engine/unlisted_project/show 若为 @record 在场, 或打电话 #render_not_found 否则.
  • #load_record 必须由主机控制器定义,并预计会设置 @record, (中文(简体) ), @content,以及 @attachments. 基础执行提高 NotImplementedError 如果它不是压倒性的.
  • #render_not_found 重定向到 Rails.application.vault.not_found_redirect_link 默认。 如果您需要不同的控制器, 在主机控制器中覆盖它 未发现的行为.
  • 观点使得 @record.title,原始内容 @content,如果 @attachments 目前存在,从 cdn_attachment_url(attachment.blob)。 。 。 .
  • 风景在引擎内部 neeto_unlisted_links_engine/unlistable 布局, 一个最小的独立 HTML 外壳( 属于 <head>,样式,以及需要编辑的内容样式表) 因此公用页面不会继承主机应用程序的正常布局.
# app/controllers/neeto_unlisted_links_engine/unlisted_links_controller.rb (engine)
module NeetoUnlistedLinksEngine
  class UnlistedLinksController < ApplicationController
    before_action :load_record
    layout "neeto_unlisted_links_engine/unlistable"

    def show
      if @record.nil?
        render_not_found
      else
        render "neeto_unlisted_links_engine/unlisted_project/show"
      end
    end

    private
      def load_record
        raise NotImplementedError,
          "Host controller must define #load_record (the one which will " \
          "include the @record and the @content and @attachments )"
      end

      def render_not_found
        redirect_to Rails.application.vault.not_found_redirect_link
      end
  end
end

前端软件包

匹配的 npm 包是 @bigbinary/neeto-unlisted-links-frontend它输出一种模式,即: 资源 URL 前缀,显示未列出的链接、其过期状态和 a 复生出流.

import { UnlistedLinks } from "@bigbinary/neeto-unlisted-links-frontend";
<UnlistedLinks
  isOpen={isOpen}
  onClose={onClose}
  resourceUrl="/v1/projects/:project_sid/documents/:document_sid/unlisted_link"
/>;

resourceUrl 应指 管理路径 (单位:千美元)GET 为显示, POST .../regenerate 用于特定 记录模式打开.

出版指令

  1. 弹出 lib/neeto_unlisted_links_engine/version.rb。 。 。 .
  2. 更新 CHANGELOG.md。 。 。 .
  3. gem build neeto-unlisted-links-engine.gemspec。 。 。 .
  4. gem push neeto-unlisted-links-engine-<version>.gem --host https://private-gems.neeto.com。 。 。 .
  5. 对于前端包, 凸起 package.json运行 yarn build,以及 npm publish。 。 。 .

版本与发布记录

@bigbinary/neeto-unlisted-links-frontend 共发布 5 个版本,首次发布于 2026/04/27;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.1.5latest2026/08/063 个月前
0.1.42026/07/153 个月前
0.1.32026/06/294 个月前
0.1.22026/05/056 个月前
0.1.12026/04/276 个月前

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

@bigbinary/neeto-unlisted-links-frontend 是什么?

前端模式和钩子,用于管理横跨neto产品的未上市链接.

如何安装 @bigbinary/neeto-unlisted-links-frontend?

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

@bigbinary/neeto-unlisted-links-frontend 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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

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

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