index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <route lang="json5" type="page">
  2. {
  3. layout: 'default',
  4. style: {
  5. navigationBarTitleText: '关于系统',
  6. },
  7. }
  8. </route>
  9. <template>
  10. <view class="about-container">
  11. <!-- 头部 Logo 区域 -->
  12. <view class="header-card">
  13. <view class="logo-container">
  14. <image class="logo" src="/static/images/logo.png" mode="aspectFit" />
  15. </view>
  16. <text class="app-name">广州特检检务通 v{{ appVersion }}</text>
  17. </view>
  18. <!-- 版本更新列表 -->
  19. <view class="version-card">
  20. <view class="card-header">
  21. <text class="card-title">版本更新</text>
  22. </view>
  23. <view v-if="loading" class="loading-container">
  24. <text class="loading-text">加载中...</text>
  25. </view>
  26. <scroll-view v-else-if="updateList.length > 0" class="version-list" scroll-y>
  27. <view
  28. v-for="(item, index) in updateList"
  29. :key="item.id || item.version"
  30. class="version-item"
  31. @click="showVersionDetail(item)"
  32. >
  33. <view class="version-item-content">
  34. <view class="version-item-left">
  35. <text class="version-number">v{{ item.versionName || item.version }}</text>
  36. <view class="version-info-row">
  37. <text class="version-info">更新时间:{{ formatDateTime(item.publishTime) }}</text>
  38. <text class="version-info">文件大小:{{ formatFileSize(item.fileSize) }}</text>
  39. </view>
  40. </view>
  41. <text class="version-arrow">></text>
  42. </view>
  43. <view v-if="index < updateList.length - 1" class="version-divider" />
  44. </view>
  45. </scroll-view>
  46. <view v-else class="empty-container">
  47. <text class="empty-text">暂无版本更新记录</text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script lang="ts" setup>
  53. import { ref, onMounted } from 'vue'
  54. import { getUpdateHistoryApi } from '@/api/version'
  55. import { formatFileSize } from '@/utils/fileServices'
  56. import { getTime } from '@/utils/index'
  57. interface UpdateInfo {
  58. id?: string
  59. version?: string
  60. versionName?: string
  61. publishTime?: string
  62. fileSize?: number | string
  63. downloadUrl?: string
  64. download_url?: string
  65. [key: string]: any
  66. }
  67. const appVersion = ref('1.0.0')
  68. const updateList = ref<UpdateInfo[]>([])
  69. const loading = ref(false)
  70. // 获取版本更新历史
  71. const fetchUpdateHistory = async () => {
  72. try {
  73. loading.value = true
  74. console.log('开始获取版本更新历史...')
  75. const response: any = await getUpdateHistoryApi()
  76. console.log('API 响应:', response)
  77. if (response?.data?.list?.length > 0) {
  78. console.log('版本历史数据:', response.data.list)
  79. updateList.value = response.data.list
  80. }
  81. } catch (error) {
  82. console.error('获取版本更新历史失败:', error)
  83. uni.showToast({
  84. title: '获取版本历史失败',
  85. icon: 'none',
  86. duration: 2000,
  87. })
  88. } finally {
  89. loading.value = false
  90. }
  91. }
  92. // 格式化日期时间
  93. const formatDateTime = (dateTime: string) => {
  94. if (!dateTime) return '未知时间'
  95. try {
  96. const date = getTime(dateTime)
  97. const year = date.getFullYear()
  98. const month = String(date.getMonth() + 1).padStart(2, '0')
  99. const day = String(date.getDate()).padStart(2, '0')
  100. const hours = String(date.getHours()).padStart(2, '0')
  101. const minutes = String(date.getMinutes()).padStart(2, '0')
  102. return `${year}-${month}-${day} ${hours}:${minutes}`
  103. } catch (error) {
  104. return dateTime
  105. }
  106. }
  107. // 显示版本详情
  108. const showVersionDetail = (item: UpdateInfo) => {
  109. try {
  110. const dataJson = encodeURIComponent(JSON.stringify(item))
  111. uni.navigateTo({
  112. url: `/pages/aboutSystem/updateDetail?data=${dataJson}`,
  113. })
  114. } catch (error) {
  115. console.error('跳转更新详情页面失败:', error)
  116. uni.showToast({
  117. title: '跳转失败',
  118. icon: 'none',
  119. duration: 2000,
  120. })
  121. }
  122. }
  123. onMounted(() => {
  124. // 获取应用版本
  125. try {
  126. const app = uni.getAppBaseInfo()
  127. appVersion.value = app.version || '1.0.0'
  128. } catch (e) {
  129. appVersion.value = '1.0.0'
  130. }
  131. fetchUpdateHistory()
  132. })
  133. </script>
  134. <style lang="scss" scoped>
  135. .about-container {
  136. display: flex;
  137. flex-direction: column;
  138. min-height: 100vh;
  139. padding: 16px;
  140. background-color: #ededed;
  141. }
  142. .header-card {
  143. display: flex;
  144. flex-direction: column;
  145. align-items: center;
  146. padding: 30px 20px;
  147. margin-bottom: 16px;
  148. background-color: #ffffff;
  149. border-radius: 4px;
  150. }
  151. .logo-container {
  152. margin-bottom: 15px;
  153. }
  154. .logo {
  155. width: 120px;
  156. height: 120px;
  157. }
  158. .app-name {
  159. font-size: 18px;
  160. font-weight: 500;
  161. color: #081f50;
  162. }
  163. .version-card {
  164. flex: 1;
  165. overflow: hidden;
  166. background-color: #fff;
  167. border: 1px solid #f0f0f0;
  168. border-radius: 8px;
  169. }
  170. .card-header {
  171. padding: 16px;
  172. border-bottom: 1px solid #f0f0f0;
  173. }
  174. .card-title {
  175. font-size: 16px;
  176. font-weight: bold;
  177. color: #333;
  178. }
  179. .version-list {
  180. height: 100%;
  181. }
  182. .version-item {
  183. background-color: #fff;
  184. }
  185. .version-item-content {
  186. display: flex;
  187. flex-direction: row;
  188. align-items: center;
  189. justify-content: space-between;
  190. padding: 16px;
  191. }
  192. .version-item-left {
  193. flex: 1;
  194. }
  195. .version-number {
  196. margin-bottom: 4px;
  197. font-size: 16px;
  198. font-weight: 500;
  199. color: #333;
  200. }
  201. .version-info-row {
  202. display: flex;
  203. flex-direction: row;
  204. gap: 8px;
  205. align-items: center;
  206. }
  207. .version-info {
  208. font-size: 14px;
  209. line-height: 20px;
  210. color: #666;
  211. }
  212. .version-arrow {
  213. font-size: 16px;
  214. font-weight: bold;
  215. color: #ccc;
  216. }
  217. .version-divider {
  218. height: 1px;
  219. margin-left: 16px;
  220. background-color: #f0f0f0;
  221. }
  222. .loading-container,
  223. .empty-container {
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. padding: 40px 0;
  228. }
  229. .loading-text,
  230. .empty-text {
  231. font-size: 14px;
  232. color: #999;
  233. }
  234. </style>