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 🙏

© 2026 – Pkg Stats / Ryan Hefner

easy-aliyun-weboffice

v0.1.2

Published

Aliyun IMM WebOffice Vue3 component

Readme

aliyun-weboffice (Vue 3)

WebOffice (阿里云 IMM WebOffice) 的 Vue3 + TypeScript 组件封装。

安装

  • pnpm add easy-aliyun-weboffice
  • npm i easy-aliyun-weboffice

使用

<template>
  <div class="container">
    <div class="header">
      <el-button @click="opendoc(1)">文档1</el-button>
      <el-button @click="opendoc(2)">文档2</el-button>
    </div>
    <webOffice
      ref="webofficeRef"
      :document="currentDocument"
      :document-request-options="documentRequestOptions"
      :web-office-options="webofficeOptions"
    >
      <template #loading>
        <el-skeleton animated style="width: 100%; height: 100%" />
      </template>

      <template #error="{ msg }">
        <el-empty description="加载失败">
          <div>{{ msg }}</div>
        </el-empty>
      </template>
    </webOffice>
  </div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import { ElButton, ElSkeleton, ElEmpty } from 'element-plus'
import webOffice, { type DocumentRequestOptions, type WebOfficeOptions, type DocumentInfo } from 'easy-aliyun-weboffice'

// 定义组件引用的类型
const webofficeRef = ref<InstanceType<typeof webOffice>>()

// 准备文档
const documents = [
  {
    fileName: '文档1.doc',
    permission: {
      print: true,
      export: true,
      readonly: false
    }
  },
  {
    fileName: '文档2.pdf',
    permission: {
      print: true,
      export: true,
      readonly: true
    }
  }
]

const currentDocument = ref<DocumentInfo>(documents[0] as DocumentInfo)

const opendoc = (fileIndex: number) => {
  currentDocument.value = documents[fileIndex - 1] as DocumentInfo
}

// 配置文档请求选项
const documentRequestOptions = {
  // 配置获取文档Token的接口地址
  getWebofficeDocumentTokenURL: 'https://localhost:7039/getToken',
  // 配置刷新文档Token的接口地址
  refeshWebofficeDocumentTokenURL: 'https://localhost:7039/refeshToken',
  // getWebofficeDocumentTokenFunc:()=>{}, 自定义获取文档Token的方法
  // refeshWebofficeDocumentTokenFunc:()=>{},自定义刷新文档Token的方法
  user: { id: '12345', name: '测试用户' } // 当前用户信息
} as DocumentRequestOptions

// 配置webOffice组件选项
const webofficeOptions = {
  mode: 'normal', // normal-普通模式,simple-简洁模式
  cooperUserAttribute: {
    isCooperUsersAvatarVisible: true // 显示协作用户头像
  },
  // 通用选项
  commonOptions: {
    isShowTopArea: true, // 显示顶部区域
    isShowHeader: true, // 显示头部
    isBrowserViewFullscreen: true, // 是否允许在浏览器全屏模式
    isIframeViewFullscreen: true // 是否在iframe区域内全屏
  },
  // word文档选项
  wordOptions: {
    isShowDocMap: true, // 是否开启目录功能
    isBestScale: false, // 打开文档时,默认以最佳比例显示。
    isShowBottomStatusBar: true // 是否显示底部状态栏
  }
} as WebOfficeOptions

// watch(() => webofficeRef.value?.ins, (ins) => {
//   console.log('webofficeRef',ins);
//   ins?.ApiEvent.AddApiEventListener('fileOpen',(file)=>{
//     console.log('文件打开了',file);
//   })
//   ins?.ApiEvent.AddApiEventListener('fileStatus',(status)=>{
//     console.log('文件保存状态:',status);
//   })

// })

onMounted(async () => {
  // 等待组件实例初始化完成,获取实例对象(如果切换文档此方式无法获取新实例,可以使用上面watch)
  const ins = await webofficeRef.value?.ready()

  // 注册事件:
  // 不推荐此方式注册事件,切换文档后ins会变化,建议使用组件提供的WebOfficeEvents prop注册事件,或者使用上面watch监听ins变化后再注册事件
  ins?.ApiEvent.AddApiEventListener('fileOpen', (file) => {
    console.log('文件打开了', file)
  })
  ins?.ApiEvent.AddApiEventListener('fileStatus', (status) => {
    console.log('文件保存状态:', status)
  })

  // setInterval(() => {
  //   var res= ins?.save() // 手动调用save,模拟定时自动保存
  // }, 60000);

  // await ins?.ready() // 文档编辑器就绪,用于下面的高级api调用

  // const app = ins?.Application; // 获取文档应用对象

  //获取页面定制对象:更多菜单
  // const moreMenus = await app.CommandBars('MoreMenus');

  //控制更多菜单隐藏
  // moreMenus.Visible = false;
})
</script>
<style scoped>
.container {
  width: 100%;
  height: 100%;
}
.header {
  margin-bottom: 20px;
}
</style>