@chenghongyu/xpt-file-viewer 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/main.ts +22 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenghongyu/xpt-file-viewer",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "main": "./dist/file-viewer.umd.js",
6
6
  "module": "./dist/file-viewer.es.js",
package/src/main.ts CHANGED
@@ -1,23 +1,30 @@
1
1
  // src/main.ts
2
- import { createApp } from 'vue'
2
+ import type { App, Plugin } from 'vue'
3
3
  import ElementPlus from 'element-plus'
4
4
  import 'element-plus/dist/index.css'
5
- import { createPinia } from 'pinia'
6
- import App from './App.vue'
7
- // 导出文件预览主组件
8
- import HelloWorld from './components/HelloWorld.vue'
5
+ import { createPinia } from 'pinia' // 注意:Pinia 通常也需要 peerDependencies 或者在这里处理
6
+ import FileViewer from './components/HelloWorld.vue' // 建议重命名文件为 FileViewer.vue
9
7
 
10
- const app = createApp(App)
11
- const pinia = createPinia()
8
+ // 定义安装函数
9
+ const install = (app: App) => {
10
+ // 1. 注册 Element Plus
11
+ app.use(ElementPlus)
12
+
13
+ // 2. 注册 Pinia (如果组件内部用了 pinia,这里需要注册,但通常 pinia 应该由宿主应用提供实例)
14
+ // 注意:如果宿主应用已经安装了 pinia,再次 app.use(createPinia()) 可能会覆盖或冲突。
15
+ // 更好的做法是:不在此处 createPinia,而是假设宿主应用已提供,或者提供可选配置。
16
+ // 这里为了简单演示,先注释掉,避免冲突。如果必须用,请确保文档说明。
17
+ // const pinia = createPinia()
18
+ // app.use(pinia)
12
19
 
13
- export function install(app: any) {
14
- app.component('FileViewer', HelloWorld)
20
+ // 3. 注册你的组件
21
+ app.component('FileViewer', FileViewer)
15
22
  }
16
- // 默认导出(兼容多种引入方式)
23
+
24
+ // 默认导出插件
17
25
  export default {
18
26
  install,
19
- FileViewer: HelloWorld,
20
- }
21
- app.use(ElementPlus)
22
- app.use(pinia)
23
- // app.mount('#app')
27
+ } as Plugin
28
+
29
+ // 单独导出组件
30
+ export { FileViewer }