20260809223428
This commit is contained in:
1 parent
d72ca4193d
commit
c4891538a7
466 files changed
+21000
-3339
No files matched your search
@@ -1,284 +1,8 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { Upload, Cloud, HardDrive } from "@lucide/vue";
|
||||
import { initFileConfig, upload } from "@/services/fileService";
|
||||
import { post } from "@/services/http";
|
||||
import FmsFileModal from "@/components/fms-file/FmsFileModal.vue";
|
||||
|
||||
const storageType = ref(null);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
storageType.value = await initFileConfig();
|
||||
} catch {
|
||||
storageType.value = "unknown";
|
||||
}
|
||||
});
|
||||
|
||||
/* ───── 本地上传 ───── */
|
||||
const localFiles = ref([]);
|
||||
const localUploading = ref(false);
|
||||
const localResult = ref(null);
|
||||
|
||||
function onLocalFileChange(e) {
|
||||
localFiles.value = Array.from(e.target.files || []);
|
||||
localResult.value = null;
|
||||
}
|
||||
|
||||
async function testLocalUpload() {
|
||||
if (!localFiles.value.length) return;
|
||||
localUploading.value = true;
|
||||
localResult.value = null;
|
||||
try {
|
||||
const list = await upload({
|
||||
files: localFiles.value,
|
||||
father: "demo",
|
||||
moduleId: "1",
|
||||
});
|
||||
localResult.value = { ok: true, data: list, count: list.length };
|
||||
} catch (e) {
|
||||
localResult.value = { ok: false, error: e.message || String(e) };
|
||||
} finally {
|
||||
localUploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ───── OSS 凭证 ───── */
|
||||
const ossLoading = ref(false);
|
||||
const ossResult = ref(null);
|
||||
|
||||
async function testOssCredential() {
|
||||
ossLoading.value = true;
|
||||
ossResult.value = null;
|
||||
try {
|
||||
const res = await post("/file/upload-credential");
|
||||
ossResult.value = { ok: true, data: res.data };
|
||||
} catch (e) {
|
||||
ossResult.value = { ok: false, error: e.message || String(e) };
|
||||
} finally {
|
||||
ossLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function fmtJson(obj) {
|
||||
return JSON.stringify(obj, null, 2);
|
||||
}
|
||||
|
||||
/* ───── 附件管理 (Modal) ───── */
|
||||
const demoOpen = ref(false);
|
||||
const demoModuleCode = ref("b_port");
|
||||
const demoFather = ref("demo_doc_001");
|
||||
|
||||
function openFmsFileDemo() {
|
||||
demoOpen.value = true;
|
||||
}
|
||||
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="dh">
|
||||
<!-- 原有:文件接口测试 -->
|
||||
<header class="dh-head">
|
||||
<h1>文件接口测试</h1>
|
||||
<a-tag :color="storageType === 'local' ? 'green' : storageType === 'aliyun-oss' ? 'orange' : 'default'">
|
||||
<template #icon><HardDrive :size="12" /></template>
|
||||
{{ storageType || '加载中...' }}
|
||||
</a-tag>
|
||||
</header>
|
||||
|
||||
<div class="dh-cards">
|
||||
<!-- 本地上传 -->
|
||||
<div class="dh-card">
|
||||
<div class="dh-card__title">
|
||||
<Upload :size="14" />
|
||||
本地上传 <code>POST /file/upload</code>
|
||||
</div>
|
||||
<div class="dh-card__body">
|
||||
<input type="file" class="dh-file" multiple @change="onLocalFileChange" />
|
||||
<div v-if="localFiles.length" class="dh-filelist">
|
||||
<span v-for="f in localFiles" :key="f.name" class="dh-filelist__item">{{ f.name }}</span>
|
||||
</div>
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="localUploading"
|
||||
:disabled="!localFiles.length"
|
||||
@click="testLocalUpload"
|
||||
>
|
||||
上传 {{ localFiles.length ? `(${localFiles.length} 个文件)` : '' }}
|
||||
</a-button>
|
||||
<div v-if="localResult" class="dh-result" :class="localResult.ok ? 'dh-result--ok' : 'dh-result--err'">
|
||||
<pre>{{ localResult.ok ? fmtJson(localResult.data) : localResult.error }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- OSS 凭证 -->
|
||||
<div class="dh-card">
|
||||
<div class="dh-card__title">
|
||||
<Cloud :size="14" />
|
||||
OSS 凭证 <code>POST /file/upload-credential</code>
|
||||
</div>
|
||||
<div class="dh-card__body">
|
||||
<a-button
|
||||
size="small"
|
||||
:loading="ossLoading"
|
||||
@click="testOssCredential"
|
||||
>
|
||||
获取凭证
|
||||
</a-button>
|
||||
<div v-if="ossResult" class="dh-result" :class="ossResult.ok ? 'dh-result--ok' : 'dh-result--err'">
|
||||
<pre>{{ ossResult.ok ? fmtJson(ossResult.data) : ossResult.error }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 附件管理演示入口 -->
|
||||
<div class="dh-demo-entry">
|
||||
<a-button type="primary" size="large" @click="openFmsFileDemo">
|
||||
附件管理
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<!-- FmsFileModal 声明式调用 -->
|
||||
<FmsFileModal
|
||||
v-model:open="demoOpen"
|
||||
:module-code="demoModuleCode"
|
||||
:father="demoFather"
|
||||
/>
|
||||
</main>
|
||||
<div class="flex h-full items-center justify-center">
|
||||
<h1 class="text-2xl font-bold text-muted-foreground">Dashboard</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.dh {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 24px 16px;
|
||||
color: #1f2329;
|
||||
}
|
||||
|
||||
.dh-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.dh-cards {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.dh-card {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
|
||||
&__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
background: #fafafa;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
|
||||
svg { color: #1677ff; flex: none; }
|
||||
|
||||
code {
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
color: #1677ff;
|
||||
background: #e6f4ff;
|
||||
padding: 1px 6px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.dh-file {
|
||||
font-size: 13px;
|
||||
color: #646a73;
|
||||
|
||||
&::file-selector-button {
|
||||
font-size: 12px;
|
||||
padding: 3px 12px;
|
||||
margin-right: 10px;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
background: #fafafa;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.dh-filelist {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
|
||||
&__item {
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
background: #f0f2f5;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 3px;
|
||||
color: #646a73;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.dh-result {
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
padding: 10px 12px;
|
||||
border-radius: 4px;
|
||||
max-height: 220px;
|
||||
overflow: auto;
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
font-family: "SF Mono", Consolas, monospace;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
&--ok {
|
||||
background: #f6ffed;
|
||||
border: 1px solid #b7eb8f;
|
||||
color: #389e0d;
|
||||
}
|
||||
|
||||
&--err {
|
||||
background: #fff1f0;
|
||||
border: 1px solid #ffa39e;
|
||||
color: #cf1322;
|
||||
}
|
||||
}
|
||||
|
||||
/* ───── 附件管理演示入口 ───── */
|
||||
.dh-demo-entry {
|
||||
margin-top: 28px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user