index.vue 3.8 KB

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