ITADN
nextcloud-libraries/nextcloud-vue
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

@nextcloud/vue

npm last version Dependabot status

🖼️ 用于使用 Vue 构建 Nextcloud 应用的 UI Kit

📄 文档

版本目标文档
v9.x [main]Nextcloud 31+ (Vue 3)https://nextcloud-vue-components.netlify.app
v8.x [stable8]Nextcloud 28+ (Vue 2)https://stable8--nextcloud-vue-components.netlify.app
v7.x [stable7]Nextcloud 25 - 27https://stable7--nextcloud-vue-components.netlify.app
v6.x [stable6]Nextcloud 24 - 25https://stable6--nextcloud-vue-components.netlify.app

📦 安装

npm i @nextcloud/vue@next

🚀 用法

使用时导入相应的组件和其他模块。更多详情请参阅文档。

import NcButton from '@nextcloud/vue/components/NcButton'
import { useHotKey } from '@nextcloud/vue/composables/useHotKey'

从单个根目录导入也是可用的。请谨慎使用:在某些情况下,这可能会导致构建时间变慢和包体积增大。

import { NcButton, useHotKey } from '@nextcloud/vue'

🤝 贡献

📜 如何贡献

  1. It's always good to check/create an issue first and discuss the problem or feature you want to work on
  2. Fork the repository and create a new branch
  3. Make the changes
  4. Check the change in Vue-Styleguidist and/or Nextcloud apps
    • Do not forget to lint and test your changes
    • If possible, add tests and documentation for your changes
  5. Commit and push your changes, create a Pull Request
  6. Get your PR reviewed
    • If you don't receive a feedback in a week, feel free to mention the maintainers, for example, last developers worked on the module
  7. Get your PR merged

请阅读行为准则。本文档提供了一些指导,以确保 Nextcloud 参与者能够在积极且鼓舞人心的氛围中有效合作,并解释我们如何共同加强和支持彼此。

有关如何贡献的更多信息:https://nextcloud.com/contribute/

🧑‍💻 开发环境搭建

首先,使用 npm 安装依赖项:

npm ci

🐸 使用 Styleguidist 进行开发

开发和调试 @nextcloud/vue 最简单的方式是通过 vue-styleguidist 使用我们的实时文档。

运行带有组件文档和 playground 的开发服务器:

npm run styleguide

你还可以通过设置 NEXTCLOUD_LEGACY 环境变量来测试设计在旧版 Nextcloud 中是否仍然有效。

NEXTCLOUD_LEGACY=y npm run styleguide

单元测试

npm run test

组件测试

[!TIP] 我们使用 Playwright 进行组件测试。

如果未满足系统要求, 请尝试使用提供的开发容器

它也与 CI 环境相匹配,因此使用它生成的快照在 CI 中不太容易失效。

npm run test:component # or test:component:gui

☁️ 使用 Nextcloud 应用进行开发

要在 Nextcloud 应用中测试或调试 @nextcloud/vue,您需要 pack 该库并安装到应用中。

  1. In nextcloud-vue:
    1. Build the library with:
      • npm run dev for development build
      • npm run build for production build
    2. Pack with npm pack
  2. In the Nextcloud app:
    1. Install the packed file by path to the file, for example:
      npm install --no-save ../../../nextcloud-vue-9.3.1.tgz
    2. Rebuild the app or run it in watch mode
    3. To remove the linked package, reinstall dependencies with npm ci
  3. Repeat every time you do a change in @nextcloud/vue
  4. Do not commit the created .tgz file

[!WARNING] 不要使用 npm link

虽然这是一种将本地 npm 包连接到另一个包的简单且流行的方式,但它没有正确的依赖解析,从而导致问题。通过 npm pack 添加包与安装已发布的包完全相同。

🌐 翻译

使用 src/l10n.js 中的 tn 函数来显示翻译后的字符串。它们遵循来自 @nextcloud/l10n/gettextgettextngettext 接口。

<script setup lang="ts">
import { t } from '../../l10n.js'
</script>

<template>
	<element>
		{{ t('Choose') }}
	</element>
</template>

当你编辑/创建翻译字符串时,你需要更新 l10n 文件。 我们出色的翻译社区随后会收到通知,并且一个机器人将自动同步翻译。

npm run l10n:extract

📤 发布新版本

  • Pull the latest changes from main or stableX
  • Checkout a new branch with the tag name (e.g v4.0.1): git checkout -b v<version>
  • Run npm version patch --no-git-tag-version (npm version minor --no-git-tag-version if minor). This will return a new version name, make sure it matches what you expect
  • Generate the changelog content from the release page. Create a draft release, select the previous tag, click generate then paste the content to the CHANGELOG.md file
    1. adjust the links to the merged pull requests and authors so that the changelog also works outside of GitHub by running npm run prerelease:format-changelog. This will apply this regex: by @([^ ]+) in ((https://github.com/)nextcloud-libraries/nextcloud-vue/pull/(\d+)) Which this as the replacement: [\#$4]($2) \([$1]($3$1)\)
    2. use the the version as tag AND title (e.g v4.0.1)
    3. add the changelog content as description (https://github.com/nextcloud-libraries/nextcloud-vue/releases)
  • Commit, push and create PR
  • Get your PR reviewed and merged
  • Create a milestone with the follow-up version at https://github.com/nextcloud-libraries/nextcloud-vue/milestones
  • Move all open tickets and PRs to the follow-up
  • Close the milestone of the version you release
  • Publish the previously drafted release on GitHub image

发布预发布版本

预发布版本可以按照上述描述的方式构建,但需要进行手动调整,以避免 npm 将预发布版本发布给所有用户:

  1. 将 latest 标签重新指向最后一个稳定版本

    npm dist-tag add @nextcloud/vue@5.4.0 latest

  2. 将新的预发布版本标记为 next

    npm dist-tag add @nextcloud/vue@6.0.0-beta.2 next