<template>
  <view class="container">
    <u-navbar title="日志文件"
              @rightClick="rightClick" titleStyle="color:#fff;fontSize:36rpx;"   bgColor="#2C6FF3"
              :autoBack="true" leftIconColor="#fff" :placeholder="true">
    </u-navbar>

    <view class="content">
      <view class="text">
        {{data.logs}}
      </view>
<!--      <scroll-view scroll-y class="searchMenu_body flex-wrap justify-between" :style="{height:data.fullHeight}">-->
<!--        <u&#45;&#45;textarea class="text"  style="background-color: #ff0000" v-model="data.logs" placeholder="正在加载文件..." ></u&#45;&#45;textarea>-->
<!--      </scroll-view>-->
    </view>
  </view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app';
import {getCurrentInstance, onMounted, reactive, ref} from "vue";
const { proxy } = getCurrentInstance();
const instance = getCurrentInstance();

const data = reactive({
  logs:null,
  fullHeight:'1920px',
  screenHeight:1920
})

onLoad((options)=>{
  // console.log("----------",options);
  showLog(options.file);
})

onMounted(() => {
  // console.log("----------",instance);
  data.screenHeight = uni.getSystemInfoSync().windowHeight;//-uni.upx2px(100);
});

function showLog(file){
  wx.downloadFile({
    url: file,
    success: function (res) {
      const filePath = res.tempFilePath
      data.logs = wx.getFileSystemManager().readFileSync(filePath,'utf-8');
      // setTimeout(()=>{
      //   data.logs = logs;
      // },1000);
      // wx.openDocument({
      //   filePath: filePath,
      //   success: function (res) {
      //     console.log('打开文档成功')
      //   }
      // })
    }
  })
}

</script>

<style lang="scss" scoped>
.container {
  .content {
    width: 100%;
    height: 100%;
    font-size: 28rpx;
    font-weight: 500;
    text-align: center;
    overflow-y: hidden;
    //margin-top: 135rpx;
  }
  .text{
    text-align: left;
    background: white;
    padding: 10rpx;
  }
}
</style>
