<template>
  <!-- #ifdef APP -->
  <text>操作日志</text><button size="mini" @click="log=''">清空日志</button>
  <text style="margin: 2px; padding: 2px; border: 1px solid #000000;">{{ log }}</text>
  <scroll-view style="flex: 1;">
  <!-- #endif -->
    <!-- #ifdef APP -->
    <button class="btnstyle" type="primary" @tap="geAbsPath(sandboxPath)"
      id="btn-path">应用外置沙盒目录uni.env.SANDBOX_PATH</button>
    <button class="btnstyle" type="primary" @tap="geAbsPath(cachePath)" id="btn-path">缓存文件目录uni.env.CACHE_PATH</button>
    <button class="btnstyle" type="primary" @tap="geAbsPath(userPath)"
      id="btn-path">用户文件目录uni.env.USER_DATA_PATH</button>
    <!-- #ifdef APP-HARMONY -->
    <button class="btnstyle" type="primary" @tap="geAbsPath(tempPath)"
      id="btn-path">用户临时目录uni.env.TEMP_PATH</button>
    <!-- #endif -->
    <!-- #ifdef APP-ANDROID -->
    <button class="btnstyle" type="primary" @tap="geAbsPath(internalSandboxPath)"
      id="btn-path">应用内置沙盒目录uni.env.ANDROID_INTERNAL_SANDBOX_PATH</button>
    <!-- #endif -->
    <!-- #endif -->
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>

<script>
  // #ifdef APP-HARMONY
  import { convert2AbsFullPath } from '@/uni_modules/uts-get-native-view'
  // #endif
  export default {
    data() {
      return {
        log: "",
        userPath: uni.env.USER_DATA_PATH,
        sandboxPath: uni.env.SANDBOX_PATH,
        cachePath: uni.env.CACHE_PATH,
        // #ifdef APP-HARMONY
        tempPath: uni.env.TEMP_PATH,
        // #endif
        internalSandboxPath: uni.env.ANDROID_INTERNAL_SANDBOX_PATH,
      }
    },
    methods: {
      geAbsPath(path ?: any) {
        // #ifdef APP-ANDROID
        this.log += UTSAndroid.convert2AbsFullPath(path as string) + '\n'
        // #endif
        // #ifdef APP-HARMONY
        this.log += convert2AbsFullPath(path as string) + '\n'
        // #endif
      }
    }
  }
</script>

<style>
  .btnstyle {
    margin: 4px;
  }
</style>
