plugin-unavailable.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view v-if="pluginInfo" class="plugin-unavailable flex flex-col flex-center"
  3. :class="{border:useBorder,'decoration':useDecoration}" :style="[calcCustomStyle]">
  4. <!-- 图标 -->
  5. <image class="plugin-logo" :src="pluginInfo.logo" mode="scaleToFill"></image>
  6. <!-- 名称 -->
  7. <view class="plugin-name">
  8. {{ pluginInfo.name }}
  9. </view>
  10. <view class="plugin-error">
  11. 未安装/启用插件
  12. </view>
  13. <!-- 描述 -->
  14. <view class="plugin-desc">
  15. {{ pluginInfo.desc }}
  16. </view>
  17. <view v-if="errorText" class="plugin-tip">
  18. {{errorText}}
  19. </view>
  20. <!-- 插件地址 -->
  21. <view class="plugin-url">
  22. 插件地址:{{ pluginInfo.url }}
  23. </view>
  24. <!-- 反馈按钮/复制地址 -->
  25. <view class="plugin-btns w-full flex-center">
  26. <!-- #ifndef MP-WEIXIN -->
  27. <tm-button theme="light-blue" :block="true" class="w-full" :height="70" @click="copy">复制地址</tm-button>
  28. <!-- #endif -->
  29. <!-- #ifdef MP-WEIXIN -->
  30. <tm-button theme="light-blue" plan text :height="70" @click="copy">复制地址</tm-button>
  31. <tm-button theme="light-blue" open-type="contact" :height="70">提交反馈</tm-button>
  32. <!-- #endif -->
  33. </view>
  34. <view class="plugin-copyright">
  35. 提示:请确保 Halo 博客已安装相关插件
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. NeedPluginIds,
  42. NeedPlugins,
  43. CheckNeedPluginAvailable
  44. } from "@/utils/plugin.js"
  45. import utils from '@/utils/index.js'
  46. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  47. export default {
  48. name: "plugin-unavailable",
  49. components: {
  50. tmButton
  51. },
  52. props: {
  53. pluginId: {
  54. type: String,
  55. default: ""
  56. },
  57. errorText: {
  58. type: String,
  59. default: ""
  60. },
  61. useDecoration: {
  62. type: Boolean,
  63. default: true
  64. },
  65. useBorder: {
  66. type: Boolean,
  67. default: true
  68. },
  69. customStyle: {
  70. type: Object,
  71. default: () => ({})
  72. }
  73. },
  74. data() {
  75. return {
  76. NeedPluginIds,
  77. NeedPlugins,
  78. pluginInfo: null,
  79. defaultStyle: {
  80. width: "80vw",
  81. borderRadius: "24rpx"
  82. }
  83. };
  84. },
  85. computed: {
  86. calcCustomStyle() {
  87. const style = this.customStyle ?? {}
  88. return {
  89. ...this.defaultStyle,
  90. ...style
  91. }
  92. }
  93. },
  94. watch: {
  95. pluginId: {
  96. deep: true,
  97. immediate: true,
  98. handler(newVal, oldVal) {
  99. this.pluginInfo = NeedPlugins.get(newVal)
  100. }
  101. }
  102. },
  103. methods: {
  104. copy() {
  105. utils.copyText(this.pluginInfo.url, "插件地址已复制")
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .plugin-unavailable {
  112. box-sizing: border-box;
  113. margin: auto;
  114. padding: 100rpx 36rpx;
  115. gap: 24rpx;
  116. font-size: 28rpx;
  117. &.border {
  118. // border: 2rpx solid #E2E8F0;
  119. border: 2rpx solid #eee;
  120. }
  121. &.decoration {
  122. background-color: rgba(255, 255, 255, 0.95);
  123. box-shadow: 0 0 12rpx rgba(226, 232, 240, 0.35);
  124. backdrop-filter: blur(6rpx);
  125. border-top: 12rpx solid rgba(3, 169, 244, 1);
  126. }
  127. }
  128. .plugin-logo {
  129. box-sizing: border-box;
  130. width: 120rpx;
  131. height: 120rpx;
  132. border-radius: 24rpx;
  133. }
  134. .plugin-name {
  135. box-sizing: border-box;
  136. font-weight: bold;
  137. color: #333;
  138. font-size: 32rpx;
  139. }
  140. .plugin-error {
  141. box-sizing: border-box;
  142. padding: 6rpx 16rpx;
  143. border-radius: 36rpx;
  144. background-color: rgba(255, 61, 49, 0.075);
  145. color: rgba(255, 61, 49, 1);
  146. font-size: 24rpx;
  147. font-weight: bold;
  148. }
  149. .plugin-tip {
  150. box-sizing: border-box;
  151. padding: 10rpx 20rpx;
  152. border-radius: 12rpx;
  153. border: 2rpx dashed #f2c97d;
  154. color: #f0a020;
  155. font-size: 24rpx;
  156. }
  157. .plugin-desc {
  158. box-sizing: border-box;
  159. width: 60vw;
  160. font-size: 24rpx;
  161. text-align: center;
  162. color: #64748b;
  163. }
  164. .plugin-url {
  165. width: 100%;
  166. box-sizing: border-box;
  167. padding: 16rpx 24rpx;
  168. border-radius: 12rpx;
  169. background-color: #F1F5F9;
  170. color: #666;
  171. font-size: 24rpx;
  172. white-space: nowrap;
  173. overflow: hidden;
  174. text-overflow: ellipsis;
  175. }
  176. .plugin-btns {
  177. box-sizing: border-box;
  178. }
  179. .plugin-copyright {
  180. font-size: 20rpx;
  181. color: #999;
  182. transform: scale(0.9) translateY(20px);
  183. }
  184. </style>