index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page -->
  2. <route lang="jsonc" type="home">
  3. {
  4. "layout": "tabbar",
  5. "style": {
  6. // 'custom' 表示开启自定义导航栏,默认 'default'
  7. "navigationStyle": "custom",
  8. "navigationBarTitleText": "首页"
  9. }
  10. }
  11. </route>
  12. <script lang="ts" setup>
  13. defineOptions({
  14. name: 'Home',
  15. })
  16. // 获取屏幕边界到安全区域距离
  17. let safeAreaInsets
  18. let systemInfo
  19. // #ifdef MP-WEIXIN
  20. // 微信小程序使用新的API
  21. systemInfo = uni.getWindowInfo()
  22. safeAreaInsets = systemInfo.safeArea
  23. ? {
  24. top: systemInfo.safeArea.top,
  25. right: systemInfo.windowWidth - systemInfo.safeArea.right,
  26. bottom: systemInfo.windowHeight - systemInfo.safeArea.bottom,
  27. left: systemInfo.safeArea.left,
  28. }
  29. : null
  30. // #endif
  31. // #ifndef MP-WEIXIN
  32. // 其他平台继续使用uni API
  33. systemInfo = uni.getSystemInfoSync()
  34. safeAreaInsets = systemInfo.safeAreaInsets
  35. // #endif
  36. const author = ref('菲鸽')
  37. const description = ref(
  38. 'unibest 是一个集成了多种工具和技术的 uniapp 开发模板,由 uniapp + Vue3 + Ts + Vite5 + UnoCss + VSCode 构建,模板具有代码提示、自动格式化、统一配置、代码片段等功能,并内置了许多常用的基本组件和基本功能,让你编写 uniapp 拥有 best 体验。',
  39. )
  40. // 测试 uni API 自动引入
  41. onLoad(() => {
  42. console.log('项目作者:', author.value)
  43. })
  44. console.log('index')
  45. </script>
  46. <template>
  47. <view class="bg-white px-4 pt-2" :style="{ marginTop: `${safeAreaInsets?.top}px` }">
  48. <view class="mt-10">
  49. <image src="/static/logo.svg" alt="" class="mx-auto block h-28 w-28" />
  50. </view>
  51. <view class="mt-4 text-center text-4xl text-[#d14328]">
  52. unibest
  53. </view>
  54. <view class="mb-8 mt-2 text-center text-2xl">
  55. 最好用的 uniapp 开发模板
  56. </view>
  57. <view class="m-auto mb-2 max-w-100 text-justify indent text-4">
  58. {{ description }}
  59. </view>
  60. <view class="mt-4 text-center">
  61. 作者:
  62. <text class="text-green-500">
  63. 菲鸽
  64. </text>
  65. </view>
  66. <view class="mt-4 text-center">
  67. 官网地址:
  68. <text class="text-green-500">
  69. https://unibest.tech
  70. </text>
  71. </view>
  72. <!-- #ifdef H5 -->
  73. <view class="mt-4 text-center">
  74. <a href="https://unibest.tech/base/3-plugin" target="_blank" class="text-green-500">
  75. 新手请看必看章节1:
  76. </a>
  77. </view>
  78. <!-- #endif -->
  79. <!-- #ifdef MP-WEIXIN -->
  80. <view class="mt-4 text-center">
  81. 新手请看必看章节1:
  82. <text class="text-green-500">
  83. https://unibest.tech/base/3-plugin
  84. </text>
  85. </view>
  86. <!-- #endif -->
  87. <!-- #ifdef H5 -->
  88. <view class="mt-4 text-center">
  89. <a href="https://unibest.tech/base/14-faq" target="_blank" class="text-green-500">
  90. 新手请看必看章节2:
  91. </a>
  92. </view>
  93. <!-- #endif -->
  94. <!-- #ifdef MP-WEIXIN -->
  95. <view class="mt-4 text-center">
  96. 新手请看必看章节2:
  97. <text class="text-green-500">
  98. https://unibest.tech/base/14-faq
  99. </text>
  100. </view>
  101. <!-- #endif -->
  102. <view class="mt-4 text-center">
  103. <wd-button type="primary">
  104. UI组件按钮
  105. </wd-button>
  106. </view>
  107. <view class="mt-4 text-center">
  108. UI组件官网:<text class="text-green-500">
  109. https://wot-design-uni.cn
  110. </text>
  111. </view>
  112. </view>
  113. </template>