officialblock 1.1.4 → 1.1.7

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.
package/README.md CHANGED
@@ -96,6 +96,43 @@ app.use(ArticleListPlugin) // 只注册 ArticleList 组件
96
96
  app.use(HeroSlidePlugin) // 只注册 HeroSlide 组件
97
97
  ```
98
98
 
99
+ ### 全局属性
100
+
101
+ 当你使用 `app.use(OfficialBlock)` 安装插件时,会自动注册以下全局属性:
102
+
103
+ #### $device - 设备检测
104
+
105
+ 在组件中可以直接使用 `$device` 来检测当前设备类型:
106
+
107
+ ```vue
108
+ <template>
109
+ <div>
110
+ <div v-if="$device.isMobile">移动端内容</div>
111
+ <div v-else-if="$device.isTablet">平板内容</div>
112
+ <div v-else>桌面端内容</div>
113
+ </div>
114
+ </template>
115
+
116
+ <script setup>
117
+ import { getCurrentInstance } from 'vue'
118
+
119
+ // 在 setup 中使用
120
+ const instance = getCurrentInstance()
121
+ const device = instance?.proxy?.$device
122
+
123
+ console.log('是否为移动设备:', device?.isMobile)
124
+ console.log('是否为平板:', device?.isTablet)
125
+ console.log('是否为移动设备或平板:', device?.isMobileOrTablet)
126
+ console.log('是否为桌面:', device?.isDesktop)
127
+ </script>
128
+ ```
129
+
130
+ **属性说明:**
131
+ - `$device.isMobile`: 是否为移动设备 (宽度 < 768px)
132
+ - `$device.isTablet`: 是否为平板设备 (768px ≤ 宽度 < 1024px)
133
+ - `$device.isMobileOrTablet`: 是否为移动设备或平板 (宽度 < 1024px)
134
+ - `$device.isDesktop`: 是否为桌面设备 (宽度 ≥ 1024px)
135
+
99
136
  ### TypeScript Support
100
137
 
101
138
  This package includes TypeScript definitions.
@@ -122,6 +159,9 @@ const heroProps: HeroSlideProps = {
122
159
  showIndicators: true,
123
160
  autoPlay: true
124
161
  }
162
+
163
+ // $device 全局属性已自动包含类型定义
164
+ // 在 TypeScript 中可以直接使用,无需额外导入
125
165
  ```
126
166
 
127
167
  ## Components