refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
117
mpuniapp/pages/API/env/env.uvue
vendored
普通文件
117
mpuniapp/pages/API/env/env.uvue
vendored
普通文件
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<view style="margin:12px">
|
||||
<page-head title="环境变量 - 文件系统"></page-head>
|
||||
<page-intro content="本页演示 uni.env 文件系统路径:点击按钮查看 USER_DATA_PATH、CACHE_PATH、SANDBOX_PATH 等目录信息,可开关递归获取。"></page-intro>
|
||||
<button class="button" type="primary" @tap="getDirInfo(uni.env.USER_DATA_PATH)">USER_DATA_PATH</button>
|
||||
<button class="button" type="primary" @tap="getDirInfo(data.cachePath)">CACHE_PATH</button>
|
||||
<button class="button" type="primary" @tap="getDirInfo(data.sandboxPath)">SANDBOX_PATH</button>
|
||||
<!-- #ifdef APP-HARMONY -->
|
||||
<button class="button" type="primary" @tap="getDirInfo(data.tempPath)">TEMP_PATH</button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP-ANDROID -->
|
||||
<button class="button" type="primary" @tap="getDirInfo(data.androidInternalSandboxPath)">ANDROID_INTERNAL_SANDBOX_PATH</button>
|
||||
<!-- #endif -->
|
||||
<boolean-data :defaultValue="false" title="是否递归获取" @change="switchRecursive"></boolean-data>
|
||||
</view>
|
||||
<scroll-view style="flex: 1; padding: 16px 0px;">
|
||||
<text class="result">{{data.result}}</text>
|
||||
<text class="error">{{data.error}}</text>
|
||||
<view class="stat" v-for="(stat,index) in data.list" :key="index" >
|
||||
<text class="path">{{stat.path}}</text>
|
||||
<text class="size">{{stat.size}}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
type StatInfo = {
|
||||
path : string;
|
||||
size : string;
|
||||
};
|
||||
|
||||
type DataType = {
|
||||
result: string;
|
||||
error: string;
|
||||
list: Array<StatInfo>;
|
||||
recursive: boolean;
|
||||
cachePath: string;
|
||||
sandboxPath: string;
|
||||
// #ifdef APP-HARMONY
|
||||
tempPath: string;
|
||||
// #endif
|
||||
// #ifdef APP-ANDROID
|
||||
androidInternalSandboxPath: string;
|
||||
// #endif
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
result: '',
|
||||
error: '',
|
||||
list: [],
|
||||
recursive: false,
|
||||
cachePath: uni.env.CACHE_PATH,
|
||||
sandboxPath: uni.env.SANDBOX_PATH,
|
||||
// #ifdef APP-HARMONY
|
||||
tempPath: uni.env.TEMP_PATH,
|
||||
// #endif
|
||||
// #ifdef APP-ANDROID
|
||||
androidInternalSandboxPath: uni.env.ANDROID_INTERNAL_SANDBOX_PATH,
|
||||
// #endif
|
||||
} as DataType)
|
||||
|
||||
const switchRecursive = () => {
|
||||
data.recursive = !data.recursive
|
||||
}
|
||||
|
||||
const getDirInfo = (dirPath: string) => {
|
||||
const fm = uni.getFileSystemManager()
|
||||
data.list = [];
|
||||
fm.stat({
|
||||
path: dirPath,
|
||||
recursive: data.recursive,
|
||||
success: (res: StatSuccessResult) => {
|
||||
data.result = `获取 "${dirPath}" 成功(success)`
|
||||
console.log(data.result)
|
||||
res.stats.forEach((item)=>{
|
||||
data.list.push({
|
||||
path: item.path,
|
||||
size: `${item.stats.size} Bytes`
|
||||
} as StatInfo)
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
data.result = `获取 "${dirPath}" 失败(fail)`
|
||||
console.log(data.result)
|
||||
data.error = JSON.stringify(err)
|
||||
console.log(data.error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.button {
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.result {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.error {
|
||||
color: firebrick;
|
||||
}
|
||||
.stat {
|
||||
padding: 8px 16px;
|
||||
}
|
||||
.path {
|
||||
color: darkgray;
|
||||
}
|
||||
.size {
|
||||
color: darkgrey;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户