auto-exhibition-template-sdk

面向模板项目的前端 SDK,用一份 configJson 定义可配置内容,在 Vue 页面中读取字段值,并通过 Template Bridge 支持跨设备函数联动。

configJson.ts
import { defineTemplateConfig } from 'auto-exhibition-template-sdk/config'
const config = defineTemplateConfig({
  meta: {
    name: '示例模板',
    code: 'demo-template'
  },
  dataSchema: {
    fields: [
      { key: 'title', type: 'string', value: '默认标题' },
      { key: 'poster', type: 'image', value: '/assets/poster.png' },
      {
        key: 'models',
        type: 'array',
        value: [
          {
            type: 'object',
            value: [
              { key: 'name', type: 'string', value: '模型 A' },
              { key: 'url', type: 'file', value: '/assets/model.glb' }
            ]
          }
        ]
      }
    ]
  }
})

export default config

核心特性

声明式配置

通过 TypeScript 类型安全的配置定义,清晰的字段结构和编辑器智能提示支持。

Vite 接入

通过 templateSdkPlugin 接入模板配置,让开发和构建流程保持一致。

运行时取值

简洁的 API 设计,通过 useTemplateValue 组合式函数轻松获取模板字段值。

路径取值

支持 title、profile.name、models[0].url 等路径,组件里读取清晰直接。

灵活扩展

支持 string、number、boolean、image、video、file、object、array 等常见字段。

函数联动

声明模板函数并注册运行时 handler,由 Bridge 和网关完成本地或跨设备调用。

快速开始

1

安装依赖

pnpm add auto-exhibition-template-sdk
2

配置 configJson

定义模板的字段结构和默认值

3

启用 Vite 插件

在 vite.config 中集成 templateSdkPlugin

4

在组件中取值

使用 useTemplateValue 获取响应式字段值

5

注册模板函数

使用 Template Bridge 与其他模板或硬件能力联动

支持的字段类型

string

普通文本字段

number

数字字段

boolean

布尔值字段

image

图片字段

video

视频字段

file

通用文件字段

object

对象字段

array

数组字段