FluStatusView.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import FluentUI
  5. Item{
  6. enum StatusMode {
  7. Loading,
  8. Empty,
  9. Error,
  10. Success
  11. }
  12. default property alias content: container.data
  13. property int statusMode: FluStatusView.Loading
  14. signal errorClicked
  15. Item{
  16. id:container
  17. anchors.fill: parent
  18. visible: statusMode === FluStatusView.Success
  19. }
  20. FluArea{
  21. paddings: 0
  22. border.width: 0
  23. anchors.fill: container
  24. visible: opacity
  25. opacity: statusMode === FluStatusView.Loading
  26. Behavior on opacity {
  27. NumberAnimation { duration: 83 }
  28. }
  29. ColumnLayout{
  30. anchors.centerIn: parent
  31. visible: statusMode === FluStatusView.Loading
  32. FluProgressRing{
  33. indeterminate: true
  34. Layout.alignment: Qt.AlignHCenter
  35. }
  36. FluText{
  37. text:"正在加载..."
  38. Layout.alignment: Qt.AlignHCenter
  39. }
  40. }
  41. }
  42. FluArea{
  43. paddings: 0
  44. border.width: 0
  45. anchors.fill: container
  46. visible: opacity
  47. opacity: statusMode === FluStatusView.Empty
  48. Behavior on opacity {
  49. NumberAnimation { duration: 83 }
  50. }
  51. ColumnLayout{
  52. anchors.centerIn: parent
  53. visible: statusMode === FluStatusView.Empty
  54. FluText{
  55. text:"空空如也"
  56. fontStyle: FluText.BodyStrong
  57. Layout.alignment: Qt.AlignHCenter
  58. }
  59. }
  60. }
  61. FluArea{
  62. paddings: 0
  63. border.width: 0
  64. anchors.fill: container
  65. visible: opacity
  66. opacity: statusMode === FluStatusView.Error
  67. Behavior on opacity {
  68. NumberAnimation { duration: 83 }
  69. }
  70. ColumnLayout{
  71. anchors.centerIn: parent
  72. FluText{
  73. text:"页面出错了..."
  74. fontStyle: FluText.BodyStrong
  75. Layout.alignment: Qt.AlignHCenter
  76. }
  77. FluFilledButton{
  78. id:btn_error
  79. Layout.alignment: Qt.AlignHCenter
  80. text:"重新加载"
  81. onClicked:{
  82. errorClicked.call()
  83. }
  84. }
  85. }
  86. }
  87. function showSuccessView(){
  88. statusMode = FluStatusView.Success
  89. }
  90. function showLoadingView(){
  91. statusMode = FluStatusView.Loading
  92. }
  93. function showEmptyView(){
  94. statusMode = FluStatusView.Empty
  95. }
  96. function showErrorView(){
  97. statusMode = FluStatusView.Error
  98. }
  99. }