### Start Development Server Source: https://open.tezign.com/docs/frontend/dam-plugin/getting-started Run the development environment to build and test the plugin. ```bash npm run dev ``` -------------------------------- ### Initialize tezignSdk Source: https://open.tezign.com/docs/frontend/tezign-external-track/weapp/init Import the SDK and call the init method with the required parameters to start tracking. ```javascript import tezignSdk from '@tezignlab/tezign-external-track/miniprogram_dist'; // 初始化 tezignSdk.init(initParams); ``` -------------------------------- ### Install DAM Plugin Uploader Source: https://open.tezign.com/docs/frontend/dam-plugin/getting-started Install the global CLI tool required to upload plugin packages to the Tezign platform. ```bash npm install --global @tezignlab/dam-plugin-uploader@latest ``` -------------------------------- ### Install @tezignlab/tezign-external-track Source: https://open.tezign.com/docs/frontend/tezign-external-track/weapp/install Use a package manager to add the dependency to your project. ```shell // npm npm install @tezignlab/tezign-external-track // yarn yarn add @tezignlab/tezign-external-track // pnpm pnpm install @tezignlab/tezign-external-track ``` -------------------------------- ### Import and Install Plugins via npm Source: https://open.tezign.com/docs/frontend/tezign-external-track/weapp/plugins/import Import specific plugins from the SDK and register them using the use method before initialization. ```javascript // 引入插件 import tezignSdk, { pageViewPlugin, persistLocalStoragePlugin } from '@tezignlab/tezign-external-track/miniprogram_dist' tezignSdk.use(pageViewPlugin(pvPluginsOptions), persistLocalStoragePlugin(persistLocalStoragePluginOptions)]) ``` -------------------------------- ### Plugin Implementation Files Source: https://open.tezign.com/docs/frontend/dam-plugin/slots/portal-header-action-right Example implementation of the plugin using a TypeScript entry point and a React application component. ```typescript import { render } from './App'; const cssString = ''; const useShadowDom = true; export { cssString, render, useShadowDom }; ``` ```typescript import React from 'react'; import ReactDOM from 'react-dom/client'; function App(props: any) { return ( ); } const weakMap = new WeakMap(); function render(root: HTMLElement | ShadowRoot, props?: any) { console.log('...', arguments); let reactDOMRoot = weakMap.get(root); if (!reactDOMRoot) { reactDOMRoot = ReactDOM.createRoot(root); weakMap.set(root, reactDOMRoot); } reactDOMRoot.render( , ); } export { render }; export default App; ``` -------------------------------- ### Initialize Selector via postMessage Source: https://open.tezign.com/docs/frontend/group-selector/config/base Example of sending the configuration object to an iframe using the postMessage API. ```javascript iframe.contentWindow.postMessage( { type: 'tezign-asset-group-selector-config', data: { title: '选择素材组', rootSelectable: true, showSearch: true, showRecentlyAdded: true, showEdit: false, showTitle: true, hideCancel: true, }, }, '*', ); ``` -------------------------------- ### Listen for Page Ready Event Source: https://open.tezign.com/docs/frontend/asset-selector/events/page-ready Example implementation of a message listener in the parent window to detect when the iframe is ready. ```html 素材上传父页面