npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cloudbase-vue-next

v0.1.3

Published

[云开发 Vue 插件](https://github.com/TencentCloudBase/cloudbase-vue) 是云开发官方维护的 Vue 插件,提供全局入口、Vue 逻辑组件等功能。

Readme

云开发 Vue3插件

云开发 Vue 插件 是云开发官方维护的 Vue 插件,提供全局入口、Vue 逻辑组件等功能。

安装

npm install --save cloudbase-vue-next

使用

下面我们使用 LoginState 组件,来动态绑定当前页面的登录态。

  • 页面初始化时,显示 '未登录'
  • 之后我们调用[匿名登录](https://docs.cloudbase.net/authentication/ anonymous.html),如果登录成功,则文案将变成 '已登录'

main.js

import {createApp} from "vue"
import Cloudbase from "cloudbase-vue-next"
import App from "./App.vue"
const app = createApp(App)
app.use(Cloudbase, {
    env: "your-env-id",
    region: "your-env-region"
})
app.mount('#app');

App.vue

<template>
  <div id="app">
    <h1>Hello world</h1>
    <LoginState v-slot="{ loginState }">
      <h1>{{ loginState ? "已登录" : "未登录" }}</h1>
    </LoginState>
    <button @click="callFn">调用云函数</button>
  </div>
</template>

<script>
export default {
  async created() {
    // 以匿名登录为例
    await this.$cloudbase
      .auth({ persistence: "local" })
      .anonymousAuthProvider()
      .signIn();
  },
  methods: {
    callFn() {
      this.$cloudbase
        .callFunction({
          name: "vue-echo",
          data: { meg: "Hello world" },
        })
        .then((res) => {
          const result = res.result; //云函数执行结果
          console.log(result);
        });
    },
  },
};
</script>

在setup中使用

<template>
  <div id="app">
    <h1>Hello world</h1>
    <LoginState v-slot="{ loginState }">
      <h1>{{ loginState ? "已登录" : "未登录" }}</h1>
    </LoginState>
    <button @click="callFn">调用云函数</button>
  </div>
</template>

<script>
import { useCloud } from "cloudbase-vue-next"
export default {
  setup(){
    const cloudbase = useCloud({
      env: "your-env-id",
      region: "your-env-region"
    });
    //登录授权
    cloudbase
      .auth({ persistence: "local" })
      .anonymousAuthProvider()
      .signIn();
    //请求函数
    const callFn=()=>{
      cloudbase
      .callFunction({
        name: "vue-echo",
        data: { meg: "Hello world" },
      })
      .then((res) => {
        const result = res.result; //云函数执行结果
        console.log(result);
      });
    }

    return {
      callFn
    }
  }
};
</script>

Plugin API

Vue.$cloudbase

可以在 Vue 组件的 this.$cloudbase 中,获取 Cloudbase 实例

export default {
  data() {
    return {
      docs: []
    }
  },
  async created() {
    // 登录
    await this.$cloudbase.auth({ persistence: "local" }).signInWithTicket(ticket)
    // 数据库查询
    const queryResult = await this.$cloudbase.database().collection('test').where({}).get()
    this.docs = queryResult.data
  }
}

Components

| 组件 | 功能 | | ---- | ---- | | LoginState | 获取并绑定登录状态 | | DatabaseQuery | 数据库查询 | | DatabaseWatch | 数据库实时推送 | | CloudFile | 获取云存储中的文件 |

LoginState

获取登录状态

Props

暂无

Slots

| slot | type | 描述 | | ---------- | ---------------------- | ------------ | | loginState | null or LoginState | 当前是否登录 | | loading | boolean | 是否加载中 |

Example

<LoginState v-slot="{ loginState, loading }">
  <p>{{ loading ? '加载中' : (loginState ? '已登录' : '没登录') }}</p>
</LoginState>

DatabaseQuery

数据库查询

Props

| prop | type | 描述 | | ---------- | ---------- | ------------------------------------------------ | | collection | string | 集合名 | | query | function | 返回自定的查询条件,如 _ => ({ foo: _.gt(2) }) |

Slot

| slot | type | 描述 | | ------- | ----------------- | -------------- | | docs | Array<doc> | 文档组成的数组 | | loading | boolean | 是否加载中 | | error | null or Error | 错误 |

Example

<DatabaseQuery
  v-slot="{ docs, loading, error }"
  collection="messages"
  :query="_ => ({ timestamp: _.gt(1573635456709) })"
>
  <p v-for="{ text } in docs">
    {{ text }}
  </p>
</DatabaseQuery>

DatabaseWatch

数据库实时监听

Props

| prop | type | 描述 | | ---------- | ---------- | ------------------------------------------------ | | collection | string | 集合名 | | query | function | 返回自定的查询条件,如 _ => ({ foo: _.gt(2) }) |

Slot

| slot | type | 描述 | | ------- | ----------------- | -------------- | | docs | Array<doc> | 文档组成的数组 | | loading | boolean | 是否加载中 | | error | null or Error | 错误 |

Example

<DatabaseWatch
  v-slot="{ docs, loading, error }"
  collection="messages"
  :query="_ => ({ timestamp: _.gt(1573635456709) })"
>
  <p v-for="{ text } in docs">
    {{ text }}
  </p>
</DatabaseWatch>

CloudFile

根据 FileID,获取云存储文件的真实 URL

Props

| slot | type | 描述 | | ---- | -------- | ----------------------------- | | id | string | 云存储 ID,形如 cloud://... |

Slot

| slot | type | 描述 | | ------- | ----------------- | -------------- | | url | string | 文件的真实 URL | | loading | boolean | 是否加载中 | | error | null or Error | 错误 |

Example

<CloudFile
    id="cloud://file-cloud-path"
    v-slot="{ url, loading }"
>
  {{ url ? url : 'loading...' }}
</CloudFile>