Girder 网络组件库
试试看 演示应用。 。 。 . 和我们一起工作 数据. kitware.com。 。 。 .
用法快速启动
最新版本仅支持Vue3. 对于Vue2, @ girder/ 组件 v3.3. 0 应当使用.
安装
维特 用于Girder网络组件的建筑应用程序.
# Install GWC
yarn add @girder/components
# or
npm install @girder/components
初始化
自由输出 组件 (单位:千美元) 插件 缩写为 暂停 (单位:千美元) 通知窗口,并注册 Vuetify 配置。 它可以选择注册所有组件.
使用插件的应用程序初始化示例( 通常为 src/main.js:
/* src/main.js */
import { createApp } from 'vue'
import App from './App.vue'
import GirderPlugin from '@girder/components'
const app = createApp(App)
app.use(GirderPlugin, {
girder: {apiRoot: import.meta.env.VITE_API_ROOT},
notification: {useEventSource: true},
components: true // register all components
})
app.mount('#app')
使用组件
所有组件都是前缀 Girder。 。 。 .
A-la-carte(建议)
在这种情况下,插件不会对所有组件进行注册,因此要单独使用组件,它们应该从名称导入 @girder/components/,因为这个位置在释放物之间是稳定的.
例如:
import { GirderUpload } from '@girder/components/'; // Good
import { Upload } from '@girder/components/src/components/Upload/Upload.vue'; // Unsafe -- may move in the future
由于 Girder 网络组件使用 Vuetify, 您的应用程序必须提供
v-app 财务报告和审定财务报表 v-content 集装箱
在某种祖先层面.
例如,在 src/App.vue数字 :
<!-- src/App.vue -->
<template>
<v-app>
<v-content>
<h1>Welcome {{ currentUserLogin }}</h1>
<GirderAuthentication />
</v-content>
</v-app>
</template>
<script setup>
import { inject, computed } from 'vue';
import { GirderAuthentication } from '@girder/components/';
// Injecting 'rest' is not necessary to use the component,
// but is required to access the results of API calls
const { rest, user } = inject('girder');
const currentUserLogin = computed(() => user.value ? user.value.login : 'anonymous');
</script>
全球登记
在这种情况下,组件由插件注册,所以不需要被导入. 见 演示应用程序 更全面的例子.
高级使用
自定义 Vuetify 配置
自定义额外 vuetify 配置可以通过 vuetifyConfig 选项.
如果您的下游应用程序也在使用 Vuetify 并需要通过额外的配置
选项,必须注意与Girder网络组件相协调.
/* src/main.js */
import { createApp } from 'vue'
import App from './App.vue'
import GirderPlugin from '@girder/components'
const app = createApp(App)
app.use(GirderPlugin, {
girder: {apiRoot: import.meta.env.VITE_API_ROOT},
notification: {useEventSource: true},
vuetifyConfig: {icons: {aliases: {login: 'mdi-circle' }}}
})
app.mount('#app')
说明: 你必须使用Mdi图标包。 图标包不能混合 .
其他安装方法
无需自己安装Girder网络组件,可以导入预建的捆绑.
使用 CDN/UMD 软件
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/@girder/components"></script>
<link rel="stylesheet" href="https://unpkg.com/@girder/components/dist/style.css">
<script>
const app = Vue.createApp({});
app.use(girder);
app.mount('#app');
</script>
这将曝光全局变量下的插件 girder。 。 。 .
使用无害环境管理
<script type="module">
import Gwc, { GirderUpload } from 'https://unpkg.com/@girder/components?module';
const app = Vue.createApp({});
app.use(Gwc);
app.component('GirderUpload', GirderUpload);
app.mount('#app');
</script>
对于开发者
# Project Setup
yarn
# Compile and hot-reload for development
yarn serve
# Build the library for production
yarn build
# Lint and fix source code
yarn lint
yarn lint:style
# Run unit tests
yarn test:unit
使用外部 Girder API
要针对外部 Girder API 构建演示应用程序,请设置
VITE_API_ROOT 环境变量。 例如:
export VITE_API_ROOT=https://data.kitware.com/api/v1
yarn serve
此可变值默认为 http://localhost:8080/api/v1 页:1
正常开发(假设开发者有本地实例)
girder API 服务器正在运行).
当运行在您自己的 Girder API 服务器上时,
确定设置 (简体中文) 相应.
在页面上显示来自 Girder 的私人媒体
如果您的应用程序使用 img 或者说 video 从Girder装入的元素,有几个要求.
- 你必须使用
authenticateWithCredentials选项. - 您必须修改 Girder 的 CORS 允许的源设置 和你的应用程序的原产地完全吻合 您可以使用逗号分隔列表来匹配多个来源, 例如
*, http://localhost:8080, https://myapp.domain.com - 要与帆布或联署材料中装入的元素数据互动,可能需要添加 横跨奥里金属性 对媒体元素.
部署和出版
演示应用自动部署到 gwc.girder.org (英语)。 。 。 .
任何贡献者都可以要求更新已出版的 npmjs 版本,方法是在其中更改版本字符串 package.json 并打开拉取请求。 我们的CI跑者会探测到变化 并在合并时公布 版本更新的PR一般应当独立于功能性PR.
类型定义
TypeScript 类型 def 维持在 index.d.ts。如果您的更改会影响公共 api,请记住更新此文件 .