fix:图片访问
fix:权限修改
This commit is contained in:
1 parent
dec9fd96e3
commit
d86bc810cc
69 files changed
+1264
-458
No files matched your search
+4
-1
@@ -52,4 +52,7 @@ coverage/
|
||||
.video_agent/
|
||||
.mimosa/
|
||||
.zcode/
|
||||
.zcodeignore
|
||||
.zcodeignore
|
||||
|
||||
# Local file-access credentials
|
||||
.env.*.local
|
||||
@@ -1,4 +1,7 @@
|
||||
import request from "/@/utils/request"
|
||||
import { submitExportTask } from "/@/api/asyncTask"
|
||||
|
||||
export const submitDeptExport = (query: Record<string, unknown>) => submitExportTask("/admin/dept/export-async", query)
|
||||
|
||||
export const deptTree = (params?: Object) => {
|
||||
return request({
|
||||
|
||||
+53
-53
@@ -1,138 +1,138 @@
|
||||
import request from '/@/utils/request';
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export const getDicts = (type: String) => {
|
||||
return request({
|
||||
url: `/admin/dict/type/${type}`,
|
||||
method: 'get',
|
||||
});
|
||||
};
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchList(query: any) {
|
||||
return request({
|
||||
url: '/admin/dict/list',
|
||||
method: 'get',
|
||||
url: "/admin/dict/list",
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchItemList(query: any) {
|
||||
return request({
|
||||
url: '/admin/dict/item/page',
|
||||
method: 'get',
|
||||
url: "/admin/dict/item/page",
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function addItemObj(obj: any) {
|
||||
return request({
|
||||
url: '/admin/dict/item',
|
||||
method: 'post',
|
||||
url: "/admin/dict/item",
|
||||
method: "post",
|
||||
data: obj,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function getItemObj(id: string) {
|
||||
return request({
|
||||
url: '/admin/dict/item/details/' + id,
|
||||
method: 'get',
|
||||
});
|
||||
url: "/admin/dict/item/details/" + id,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
export function getItemDetails(obj: object) {
|
||||
return request({
|
||||
url: '/admin/dict/item/details',
|
||||
method: 'get',
|
||||
url: "/admin/dict/item/details",
|
||||
method: "get",
|
||||
params: obj,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function delItemObj(id: string) {
|
||||
return request({
|
||||
url: '/admin/dict/item/' + id,
|
||||
method: 'delete',
|
||||
});
|
||||
url: "/admin/dict/item/" + id,
|
||||
method: "delete",
|
||||
})
|
||||
}
|
||||
|
||||
export function putItemObj(obj: any) {
|
||||
return request({
|
||||
url: '/admin/dict/item',
|
||||
method: 'put',
|
||||
url: "/admin/dict/item",
|
||||
method: "put",
|
||||
data: obj,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj: any) {
|
||||
return request({
|
||||
url: '/admin/dict',
|
||||
method: 'post',
|
||||
url: "/admin/dict",
|
||||
method: "post",
|
||||
data: obj,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id: string) {
|
||||
return request({
|
||||
url: '/admin/dict/details/' + id,
|
||||
method: 'get',
|
||||
});
|
||||
url: "/admin/dict/details/" + id,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
export function getObjDetails(obj: object) {
|
||||
return request({
|
||||
url: '/admin/dict/details',
|
||||
method: 'get',
|
||||
url: "/admin/dict/details",
|
||||
method: "get",
|
||||
params: obj,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function delObj(ids: Object) {
|
||||
return request({
|
||||
url: '/admin/dict',
|
||||
method: 'delete',
|
||||
url: "/admin/dict",
|
||||
method: "delete",
|
||||
data: ids,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj: any) {
|
||||
return request({
|
||||
url: '/admin/dict',
|
||||
method: 'put',
|
||||
url: "/admin/dict",
|
||||
method: "put",
|
||||
data: obj,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function refreshCache() {
|
||||
return request({
|
||||
url: '/admin/dict/sync',
|
||||
method: 'put',
|
||||
});
|
||||
url: "/admin/dict/sync",
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
||||
export function validateDictType(rule: any, value: any, callback: any, isEdit: boolean) {
|
||||
if (isEdit) {
|
||||
return callback();
|
||||
return callback()
|
||||
}
|
||||
|
||||
getObjDetails({ dictType: value }).then((response) => {
|
||||
const result = response.data;
|
||||
const result = response.data
|
||||
if (result !== null) {
|
||||
callback(new Error('字典已经存在'));
|
||||
callback(new Error("字典已经存在"))
|
||||
} else {
|
||||
callback();
|
||||
callback()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function validateDictItemLabel(rule: any, value: any, callback: any, type: string, isEdit: boolean) {
|
||||
if (isEdit) {
|
||||
return callback();
|
||||
return callback()
|
||||
}
|
||||
|
||||
getItemDetails({ dictType: type, label: value }).then((response) => {
|
||||
const result = response.data;
|
||||
const result = response.data
|
||||
if (result !== null) {
|
||||
callback(new Error('标签已经存在'));
|
||||
callback(new Error("标签已经存在"))
|
||||
} else {
|
||||
callback();
|
||||
callback()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
import request from '/@/utils/request';
|
||||
import { submitExportTask } from '/@/api/asyncTask';
|
||||
|
||||
export const submitLogExport = (query: Record<string, unknown>) => submitExportTask('/admin/log/export-async', query);
|
||||
|
||||
export const pageList = (params?: Object) => {
|
||||
return request({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="flex flex-col border border-br" :style="styles">
|
||||
<div ref="editorContainer" class="flex flex-col border border-br" :style="styles">
|
||||
<Toolbar class="border-b border-br" :editor="editorRef" :mode="mode" />
|
||||
<Editor
|
||||
class="flex-1 overflow-y-auto"
|
||||
@@ -18,6 +18,8 @@ import { reactive, shallowRef, watch, onBeforeUnmount, CSSProperties } from 'vue
|
||||
// @ts-ignore
|
||||
import { IDomEditor } from '@wangeditor/editor';
|
||||
import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
|
||||
import { stripFileHtml, resolveFileUrl } from '/@/utils/file-access';
|
||||
import { bindFileAccessDom } from '/@/utils/file-access-dom';
|
||||
import { Session } from '/@/utils/storage';
|
||||
import other from '/@/utils/other';
|
||||
const { proxy } = getCurrentInstance();
|
||||
@@ -77,11 +79,13 @@ const uploadAttr = reactive({
|
||||
server: proxy.baseURL + props.uploadFileUrl,
|
||||
headers: headers,
|
||||
customInsert(res, insertFn) {
|
||||
insertFn(proxy.baseURL + res.data.url);
|
||||
insertFn(resolveFileUrl(res.data.url));
|
||||
},
|
||||
});
|
||||
|
||||
const editorRef = shallowRef();
|
||||
const editorContainer = shallowRef<HTMLElement>();
|
||||
let stopResourceRenewal: (() => void) | undefined;
|
||||
const state = reactive({
|
||||
editorConfig: {
|
||||
placeholder: props.placeholder,
|
||||
@@ -90,7 +94,7 @@ const state = reactive({
|
||||
uploadVideo: uploadAttr,
|
||||
},
|
||||
},
|
||||
editorVal: props.getHtml,
|
||||
editorVal: stripFileHtml(props.getHtml || ""),
|
||||
});
|
||||
|
||||
const styles = computed<CSSProperties>(() => ({
|
||||
@@ -102,16 +106,21 @@ const styles = computed<CSSProperties>(() => ({
|
||||
// 编辑器回调函数
|
||||
const handleCreated = (editor: IDomEditor) => {
|
||||
editorRef.value = editor;
|
||||
nextTick(() => {
|
||||
stopResourceRenewal?.();
|
||||
if (editorContainer.value) stopResourceRenewal = bindFileAccessDom(editorContainer.value);
|
||||
});
|
||||
};
|
||||
|
||||
// 编辑器内容改变时
|
||||
const handleChange = (editor: IDomEditor) => {
|
||||
emit('update:getHtml', editor.getHtml());
|
||||
emit('update:getHtml', stripFileHtml(editor.getHtml()));
|
||||
emit('update:getText', editor.getText());
|
||||
};
|
||||
|
||||
// 页面销毁时
|
||||
onBeforeUnmount(() => {
|
||||
stopResourceRenewal?.();
|
||||
const editor = editorRef.value;
|
||||
if (editor == null) return;
|
||||
emit('update:getHtml', '');
|
||||
@@ -132,7 +141,7 @@ onMounted(() =>{
|
||||
watch(
|
||||
() => props.getHtml,
|
||||
(val) => {
|
||||
state.editorVal = val;
|
||||
if (stripFileHtml(state.editorVal || "") !== stripFileHtml(val || "")) state.editorVal = stripFileHtml(val || "");
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<script setup lang="ts">
|
||||
import { shallowRef, watch } from 'vue'
|
||||
import { ElImage } from 'element-plus'
|
||||
import { accessFileUrl, fileUrls, originalFileUrl, resolveFileUrl, fileAccessRevision, retryFileAccess } from '/@/utils/file-access'
|
||||
|
||||
defineOptions({ inheritAttrs: false })
|
||||
const props = withDefaults(defineProps<{ src?: string; previewSrcList?: string[] }>(), {
|
||||
src: '', previewSrcList: () => [],
|
||||
})
|
||||
const emit = defineEmits<{
|
||||
load: [event: Event]
|
||||
error: [event: Event]
|
||||
show: []
|
||||
switch: [index: number]
|
||||
close: []
|
||||
}>()
|
||||
const displaySrc = shallowRef('')
|
||||
const previewSources = shallowRef<string[]>([])
|
||||
let generation = 0
|
||||
let loaded = false
|
||||
let failed = false
|
||||
let pending = false
|
||||
let lastError: Event
|
||||
|
||||
const identity = (source: string) => resolveFileUrl(originalFileUrl(source))
|
||||
const refreshPreview = () => { previewSources.value = fileUrls(props.previewSrcList) }
|
||||
|
||||
// An already decoded image remains visible after its request signature expires.
|
||||
// Only a changed business reference or a failed request needs a new thumbnail request.
|
||||
watch(() => identity(props.src), () => {
|
||||
generation++
|
||||
loaded = failed = pending = false
|
||||
displaySrc.value = accessFileUrl(props.src)
|
||||
}, { immediate: true })
|
||||
watch(() => JSON.stringify(props.previewSrcList.map(identity)), refreshPreview, { immediate: true })
|
||||
|
||||
function onLoad(event: Event) { loaded = true; failed = false; emit('load', event) }
|
||||
async function onError(event: Event) {
|
||||
failed = true
|
||||
lastError = event
|
||||
if (pending) return
|
||||
const current = generation
|
||||
pending = true
|
||||
try {
|
||||
const retried = await retryFileAccess(props.src)
|
||||
if (current !== generation) return
|
||||
if (retried) {
|
||||
failed = false
|
||||
displaySrc.value = accessFileUrl(props.src)
|
||||
} else emit('error', event)
|
||||
} finally { if (current === generation) pending = false }
|
||||
}
|
||||
watch(fileAccessRevision, () => {
|
||||
if (loaded || pending) return
|
||||
const renewed = accessFileUrl(props.src)
|
||||
if (renewed !== displaySrc.value) {
|
||||
failed = false
|
||||
displaySrc.value = renewed
|
||||
} else if (failed) void onError(lastError)
|
||||
})
|
||||
function onShow() { refreshPreview(); emit('show') }
|
||||
function onSwitch(index: number) { refreshPreview(); emit('switch', index) }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElImage v-bind="$attrs" :src="displaySrc" :preview-src-list="previewSources"
|
||||
@load="onLoad" @error="onError" @show="onShow" @switch="onSwitch" @close="emit('close')">
|
||||
<template v-for="(_, name) in $slots" #[name]="scope">
|
||||
<slot :name="name" v-bind="scope || {}" />
|
||||
</template>
|
||||
</ElImage>
|
||||
</template>
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="relative flex items-center justify-center file-item" :style="{ height: fileSize, width: fileSize }">
|
||||
<el-image class="image" v-if="type === 'image'" fit="contain" :src="uri"></el-image>
|
||||
<video class="video" v-else-if="type === 'video'" :src="uri"></video>
|
||||
<file-image class="image" v-if="type === 'image'" fit="contain" :src="$fileUrl(uri)" @error="$fileRetry(uri)"></file-image>
|
||||
<video class="video" v-else-if="type === 'video'" :src="$fileUrl(uri)"></video>
|
||||
<div
|
||||
v-if="type == 'video'"
|
||||
class="absolute left-1/2 top-1/2 translate-x-[-50%] translate-y-[-50%] rounded-full w-5 h-5 flex justify-center items-center bg-[rgba(0,0,0,0.3)]"
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
|
||||
<div v-if="type === 'file'" class="flex items-center justify-center">
|
||||
<img class="w-16" :src="getFileImage(uri)" />
|
||||
<img class="w-16" :src="$fileUrl(getFileImage(uri))" @error="$fileRetry(getFileImage(uri))" />
|
||||
</div>
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="名称" min-width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link @click.stop="handlePreview(getFileUri(row))" :underline="false">
|
||||
<el-link @click.stop="handlePreview(row)" :underline="false">
|
||||
{{ row.original }}
|
||||
</el-link>
|
||||
</template>
|
||||
@@ -165,7 +165,7 @@
|
||||
</popover-input>
|
||||
</div>
|
||||
<div class="inline-block">
|
||||
<el-button type="primary" link @click.stop="handlePreview(getFileUri(row))"> 查看</el-button>
|
||||
<el-button type="primary" link @click.stop="handlePreview(row)"> 查看</el-button>
|
||||
</div>
|
||||
<div class="inline-block">
|
||||
<el-button type="primary" link @click.stop="batchFileDelete([row.id])"> 删除</el-button>
|
||||
@@ -330,7 +330,7 @@ const handlePreview = (item: { fileName: string }) => {
|
||||
* @param {any} item - 文件项对象
|
||||
*/
|
||||
const handleDownFile = (item: any) => {
|
||||
other.downBlobFile(`/admin/sys-file/oss/file?fileName=${item.fileName}`, {}, item.original);
|
||||
other.downBlobFile(`/admin/sys-file/oss/file?fileName=${encodeURIComponent(item.fileName)}`, {}, item.original);
|
||||
};
|
||||
|
||||
watch(
|
||||
@@ -371,7 +371,7 @@ watch(
|
||||
);
|
||||
|
||||
const getFileUri = (item: any) => {
|
||||
return `${proxy.baseURL}/admin/sys-file/oss/file?fileName=${item.fileName}`;
|
||||
return `${proxy.baseURL}/admin/sys-file/oss/file?fileName=${encodeURIComponent(item.fileName)}`;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-show="modelValue">
|
||||
<div v-if="type == 'image'">
|
||||
<el-image-viewer v-if="previewLists.length" :url-list="previewLists" hide-on-click-modal @close="handleClose"/>
|
||||
<el-image-viewer v-if="previewLists.length" :url-list="$fileUrls(previewLists)" hide-on-click-modal @close="handleClose"/>
|
||||
</div>
|
||||
<div v-if="type == 'video'">
|
||||
<el-dialog v-model="visible" width="740px" :title="$t('material.preview')" :before-close="handleClose">
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {Base64} from 'js-base64';
|
||||
import { accessFileUrl, resolveFileUrl } from '/@/utils/file-access';
|
||||
import {validateNull} from "/@/utils/validate";
|
||||
|
||||
const VideoPlayer = defineAsyncComponent(() => import('/@/components/VideoPlayer/index.vue'));
|
||||
@@ -88,6 +89,10 @@ const src = computed(() => {
|
||||
if (validateNull(kkServerURL)) {
|
||||
return undefined;
|
||||
}
|
||||
return `${kkServerURL}?url=` + encodeURIComponent(Base64.encode(`${localURL}${props.url}&fullfilename=${props.fileName}`));
|
||||
const signed = accessFileUrl(props.url);
|
||||
const resolved = /^https?:\/\//i.test(signed) ? signed : `${localURL?.replace(/\/$/, '') || location.origin}${resolveFileUrl(signed)}`;
|
||||
const source = new URL(resolved);
|
||||
source.searchParams.set('fullfilename', props.fileName);
|
||||
return `${kkServerURL}?url=` + encodeURIComponent(Base64.encode(source.toString()));
|
||||
});
|
||||
</script>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div :class="mode == 'square' ? 'chatface' : 'brround avatar cover-image'" :style="transform" style="overflow: hidden; width: 40px; height: 40px">
|
||||
<img v-if="faceUrl && !num" :src="faceUrl" class="w-100 h-100" />
|
||||
<img v-if="faceUrl && !num" :src="$fileUrl(faceUrl)" class="w-100 h-100" @error="$fileRetry(faceUrl)" />
|
||||
<div v-else :style="styles" class="w-100 h-100 d-flex ai-center jc-center">{{ text }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!-- 图片预览 -->
|
||||
<script lang="ts" setup name="PreviewImage">
|
||||
import { resolveFileUrl } from '/@/utils/file-access'
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { downBlobFile } from "/@/utils/other"
|
||||
|
||||
@@ -55,7 +56,7 @@ const realHeight = computed(() => (typeof props.height == "string" ? props.heigh
|
||||
|
||||
function dispatchUrl(url?: string) {
|
||||
if (!url) return ""
|
||||
return url.includes("http") ? url : import.meta.env.VITE_IMAGE_BASE_PATH + url
|
||||
return resolveFileUrl(url)
|
||||
}
|
||||
|
||||
// 图片下载
|
||||
@@ -67,21 +68,21 @@ const download = (src: string) => {
|
||||
|
||||
<template>
|
||||
<div v-if="props.src" class="flex flex-col items-center">
|
||||
<el-image
|
||||
<file-image
|
||||
hide-on-click-modal
|
||||
preview-teleported
|
||||
:src="`${realSrc}`"
|
||||
:src="$fileUrl(`${realSrc}`)"
|
||||
fit="cover"
|
||||
:style="`width:${realWidth};height:${realHeight};`"
|
||||
:preview-src-list="realSrcList"
|
||||
:preview-src-list="$fileUrls(realSrcList)"
|
||||
loading="lazy"
|
||||
>
|
||||
@error="$fileRetry(`${realSrc}`)">
|
||||
<template #error>
|
||||
<div class="image-slot">
|
||||
<i class="el-icon-picture-outline"></i>
|
||||
</div>
|
||||
</template>
|
||||
</el-image>
|
||||
</file-image>
|
||||
<el-button v-if="props.download" size="small" type="primary" link @click="download(props.src)">下载</el-button>
|
||||
</div>
|
||||
<div v-else :style="`width:${realWidth};height:${realHeight};`" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<component :is="getIconName" />
|
||||
</i>
|
||||
<div v-else-if="isShowIconImg" :style="setIconImgOutStyle">
|
||||
<img :src="getIconName" :style="setIconSvgInsStyle" />
|
||||
<img :src="$fileUrl(getIconName)" :style="setIconSvgInsStyle" @error="$fileRetry(getIconName)" />
|
||||
</div>
|
||||
<svg v-else-if="isShowLocalSvg" class="svg-icon icon" :style="setIconImgOutStyle">
|
||||
<use :href="`#${getIconName}`" :fill="color"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
>
|
||||
<template v-if="imageUrl">
|
||||
<!-- 如果返回的是OSS 地址则不需要增加 baseURL -->
|
||||
<img :src="imageUrl.includes('http') ? imageUrl : baseURL + imageUrl" class="upload-image" />
|
||||
<img :src="$fileUrl(imageUrl)" class="upload-image" @error="$fileRetry(imageUrl)" />
|
||||
<div class="upload-handle" @click.stop>
|
||||
<div class="handle-icon" @click="editImg" v-if="!self_disabled">
|
||||
<el-icon :size="props.iconSize"><Edit /></el-icon>
|
||||
@@ -48,7 +48,7 @@
|
||||
:teleported="true"
|
||||
v-if="imgViewVisible"
|
||||
@close="imgViewVisible = false"
|
||||
:url-list="[imageUrl.includes('http') ? imageUrl : baseURL + imageUrl]"
|
||||
:url-list="$fileUrls([imageUrl])"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="upload-box">
|
||||
<div ref="imageContainer" class="upload-box">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
list-type="picture-card"
|
||||
@@ -19,12 +19,14 @@
|
||||
</el-upload>
|
||||
|
||||
<el-dialog v-model="dialogVisible">
|
||||
<img class="m-auto" w-full :src="dialogImageUrl" alt="Preview Image" />
|
||||
<img class="m-auto" w-full :src="$fileUrl(dialogImageUrl)" alt="Preview Image" @error="$fileRetry(dialogImageUrl)" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fileUrl, originalFileUrl, resolveFileUrl } from '/@/utils/file-access'
|
||||
import { bindFileAccessDom } from '/@/utils/file-access-dom'
|
||||
import { ref, watch } from "vue"
|
||||
import { Plus } from "@element-plus/icons-vue"
|
||||
import { ElUpload, ElDialog, UploadRequestOptions, ElNotification, UploadFile, UploadProps, formContextKey } from "element-plus"
|
||||
@@ -47,9 +49,13 @@ const props = withDefaults(defineProps<UploadFileProps>(), {
|
||||
borderRadius: "8px",
|
||||
})
|
||||
|
||||
const imageContainer = ref<HTMLElement>()
|
||||
let stopResourceRenewal: (() => void) | undefined
|
||||
onMounted(() => { if (imageContainer.value) stopResourceRenewal = bindFileAccessDom(imageContainer.value) })
|
||||
onBeforeUnmount(() => stopResourceRenewal?.())
|
||||
|
||||
const imageUrls = defineModel("modelValue", { default: "" })
|
||||
|
||||
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH
|
||||
const dialogVisible = ref(false)
|
||||
const fileList = ref<any>([])
|
||||
const dialogImageUrl = ref("")
|
||||
@@ -105,19 +111,18 @@ const beforeUpload: UploadProps["beforeUpload"] = (rawFile) => {
|
||||
* @description 图片上传成功
|
||||
* */
|
||||
const uploadSuccess = (response: any, uploadFile: UploadFile, uploadFiles: any) => {
|
||||
console.log("success", uploadFiles)
|
||||
|
||||
|
||||
const urls = uploadFiles
|
||||
.map((item: any) => {
|
||||
// 处理新上传和已有的图片URL
|
||||
return item.response ? item.response.data.url : item.fileUrl
|
||||
return originalFileUrl(item.response ? item.response.data.url : item.fileUrl)
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(",")
|
||||
imageUrls.value = urls
|
||||
|
||||
console.log("fileList.value", fileList.value)
|
||||
console.log("urls", urls)
|
||||
|
||||
|
||||
ElNotification({
|
||||
title: "温馨提示",
|
||||
@@ -136,7 +141,7 @@ const handlePictureCardPreview = (uploadFile: any) => {
|
||||
const handleRemove = (uploadFile: any, uploadFiles: any[]) => {
|
||||
const urls = uploadFiles
|
||||
.map((item) => {
|
||||
return item.response ? item.response.data.url : item.fileUrl
|
||||
return originalFileUrl(item.response ? item.response.data.url : item.fileUrl)
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(",")
|
||||
@@ -171,16 +176,15 @@ watch(
|
||||
fileList.value = newValue
|
||||
.split(",")
|
||||
.map((item: string) => {
|
||||
const url = item.startsWith("http") ? item : imageBaseUrl + item
|
||||
const url = resolveFileUrl(item)
|
||||
return {
|
||||
name: item.split("/").pop() || "",
|
||||
url: url,
|
||||
url: fileUrl(url),
|
||||
fileUrl: item,
|
||||
}
|
||||
})
|
||||
.filter((item) => item.url)
|
||||
|
||||
console.log("fileList.value", fileList.value)
|
||||
} else {
|
||||
fileList.value = newValue
|
||||
.split("?")
|
||||
@@ -189,16 +193,15 @@ watch(
|
||||
item.endsWith(".jpg") || item.endsWith(".png") || item.endsWith(".gif") || item.endsWith(".jpeg") || item.endsWith(".webp"),
|
||||
)
|
||||
.map((item: string) => {
|
||||
const url = item.startsWith("http") ? item : imageBaseUrl + item
|
||||
const url = resolveFileUrl(item)
|
||||
return {
|
||||
name: item.split("/").pop() || "",
|
||||
url: url,
|
||||
url: fileUrl(url),
|
||||
fileUrl: item,
|
||||
}
|
||||
})
|
||||
.filter((item) => item.url)
|
||||
|
||||
console.log("fileList.value", fileList.value)
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</el-upload>
|
||||
|
||||
<el-dialog v-model="dialogVisible">
|
||||
<img class="m-auto" w-full :src="dialogImageUrl" alt="Preview Image" />
|
||||
<img class="m-auto" w-full :src="$fileUrl(dialogImageUrl)" alt="Preview Image" @error="$fileRetry(dialogImageUrl)" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="flex min-w-0 items-center gap-3 text-left">
|
||||
<el-avatar :size="props.avatarSize" :src="props.user.avatar || undefined" :alt="displayName" class="user-info-cell__avatar shrink-0">
|
||||
<el-avatar :size="props.avatarSize" :src="$fileUrl(props.user.avatar) || undefined" @error="$fileRetry(props.user.avatar)" :alt="displayName" class="user-info-cell__avatar shrink-0">
|
||||
{{ avatarFallback }}
|
||||
</el-avatar>
|
||||
<div class="min-w-0 flex-1">
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
<i class="iconfont icon-refresh"></i>
|
||||
</div>
|
||||
<img
|
||||
:src="'data:image/png;base64,' + pointBackImgBase"
|
||||
:src="$fileUrl('data:image/png;base64,' + pointBackImgBase)"
|
||||
ref="canvas"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block"
|
||||
@click="bindingClick ? canvasClick($event) : undefined"
|
||||
/>
|
||||
@error="$fileRetry('data:image/png;base64,' + pointBackImgBase)" />
|
||||
|
||||
<div
|
||||
v-for="(tempPoint, index) in tempPoints"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div style="position: relative">
|
||||
<div v-if="type === '2'" :style="{ height: parseInt(setSize.imgHeight) + vSpace + 'px' }" class="verify-img-out">
|
||||
<div :style="{ width: setSize.imgWidth, height: setSize.imgHeight }" class="verify-img-panel modern-shadow">
|
||||
<img :src="'data:image/png;base64,' + backImgBase" alt="" style="width: 100%; height: 100%; display: block" />
|
||||
<img :src="$fileUrl('data:image/png;base64,' + backImgBase)" alt="" style="width: 100%; height: 100%; display: block" @error="$fileRetry('data:image/png;base64,' + backImgBase)" />
|
||||
<div v-show="showRefresh" class="verify-refresh" @click="refresh"><i class="iconfont icon-refresh"></i></div>
|
||||
<transition name="tips">
|
||||
<span v-if="tipWords" :class="passFlag ? 'suc-bg' : 'err-bg'" class="verify-tips">{{ tipWords }}</span>
|
||||
@@ -46,10 +46,10 @@
|
||||
class="verify-sub-block"
|
||||
>
|
||||
<img
|
||||
:src="'data:image/png;base64,' + blockBackImgBase"
|
||||
:src="$fileUrl('data:image/png;base64,' + blockBackImgBase)"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block; -webkit-user-drag: none"
|
||||
/>
|
||||
@error="$fileRetry('data:image/png;base64,' + blockBackImgBase)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
<video-play
|
||||
ref="playerRef"
|
||||
v-bind="options"
|
||||
:src="src"
|
||||
:src="$fileUrl(src)"
|
||||
:poster="$fileUrl(poster)"
|
||||
@error="$fileRetry(src)"
|
||||
@play="onPlay"
|
||||
@pause="onPause"
|
||||
@timeupdate="onTimeupdate"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div v-if="objData.type === 'image'">
|
||||
<div class="waterfall" v-loading="state.loading">
|
||||
<div class="waterfall-item" v-for="item in state.dataList" :key="item.mediaId">
|
||||
<img class="material-img" :src="item.url" />
|
||||
<img class="material-img" :src="$fileUrl(item.url)" @error="$fileRetry(item.url)" />
|
||||
<p class="item-name">{{ item.name }}</p>
|
||||
<el-row class="ope-row">
|
||||
<el-button type="success" @click="selectMaterial(item)"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<div v-if="item.repType === 'text'">{{ item.repContent }}</div>
|
||||
<div v-if="item.repType === 'image'">
|
||||
<a target="_blank" :href="item.repUrl"><img :src="item.repUrl" style="width: 100px" /></a>
|
||||
<a target="_blank" :href="$fileUrl(item.repUrl)"><img :src="$fileUrl(item.repUrl)" style="width: 100px" @error="$fileRetry(item.repUrl)" /></a>
|
||||
</div>
|
||||
<div v-if="item.repType === 'voice'">
|
||||
<SvgIcon name="local-wx-voice" :size="80" @click="loadVideo(item)"></SvgIcon>
|
||||
@@ -54,7 +54,7 @@
|
||||
<el-link
|
||||
type="primary"
|
||||
target="_blank"
|
||||
:href="
|
||||
:href="$fileUrl(
|
||||
'https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=' +
|
||||
item.repLocationY +
|
||||
'&pointy=' +
|
||||
@@ -62,23 +62,29 @@
|
||||
'&name=' +
|
||||
item.repContent +
|
||||
'&ref=joolun'
|
||||
"
|
||||
)"
|
||||
>
|
||||
<img
|
||||
:src="
|
||||
:src="$fileUrl(
|
||||
'https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|' +
|
||||
item.repLocationX +
|
||||
',' +
|
||||
item.repLocationY +
|
||||
'&key=PFFBZ-RBM3V-IEEPP-UH6KE-6QUQE-C4BVJ&size=250*180'
|
||||
"
|
||||
/>
|
||||
)"
|
||||
@error="$fileRetry(
|
||||
'https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|' +
|
||||
item.repLocationX +
|
||||
',' +
|
||||
item.repLocationY +
|
||||
'&key=PFFBZ-RBM3V-IEEPP-UH6KE-6QUQE-C4BVJ&size=250*180'
|
||||
)" />
|
||||
<p />
|
||||
<i class="el-icon-map-location"></i>{{ item.repContent }}
|
||||
</el-link>
|
||||
</div>
|
||||
<div v-if="item.repType === 'link'" class="avue-card__detail">
|
||||
<el-link type="success" :underline="false" target="_blank" :href="item.repUrl">
|
||||
<el-link type="success" :underline="false" target="_blank" :href="$fileUrl(item.repUrl)">
|
||||
<div class="avue-card__title"><i class="el-icon-link"></i>{{ item.repName }}</div>
|
||||
</el-link>
|
||||
<div class="avue-card__info" style="height: unset">{{ item.repDesc }}</div>
|
||||
@@ -87,9 +93,9 @@
|
||||
<wx-news :obj-data="JSON.parse(item.content)"></wx-news>
|
||||
</div>
|
||||
<div v-if="item.repType === 'music'">
|
||||
<el-link type="success" :underline="false" target="_blank" :href="item.repUrl">
|
||||
<el-link type="success" :underline="false" target="_blank" :href="$fileUrl(item.repUrl)">
|
||||
<div class="avue-card__body" style="padding: 10px; background-color: #fff; border-radius: 5px">
|
||||
<div class="avue-card__avatar"><img :src="item.repThumbUrl" alt="" /></div>
|
||||
<div class="avue-card__avatar"><img :src="$fileUrl(item.repThumbUrl)" alt="" @error="$fileRetry(item.repThumbUrl)" /></div>
|
||||
<div class="avue-card__detail">
|
||||
<div class="avue-card__title" style="margin-bottom: unset">{{ item.repName }}</div>
|
||||
<div class="avue-card__info" style="height: unset">{{ item.repDesc }}</div>
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<template>
|
||||
<div class="news-home">
|
||||
<div v-for="(news, index) in props.objData" :key="index" class="news-div">
|
||||
<a v-if="index === 0" target="_blank" :href="news.url">
|
||||
<a v-if="index === 0" target="_blank" :href="$fileUrl(news.url)">
|
||||
<div class="news-main">
|
||||
<div class="news-content">
|
||||
<img class="material-img" :src="news.thumbUrl" style="width: 280; height: 120" />
|
||||
<img class="material-img" :src="$fileUrl(news.thumbUrl)" style="width: 280; height: 120" @error="$fileRetry(news.thumbUrl)" />
|
||||
<div class="news-content-title">
|
||||
<span>{{ news.title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<a v-if="index > 0" target="_blank" :href="news.url">
|
||||
<a v-if="index > 0" target="_blank" :href="$fileUrl(news.url)">
|
||||
<div class="news-main-item">
|
||||
<div class="news-content-item">
|
||||
<div class="news-content-item-title">{{ news.title }}</div>
|
||||
<div class="news-content-item-img">
|
||||
<img class="material-img" :src="news.thumbUrl" height="100%" />
|
||||
<img class="material-img" :src="$fileUrl(news.thumbUrl)" height="100%" @error="$fileRetry(news.thumbUrl)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<template #label><i class="el-icon-picture"></i> 图片</template>
|
||||
<el-row>
|
||||
<div v-if="objData.repUrl" class="select-item">
|
||||
<img class="material-img" :src="objData.repUrl" />
|
||||
<img class="material-img" :src="$fileUrl(objData.repUrl)" @error="$fileRetry(objData.repUrl)" />
|
||||
<p v-if="objData.repName" class="item-name">{{ objData.repName }}</p>
|
||||
<el-row class="ope-row">
|
||||
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj"></el-button>
|
||||
@@ -36,7 +36,7 @@
|
||||
<div v-if="objData.repName" class="select-item">
|
||||
<p class="item-name">{{ objData.repName }}</p>
|
||||
<div class="item-infos">
|
||||
<img :src="WxVoice" style="width: 100px" @click="loadVideo(item)" />
|
||||
<img :src="$fileUrl(WxVoice)" style="width: 100px" @click="loadVideo(item)" @error="$fileRetry(WxVoice)" />
|
||||
</div>
|
||||
<el-row class="ope-row">
|
||||
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj"></el-button>
|
||||
@@ -65,7 +65,7 @@
|
||||
</el-row>
|
||||
<el-row style="text-align: center">
|
||||
<el-col :span="12" class="col-select">
|
||||
<a v-if="objData.repUrl" target="_blank" :href="objData.repUrl"> <SvgIcon name="local-wx-video" :size="45" /> </a
|
||||
<a v-if="objData.repUrl" target="_blank" :href="$fileUrl(objData.repUrl)"> <SvgIcon name="local-wx-video" :size="45" /> </a
|
||||
></el-col>
|
||||
<el-col :span="12" class="col-add">
|
||||
<el-button type="success" @click="openMaterial({ type: 'video', accountId: props.objData.appId })">素材库选择 </el-button>
|
||||
|
||||
@@ -14,6 +14,7 @@ import Tip from "/@/components/Tip/index.vue"
|
||||
import TagList from "/@/components/TagList/index.vue"
|
||||
import SvgIcon from "/@/components/SvgIcon/index.vue"
|
||||
import PreviewImage from "/@/components/PreviewImage/index.vue"
|
||||
import FileImage from "/@/components/FileImage/index.vue"
|
||||
import PreviewJson from "/@/components/PreviewJson/index.vue"
|
||||
import PreviewText from "/@/components/PreviewText/index.vue"
|
||||
import PreviewXml from "/@/components/PreviewXml/index.vue"
|
||||
@@ -86,6 +87,7 @@ export default {
|
||||
app.component("TagList", TagList)
|
||||
app.component("SvgIcon", SvgIcon)
|
||||
app.component("PreviewImage", PreviewImage)
|
||||
app.component("FileImage", FileImage)
|
||||
app.component("PreviewJson", PreviewJson)
|
||||
app.component("PreviewText", PreviewText)
|
||||
app.component("PreviewXml", PreviewXml)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div :class="themeConfig.columnsAsideLayout" v-else>
|
||||
<a :href="v.meta.isLink" target="_blank">
|
||||
<a :href="$fileUrl(v.meta.isLink)" target="_blank">
|
||||
<SvgIcon :name="v.meta.icon" />
|
||||
<div class="columns-vertical-title font12">
|
||||
{{
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div v-show="state.isShowLoockLogin" class="layout-lock-screen-login">
|
||||
<div class="layout-lock-screen-login-box">
|
||||
<div class="layout-lock-screen-login-box-img">
|
||||
<img :src="baseURL + formData.avatar" />
|
||||
<img :src="$fileUrl(formData.avatar)" @error="$fileRetry(formData.avatar)" />
|
||||
</div>
|
||||
<div class="layout-lock-screen-login-box-name">{{ formData.username }}</div>
|
||||
<div class="layout-lock-screen-login-box-value">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<span :style="{color:setFontColor}">{{ themeConfig.globalTitle }}</span>
|
||||
</div>
|
||||
<div class="layout-logo-size" v-else @click="onThemeConfigChange">
|
||||
<img :src="logoMini" class="layout-logo-size-img"/>
|
||||
<img :src="$fileUrl(logoMini)" class="layout-logo-size-img" @error="$fileRetry(logoMini)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
</div>
|
||||
<el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick">
|
||||
<span class="layout-navbars-breadcrumb-user-link">
|
||||
<img :src="baseURL + userInfos.user.avatar" class="layout-navbars-breadcrumb-user-link-photo mr5" />
|
||||
<img :src="$fileUrl(userInfos.user.avatar)" class="layout-navbars-breadcrumb-user-link-photo mr5" @error="$fileRetry(userInfos.user.avatar)" />
|
||||
{{ userInfos.user.username }}
|
||||
<el-icon class="el-icon--right">
|
||||
<ele-ArrowDown />
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { installFileAccess } from './utils/file-access'
|
||||
import { downBlobFile } from './utils/other'
|
||||
import { createApp } from "vue"
|
||||
import pinia from "/@/stores/index"
|
||||
import App from "./App.vue"
|
||||
@@ -23,6 +25,7 @@ import "/@/theme/tailwind.css"
|
||||
import "/@/theme/index.scss"
|
||||
|
||||
const app = createApp(App)
|
||||
installFileAccess(app, downBlobFile)
|
||||
|
||||
// 全局自定方法挂载
|
||||
properties(app)
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import 'vue'
|
||||
declare module '@vue/runtime-core' {
|
||||
interface ComponentCustomProperties {
|
||||
$fileUrl: (source?: string | null) => string
|
||||
$fileUrls: (sources: any) => string[]
|
||||
$fileHtml: (html: string) => string
|
||||
$fileNodes: (nodes: any) => any
|
||||
$fileRetry: (source?: string | null) => Promise<boolean>
|
||||
}
|
||||
}
|
||||
export {}
|
||||
@@ -0,0 +1,131 @@
|
||||
import * as CryptoJS from 'crypto-js'
|
||||
|
||||
export const FILE_ACCESS_FIELDS = ['appId', 'kid', 'ts', 'sign']
|
||||
const FILE_PATHS = ['/sys-file/oss/file', '/admin/sys-file/oss/file', '/api/admin/sys-file/oss/file']
|
||||
export interface FileAccessOptions {
|
||||
appId: string; kid: string; key: string; baseUrl: () => string
|
||||
allowedOrigins?: string[]; now?: () => number
|
||||
}
|
||||
const decode = (s: string) => decodeURIComponent(s.replace(/\+/g, ' '))
|
||||
const encode = (s: string) => encodeURIComponent(s).replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase())
|
||||
const origin = (s: string) => {
|
||||
const match = /^(https?):\/\/([^/?#]+)/i.exec(s)
|
||||
if (!match || match[2].includes('@')) return ''
|
||||
return (match[1] + '://' + match[2]).toLowerCase().replace(match[1].toLowerCase() === 'https' ? /:443$/ : /:80$/, '')
|
||||
}
|
||||
export function fileAccessCanonical(file: string, app: string, kid: string, ts: number): string {
|
||||
const name = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(file)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
|
||||
return ['v1', 'oss-file-read', app, kid, String(ts), name].join('\n')
|
||||
}
|
||||
export function fileAccessSignature(file: string, app: string, kid: string, ts: number, key: string): string {
|
||||
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(key) || CryptoJS.enc.Base64.parse(key).sigBytes < 32) throw new Error('Invalid file access key')
|
||||
return CryptoJS.HmacSHA256(fileAccessCanonical(file, app, kid, ts), CryptoJS.enc.Base64.parse(key)).toString(CryptoJS.enc.Hex)
|
||||
}
|
||||
export function createFileAccess(options: FileAccessOptions) {
|
||||
const now = options.now || Date.now
|
||||
let offset = 0, ttl = 1800
|
||||
const cache = new Map<string, { url: string; ts: number }>()
|
||||
const base = () => (options.baseUrl() || '').replace(/\/+$/, '')
|
||||
const allowed = () => [origin(base()), ...(options.allowedOrigins || []).map(origin)].filter(Boolean)
|
||||
function resolve(source?: string | null): string {
|
||||
const raw = typeof source === 'string' ? source.trim() : ''
|
||||
if (!raw || /^(?:data:|blob:|file:|wxfile:|content:|\/static\/|static\/|\/assets\/|\/src\/|@\/|#)/i.test(raw)) return raw
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(raw)) return raw
|
||||
if (raw.startsWith('//')) return (base().startsWith('http:') ? 'http:' : 'https:') + raw
|
||||
const root = base()
|
||||
if (/^[^/?#:\\]+\.[a-z0-9]{1,10}$/i.test(raw)) return root + '/admin/sys-file/oss/file?fileName=' + encode(raw)
|
||||
const path = raw.startsWith('/') ? raw : '/' + raw
|
||||
if (/^(?:\/api)?\/admin\/sys-file\/oss\/(?:file|access-info)(?:[?#]|$)/.test(path)) return root + path.replace(/^\/api\//, '/')
|
||||
const prefix = root.replace(/^https?:\/\/[^/?#]+/i, '')
|
||||
if ((prefix && path.startsWith(prefix + '/')) || path.startsWith('/api/')) return (origin(root) || '') + path
|
||||
if (path.startsWith('/sys-file/oss/')) return root + '/admin' + path
|
||||
if (raw.startsWith('?')) return root + '/admin/sys-file/oss/file' + raw
|
||||
return root + path
|
||||
}
|
||||
function parse(source?: string | null) {
|
||||
const resolved = resolve(source)
|
||||
const ownOrigin = origin(resolved)
|
||||
if (ownOrigin && !allowed().includes(ownOrigin)) return null
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(resolved) && !ownOrigin) return null
|
||||
const relative = ownOrigin ? resolved.replace(/^https?:\/\/[^/?#]+/i, '') : resolved
|
||||
const path = relative.split(/[?#]/)[0]
|
||||
const prefix = base().replace(/^https?:\/\/[^/?#]+/i, '')
|
||||
if (!FILE_PATHS.includes(path) && path !== prefix + '/admin/sys-file/oss/file') return null
|
||||
const hashAt = resolved.indexOf('#'), head = hashAt < 0 ? resolved : resolved.slice(0, hashAt)
|
||||
const hash = hashAt < 0 ? '' : resolved.slice(hashAt)
|
||||
const question = head.indexOf('?')
|
||||
const endpoint = question < 0 ? head : head.slice(0, question)
|
||||
const pairs = (question < 0 ? '' : head.slice(question + 1)).split('&').filter(Boolean).map(pair => {
|
||||
const at = pair.indexOf('='); return [decode(at < 0 ? pair : pair.slice(0, at)), decode(at < 0 ? '' : pair.slice(at + 1))]
|
||||
})
|
||||
const names = pairs.filter(([key]) => key === 'fileName')
|
||||
if (names.length !== 1 || !names[0][1] || /[\r\n]/.test(names[0][1])) throw new Error('Invalid file-center URL')
|
||||
const extras = pairs.filter(([key]) => key !== 'fileName' && !FILE_ACCESS_FIELDS.includes(key))
|
||||
const unsigned = endpoint + '?' + [...extras, ['fileName', names[0][1]]].map(([k, v]) => encode(k) + '=' + encode(v)).join('&') + hash
|
||||
return { endpoint, file: names[0][1], extras, hash, unsigned }
|
||||
}
|
||||
function url(source?: string | null, force = false): string {
|
||||
const parsed = parse(source)
|
||||
if (!parsed) return resolve(source)
|
||||
const seconds = Math.floor((now() + offset) / 1000), cached = cache.get(parsed.unsigned)
|
||||
if (!force && cached && seconds >= cached.ts - 300 && seconds < cached.ts + ttl - Math.min(300, ttl / 6)) return cached.url
|
||||
if (!options.appId || !options.kid) throw new Error('Missing file access configuration')
|
||||
const sign = fileAccessSignature(parsed.file, options.appId, options.kid, seconds, options.key)
|
||||
const pairs = [...parsed.extras, ['appId', options.appId], ['kid', options.kid], ['ts', String(seconds)], ['sign', sign], ['fileName', parsed.file]]
|
||||
const result = parsed.endpoint + '?' + pairs.map(([k, v]) => encode(k) + '=' + encode(v)).join('&') + parsed.hash
|
||||
if (cache.size >= 2048) cache.delete(cache.keys().next().value as string)
|
||||
cache.set(parsed.unsigned, { url: result, ts: seconds })
|
||||
return result
|
||||
}
|
||||
function strip(source?: string | null): string {
|
||||
if (!source) return source || ''
|
||||
const parsed = parse(source)
|
||||
if (!parsed) return source
|
||||
// Preserve the original origin/path form in persisted values.
|
||||
const hashAt = source.indexOf('#'), hash = hashAt < 0 ? '' : source.slice(hashAt)
|
||||
const head = hashAt < 0 ? source : source.slice(0, hashAt), at = head.indexOf('?')
|
||||
if (at < 0) return source
|
||||
const query = head.slice(at + 1).split('&').filter(p => !FILE_ACCESS_FIELDS.includes(decode(p.split('=')[0])))
|
||||
return head.slice(0, at) + (query.length ? '?' + query.join('&') : '') + hash
|
||||
}
|
||||
function synchronize(serverTime: number, ttlSeconds = ttl, roundTripMs = 0) {
|
||||
if (!Number.isFinite(serverTime) || serverTime <= 0) return
|
||||
offset = serverTime + roundTripMs / 2 - now()
|
||||
if (Number.isFinite(ttlSeconds) && ttlSeconds > 300 && ttlSeconds <= 86400) ttl = ttlSeconds
|
||||
// url() already checks cached timestamps against the corrected clock. Keep
|
||||
// signatures that are still usable so a small clock correction cannot reload every image.
|
||||
}
|
||||
function invalidate(source?: string | null) {
|
||||
const parsed = parse(source)
|
||||
if (parsed) cache.delete(parsed.unsigned)
|
||||
}
|
||||
return { url, resolve, strip, protected: (s?: string | null) => !!parse(s), synchronize, invalidate, clear: () => cache.clear(), ttl: () => ttl }
|
||||
}
|
||||
|
||||
const unescapeAttribute = (s: string) => s.replace(/&/gi, '&').replace(/"/gi, '"').replace(/&#(?:39|x27);/gi, "'").replace(/&#(x[0-9a-f]+|\d+);/gi, (_, n) => { const code = n[0].toLowerCase() === 'x' ? parseInt(n.slice(1), 16) : Number(n); return code <= 0x10ffff ? String.fromCodePoint(code) : ''; })
|
||||
const escapeAttribute = (s: string) => s.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''')
|
||||
/** Rewrite only resource attributes; no DOM/window dependency (also used by mini programs). */
|
||||
export function rewriteFileHtml(html: string, transform: (url: string) => string): string {
|
||||
if (typeof html !== 'string' || !html) return html
|
||||
return html.replace(/<[a-z][^>]*>/gi, tag => tag.replace(/\b(src|href|poster|srcset)\s*=\s*(["'])([\s\S]*?)\2/gi, (attribute, name, quote, raw) => {
|
||||
const value = unescapeAttribute(raw)
|
||||
const next = name.toLowerCase() === 'srcset' && !value.startsWith('data:')
|
||||
? value.split(',').map(item => item.trim().replace(/^\S+/, transform)).join(', ')
|
||||
: transform(value)
|
||||
return next === value ? attribute : name + '=' + quote + escapeAttribute(next) + quote
|
||||
}).replace(/url\(\s*(["']?)([^)'"\s]+)\1\s*\)/gi, (all, quote, value) => {
|
||||
const next = transform(unescapeAttribute(value)); return next === value ? all : 'url(' + quote + escapeAttribute(next) + quote + ')'
|
||||
}))
|
||||
}
|
||||
export function rewriteFileNodes(nodes: any, transform: (url: string) => string): any {
|
||||
if (typeof nodes === 'string') return rewriteFileHtml(nodes, transform)
|
||||
if (Array.isArray(nodes)) return nodes.map(node => rewriteFileNodes(node, transform))
|
||||
if (!nodes || typeof nodes !== 'object') return nodes
|
||||
const copy = { ...nodes }
|
||||
if (copy.attrs) {
|
||||
copy.attrs = { ...copy.attrs }
|
||||
for (const key of ['src', 'href', 'poster']) if (typeof copy.attrs[key] === 'string') copy.attrs[key] = transform(copy.attrs[key])
|
||||
}
|
||||
if (copy.children) copy.children = rewriteFileNodes(copy.children, transform)
|
||||
return copy
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { watch } from 'vue';
|
||||
import { accessFileUrl, fileAccessRevision, retryFileAccess } from './file-access';
|
||||
|
||||
/** Renew editor resources without replacing the document or changing its undo history. */
|
||||
export function bindFileAccessDom(root: HTMLElement) {
|
||||
let scheduled = false;
|
||||
let stopped = false;
|
||||
const refresh = () => {
|
||||
if (stopped) return;
|
||||
for (const node of root.querySelectorAll<HTMLElement>('[src], [href], [poster]')) {
|
||||
for (const attr of ['src', 'href', 'poster']) {
|
||||
const source = node.getAttribute(attr);
|
||||
if (!source) continue;
|
||||
const target = accessFileUrl(source);
|
||||
if (target !== source) node.setAttribute(attr, target);
|
||||
}
|
||||
}
|
||||
};
|
||||
const schedule = () => {
|
||||
if (scheduled || stopped) return;
|
||||
scheduled = true;
|
||||
queueMicrotask(() => { scheduled = false; refresh(); });
|
||||
};
|
||||
const observer = new MutationObserver(schedule);
|
||||
observer.observe(root, { subtree: true, childList: true, attributes: true, attributeFilter: ['src', 'href', 'poster'] });
|
||||
const unwatch = watch(fileAccessRevision, schedule, { flush: 'post' });
|
||||
const onError = (event: Event) => {
|
||||
const node = event.target;
|
||||
if (node instanceof HTMLElement) void retryFileAccess(node.getAttribute('src')).then(schedule);
|
||||
};
|
||||
root.addEventListener('error', onError, true);
|
||||
refresh();
|
||||
return () => {
|
||||
stopped = true;
|
||||
observer.disconnect();
|
||||
unwatch();
|
||||
root.removeEventListener('error', onError, true);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { ref } from 'vue'
|
||||
import { createFileAccess, rewriteFileHtml, rewriteFileNodes } from './file-access-core'
|
||||
|
||||
|
||||
export const fileAccessRevision = ref(0)
|
||||
const client = createFileAccess({
|
||||
appId: import.meta.env.VITE_FILE_ACCESS_APP_ID,
|
||||
kid: import.meta.env.VITE_FILE_ACCESS_KEY_ID,
|
||||
key: import.meta.env.VITE_FILE_ACCESS_KEY,
|
||||
baseUrl: () => import.meta.env.VITE_IMAGE_BASE_PATH || import.meta.env.VITE_API_URL || '/api',
|
||||
allowedOrigins: [import.meta.env.VITE_IMAGE_BASE_PATH, typeof location === 'undefined' ? '' : location.origin, ...(import.meta.env.VITE_FILE_ACCESS_ALLOWED_ORIGINS || '').split(',')],
|
||||
})
|
||||
let timer: ReturnType<typeof setInterval> | undefined
|
||||
let pending: Promise<void> | undefined
|
||||
let lastSync = 0
|
||||
const retried = new Map<string, number>()
|
||||
const retrying = new Map<string, Promise<boolean>>()
|
||||
export function fileUrl(source?: string | null): string {
|
||||
void fileAccessRevision.value
|
||||
try { return client.url(source) } catch { return '' }
|
||||
}
|
||||
export const accessFileUrl = (source?: string | null) => isProtectedFile(source) ? fileUrl(source) : (source || '')
|
||||
export const fileUrls = (sources: any) => Array.isArray(sources) ? sources.map(accessFileUrl) : []
|
||||
export const originalFileUrl = (source?: string | null) => client.strip(source)
|
||||
export const resolveFileUrl = (source?: string | null) => client.resolve(source)
|
||||
export const fileHtml = (html: string) => rewriteFileHtml(html, accessFileUrl)
|
||||
export const stripFileHtml = (html: string) => rewriteFileHtml(html, originalFileUrl)
|
||||
export const fileNodes = (nodes: any) => rewriteFileNodes(nodes, accessFileUrl)
|
||||
export const isProtectedFile = (source?: string | null) => { try { return client.protected(source) } catch { return false } }
|
||||
export async function refreshFileAccess(force = false): Promise<void> {
|
||||
if (pending) return pending
|
||||
if (!force && Date.now() - lastSync < 60000) return
|
||||
pending = (async () => {
|
||||
const started = Date.now()
|
||||
try {
|
||||
const result: any = await readAccessInfo()
|
||||
const info = result?.data || result
|
||||
if (info?.serverTime) client.synchronize(Number(info.serverTime), Number(info.ttlSeconds), Date.now() - started)
|
||||
lastSync = Date.now()
|
||||
} catch { /* Retain the last clock offset and signed access; never fall back to a bare URL. */ }
|
||||
finally { fileAccessRevision.value++; pending = undefined }
|
||||
})()
|
||||
return pending
|
||||
}
|
||||
export function startFileAccess() {
|
||||
if (!timer) timer = setInterval(() => { fileAccessRevision.value++ }, 60000)
|
||||
void refreshFileAccess()
|
||||
}
|
||||
export function stopFileAccess() { if (timer) clearInterval(timer); timer = undefined }
|
||||
export async function retryFileAccess(source?: string | null): Promise<boolean> {
|
||||
if (!isProtectedFile(source)) return false
|
||||
const raw = originalFileUrl(source), previous = retried.get(raw) || 0
|
||||
const active = retrying.get(raw)
|
||||
if (active) return active
|
||||
if (Date.now() - previous < 30 * 60 * 1000) return false
|
||||
if (retried.size >= 2048) retried.clear()
|
||||
retried.set(raw, Date.now())
|
||||
const task = (async () => {
|
||||
const previousUrl = fileUrl(source)
|
||||
await refreshFileAccess(true)
|
||||
client.invalidate(source)
|
||||
if (fileUrl(source) === previousUrl) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1100))
|
||||
client.invalidate(source)
|
||||
}
|
||||
fileAccessRevision.value++
|
||||
return true
|
||||
})()
|
||||
retrying.set(raw, task)
|
||||
try { return await task } finally { retrying.delete(raw) }
|
||||
}
|
||||
type FileDownloader = (url: string, query: Record<string, never>, name: string) => unknown
|
||||
/** Keep owned file links inside the application's fetch/blob download flow. */
|
||||
export function handleFileLinkClick(event: MouseEvent, download: FileDownloader): boolean {
|
||||
const anchor = (event.target as Element | null)?.closest?.('a[href]')
|
||||
const href = anchor?.getAttribute('href')
|
||||
if (event.defaultPrevented || !href || !isProtectedFile(href)) return false
|
||||
event.preventDefault()
|
||||
event.stopImmediatePropagation()
|
||||
const name = /[?&]fileName=([^&#]*)/.exec(resolveFileUrl(href))
|
||||
const filename = anchor?.getAttribute('download') || (name ? decodeURIComponent(name[1].replace(/\+/g, ' ')) : '文件')
|
||||
void download(originalFileUrl(href), {}, filename)
|
||||
return true
|
||||
}
|
||||
export function installFileAccess(app: any, download?: FileDownloader) {
|
||||
Object.assign(app.config.globalProperties, {
|
||||
$fileUrl: accessFileUrl, $fileUrls: fileUrls, $fileHtml: fileHtml, $fileNodes: fileNodes, $fileRetry: retryFileAccess,
|
||||
})
|
||||
startFileAccess()
|
||||
if (typeof window !== 'undefined') {
|
||||
if (download) document.addEventListener('click', event => { handleFileLinkClick(event, download) }, true)
|
||||
window.addEventListener('online', () => { retried.clear(); void refreshFileAccess(true) })
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.hidden) stopFileAccess()
|
||||
else { retried.clear(); startFileAccess() }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function readAccessInfo() {
|
||||
const controller = new AbortController()
|
||||
const timeout = setTimeout(() => controller.abort(), 5000)
|
||||
try {
|
||||
const response = await fetch(client.resolve('/admin/sys-file/oss/access-info'), { credentials: 'omit', cache: 'no-store', signal: controller.signal })
|
||||
if (!response.ok) throw new Error('File clock unavailable')
|
||||
return await response.json()
|
||||
} finally { clearTimeout(timeout) }
|
||||
}
|
||||
+8
-2
@@ -1,3 +1,4 @@
|
||||
import { accessFileUrl, refreshFileAccess, isProtectedFile } from './file-access'
|
||||
import { nextTick } from "vue"
|
||||
import router from "/@/router/index"
|
||||
import pinia from "/@/stores/index"
|
||||
@@ -255,9 +256,10 @@ export function base64Encrypt(src: string) {
|
||||
* @param fileName 文件名称
|
||||
* @returns {*}
|
||||
*/
|
||||
export function downBlobFile(url: any, query: any, fileName: string) {
|
||||
export function downBlobFile(url: any, query: any, fileName: string, retried = false) {
|
||||
return request({
|
||||
url: url,
|
||||
url: accessFileUrl(url),
|
||||
...(isProtectedFile(url) ? { baseURL: '' } : {}),
|
||||
method: "get",
|
||||
responseType: "blob",
|
||||
params: query,
|
||||
@@ -266,6 +268,10 @@ export function downBlobFile(url: any, query: any, fileName: string) {
|
||||
handleBlobFile(response, fileName)
|
||||
})
|
||||
.catch(async (error) => {
|
||||
if (!retried && isProtectedFile(url)) {
|
||||
await refreshFileAccess(true)
|
||||
return downBlobFile(url, query, fileName, true)
|
||||
}
|
||||
let msg = "下载失败"
|
||||
try {
|
||||
if (error instanceof Blob) {
|
||||
|
||||
@@ -7,31 +7,33 @@
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button @click="dicDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary">
|
||||
<el-button @click="dicDialogRef.openDialog()" class="ml10" icon="folder-add"
|
||||
type="primary">
|
||||
{{ $t("common.addBtn") }}
|
||||
</el-button>
|
||||
<el-button plain @click="handleRefreshCache()" class="ml10" icon="refresh-left" type="primary">
|
||||
<el-button plain @click="handleRefreshCache()" class="ml10" icon="refresh-left"
|
||||
type="primary">
|
||||
{{ $t("common.refreshCacheBtn") }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-scrollbar>
|
||||
<query-tree ref="dictTreeRef" :query="state.queryList" @node-click="handleNodeClick" placeholder="请输入字典项或名称">
|
||||
<query-tree ref="dictTreeRef" :query="state.queryList" @node-click="handleNodeClick"
|
||||
placeholder="请输入字典项或名称">
|
||||
<template #default="{ data }">
|
||||
<span class="custom-tree-node">
|
||||
<span class="label">{{ data.description }}</span>
|
||||
<span class="code">{{ data.dictType }}</span>
|
||||
<span class="do">
|
||||
<el-button-group>
|
||||
<el-button icon="el-icon-edit" size="small" @click.stop="dicDialogRef.openDialog(data.id)"></el-button>
|
||||
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="data.systemFlag === '0'" placement="top">
|
||||
<el-button icon="el-icon-edit" size="small"
|
||||
@click.stop="dicDialogRef.openDialog(data.id)"></el-button>
|
||||
<el-tooltip :content="$t('sysdict.deleteDisabledTip')"
|
||||
:disabled="data.systemFlag === '0'" placement="top">
|
||||
<span style="margin-left: 12px">
|
||||
<el-button
|
||||
:disabled="data.systemFlag !== '0'"
|
||||
icon="el-icon-delete"
|
||||
size="small"
|
||||
@click.stop="handleDelete([data.id])"
|
||||
></el-button>
|
||||
<el-button :disabled="data.systemFlag !== '0'"
|
||||
icon="el-icon-delete" size="small"
|
||||
@click.stop="handleDelete([data.id])"></el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</el-button-group>
|
||||
@@ -41,9 +43,10 @@
|
||||
</query-tree>
|
||||
</el-scrollbar>
|
||||
<el-footer style="height: 40px; line-height: 40px">
|
||||
<el-button type="primary" size="small" icon="Download" style="width: 100%" @click="exportExcel">{{
|
||||
$t("common.exportBtn")
|
||||
}}</el-button>
|
||||
<el-button type="primary" size="small" icon="Download" style="width: 100%"
|
||||
@click="exportExcel">{{
|
||||
$t("common.exportBtn")
|
||||
}}</el-button>
|
||||
</el-footer>
|
||||
</div>
|
||||
</pane>
|
||||
@@ -130,6 +133,7 @@ const handleDelete = async (ids: string[]) => {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.custom-tree-node {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
@@ -139,16 +143,20 @@ const handleDelete = async (ids: string[]) => {
|
||||
padding-right: 24px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.custom-tree-node .code {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.custom-tree-node .do {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.custom-tree-node:hover .code {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.custom-tree-node:hover .do {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@@ -109,12 +109,16 @@
|
||||
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination"></pagination>
|
||||
<log-detail ref="LogDetailRef"></log-detail>
|
||||
</div>
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess"
|
||||
@failure="handleExportFailure" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { delObj, pageList } from "/@/api/admin/log"
|
||||
import { delObj, pageList, submitLogExport } from "/@/api/admin/log"
|
||||
import AsyncTaskProgressComponent from "/@/components/AsyncTaskProgress.vue"
|
||||
import { useBatchExport } from "/@/hooks/batchExport"
|
||||
import { useI18n } from "vue-i18n"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
@@ -152,7 +156,6 @@ const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
|
||||
// table hook
|
||||
const {
|
||||
downBlobFile,
|
||||
getDataList,
|
||||
currentChangeHandle: baseCurrentChangeHandle,
|
||||
sortChangeHandle,
|
||||
@@ -175,8 +178,16 @@ const resetQuery = () => {
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const { exportProgressRef, exportTaskConfig, submitExport, handleExportSuccess, handleExportFailure } = useBatchExport({
|
||||
progressUrl: "/admin/async-task/progress", redisKey: "admin:export:log",
|
||||
taskName: "操作日志", fileName: "操作日志.xlsx", submitTask: submitLogExport,
|
||||
})
|
||||
|
||||
const exportExcel = () => {
|
||||
downBlobFile("/admin/log/export", state.queryForm, "操作日志.xlsx")
|
||||
return submitExport({
|
||||
...state.queryForm,
|
||||
createTime: Array.isArray(state.queryForm.createTime) ? state.queryForm.createTime : [],
|
||||
})
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
匹配结果
|
||||
<tip content="可点击敏感词加入白名单"/>
|
||||
</template>
|
||||
<div v-html="matchResult" @click="handleChildClick"/>
|
||||
<div v-html="$fileHtml(matchResult)" @click="handleChildClick"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -58,11 +58,15 @@
|
||||
@refreshDataList="getDataList"
|
||||
/>
|
||||
</div>
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig"
|
||||
@success="handleExportSuccess" @failure="handleExportFailure" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="systemDept" setup>
|
||||
import { downBlobFile } from "/@/utils/other"
|
||||
import AsyncTaskProgressComponent from "/@/components/AsyncTaskProgress.vue"
|
||||
import { submitDeptExport } from "/@/api/admin/dept"
|
||||
import { useBatchExport } from "/@/hooks/batchExport"
|
||||
import { useI18n } from "vue-i18n"
|
||||
import { useUserInfo } from "/@/stores/userInfo"
|
||||
|
||||
@@ -120,8 +124,13 @@ const handleExpand = () => {
|
||||
/**
|
||||
* 导出Excel
|
||||
*/
|
||||
const { exportProgressRef, exportTaskConfig, submitExport, handleExportSuccess, handleExportFailure } = useBatchExport({
|
||||
progressUrl: "/admin/async-task/progress", redisKey: "admin:export:dept",
|
||||
taskName: "部门管理", fileName: "部门管理.xlsx", submitTask: submitDeptExport,
|
||||
})
|
||||
|
||||
const exportExcel = () => {
|
||||
downBlobFile("/admin/dept/export", state.queryForm, "部门管理.xlsx")
|
||||
return submitExport(state.queryForm)
|
||||
}
|
||||
|
||||
const getDataList = () => {
|
||||
|
||||
@@ -1,28 +1,14 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<DraggableDepTree
|
||||
ref="draggableDepTreeRef"
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<DraggableDepTree ref="draggableDepTreeRef" placeholder="请输入部门名称" :show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode" switch-inactive-text="包含" switch-active-text="不包含"
|
||||
:defaultTreeWidth="20" :nodeClickable="false">
|
||||
<template #default>
|
||||
<el-row v-show="showSearch">
|
||||
<SearchPanel
|
||||
v-show="showSearch"
|
||||
ref="queryRef"
|
||||
:model="state.queryForm"
|
||||
:loading="Boolean(state.loading)"
|
||||
:search-text="$t('common.queryBtn')"
|
||||
:reset-text="$t('common.resetBtn')"
|
||||
@search="getDataList"
|
||||
@reset="resetQuery"
|
||||
>
|
||||
<SearchPanel v-show="showSearch" ref="queryRef" :model="state.queryForm"
|
||||
:loading="Boolean(state.loading)" :search-text="$t('common.queryBtn')"
|
||||
:reset-text="$t('common.resetBtn')" @search="getDataList" @reset="resetQuery">
|
||||
<el-form-item style="width: 250px" label="用户" prop="userId">
|
||||
<select-user v-model="state.queryForm.userId" clearable />
|
||||
</el-form-item>
|
||||
@@ -41,38 +27,26 @@
|
||||
<select-role v-model="state.queryForm.role" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 250px" label="编制情况" prop="staffingType">
|
||||
<dict-select v-model="state.queryForm.staffingType" dict-code="user_staffing_type" />
|
||||
<dict-select v-model="state.queryForm.staffingType"
|
||||
dict-code="user_staffing_type" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</SearchPanel>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button v-auth="'sys_user_add'" icon="folder-add" type="primary" @click="userDialogRef.openDialog()">新增</el-button>
|
||||
<el-button plain v-auth="'sys_user_export'" class="ml10" icon="upload-filled" type="primary" @click="excelUploadRef.show()">
|
||||
<el-button v-auth="'sys_user_add'" icon="folder-add" type="primary"
|
||||
@click="userDialogRef.openDialog()">新增</el-button>
|
||||
<el-button plain v-auth="'sys_user_export'" class="ml10" icon="upload-filled" type="primary"
|
||||
@click="excelUploadRef.show()">
|
||||
导入
|
||||
</el-button>
|
||||
<el-button
|
||||
plain
|
||||
v-auth="'sys_user_del'"
|
||||
:disabled="multiple"
|
||||
class="ml10"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
@click="handleDelete(selectObjs)"
|
||||
>
|
||||
<el-button plain v-auth="'sys_user_del'" :disabled="multiple" class="ml10" icon="Delete"
|
||||
type="primary" @click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<el-button
|
||||
plain
|
||||
v-auth="'sys_user_del'"
|
||||
v-if="activeName == '1'"
|
||||
:disabled="multiple"
|
||||
class="ml10"
|
||||
icon="VideoPlay"
|
||||
type="primary"
|
||||
@click="doBatchDeal"
|
||||
>
|
||||
<el-button plain v-auth="'sys_user_del'" v-if="activeName == '1'" :disabled="multiple"
|
||||
class="ml10" icon="VideoPlay" type="primary" @click="doBatchDeal">
|
||||
审批
|
||||
</el-button>
|
||||
<div class="flex justify-between items-center">
|
||||
@@ -80,26 +54,15 @@
|
||||
<el-tab-pane v-for="v in tabItems" :key="v.id" :label="v.label" :name="v.value" />
|
||||
</el-tabs>
|
||||
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'sys_user_export'"
|
||||
@exportExcel="exportExcel"
|
||||
@queryTable="getDataList"
|
||||
class="ml10"
|
||||
style="float: right"
|
||||
/>
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'sys_user_export'"
|
||||
@exportExcel="exportExcel" @queryTable="getDataList" class="ml10"
|
||||
style="float: right" />
|
||||
</div>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table
|
||||
v-loading="state.loading"
|
||||
:data="state.dataList"
|
||||
@selection-change="handleSelectionChange"
|
||||
row-key="userId"
|
||||
border
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
>
|
||||
<el-table v-loading="state.loading" :data="state.dataList" @selection-change="handleSelectionChange"
|
||||
row-key="userId" border :cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column :selectable="handleSelectable" type="selection" width="40" />
|
||||
<el-table-column label="#" type="index" width="60" fixed="left" />
|
||||
<el-table-column label="用户名" prop="username" fixed="left" show-overflow-tooltip />
|
||||
@@ -108,13 +71,9 @@
|
||||
<el-table-column label="部门" prop="deptName" show-overflow-tooltip min-width="150" />
|
||||
<el-table-column label="启用" show-overflow-tooltip min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
:disabled="!auth('sys_user_edit') || row.processStatus != '2'"
|
||||
v-model="row.lockFlag"
|
||||
@change="changeSwitch(row)"
|
||||
active-value="0"
|
||||
inactive-value="9"
|
||||
></el-switch>
|
||||
<el-switch :disabled="!auth('sys_user_edit') || row.processStatus != '2'"
|
||||
v-model="row.lockFlag" @change="changeSwitch(row)" active-value="0"
|
||||
inactive-value="9"></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编制" min-width="80">
|
||||
@@ -124,7 +83,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="角色" show-overflow-tooltip min-width="150">
|
||||
<template #default="scope">
|
||||
<el-tag v-for="(item, index) in scope.row.roleList" :key="index"> {{ item.roleName }}</el-tag>
|
||||
<el-tag v-for="(item, index) in scope.row.roleList" :key="index"> {{ item.roleName
|
||||
}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="人脸">
|
||||
@@ -134,68 +94,44 @@
|
||||
</el-table-column>
|
||||
<el-table-column v-if="false" label="全局人脸" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
:disabled="!auth('userFace_sysUserFace_global_face')"
|
||||
v-if="row.isGlobalFace"
|
||||
v-model="row.isGlobalFace"
|
||||
@change="changeGlobalFaceSwitch(row)"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
<el-switch :disabled="!auth('userFace_sysUserFace_global_face')" v-if="row.isGlobalFace"
|
||||
v-model="row.isGlobalFace" @change="changeGlobalFaceSwitch(row)" active-value="1"
|
||||
inactive-value="0" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="所属商户" prop="merchantName" show-overflow-tooltip min-width="150" />
|
||||
<el-table-column
|
||||
v-auths="['sys_user_edit', 'userFace_sysUserFace_view', 'sys_user_del']"
|
||||
label="操作"
|
||||
min-width="300"
|
||||
width="300"
|
||||
fixed="right"
|
||||
>
|
||||
<el-table-column v-auths="['sys_user_edit', 'userFace_sysUserFace_view', 'sys_user_del']"
|
||||
label="操作" min-width="300" width="300" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center">
|
||||
<!-- 重置密码 -->
|
||||
<popover-input v-if="row.processStatus == '2'" v-model="inputPassword" @confirm="changePassword(row)">
|
||||
<popover-input v-if="row.processStatus == '2'" v-model="inputPassword"
|
||||
@confirm="changePassword(row)">
|
||||
<template #default>
|
||||
<el-button v-auth="'sys_user_edit'" icon="RefreshLeft" text type="primary" class="mr-4">密码</el-button>
|
||||
<el-button v-auth="'sys_user_edit'" icon="RefreshLeft" text type="primary"
|
||||
class="mr-4">密码</el-button>
|
||||
</template>
|
||||
</popover-input>
|
||||
<!-- 修改信息 -->
|
||||
<el-button
|
||||
v-if="row.processStatus == '2'"
|
||||
v-auth="'sys_user_edit'"
|
||||
icon="edit-pen"
|
||||
text
|
||||
type="primary"
|
||||
@click="userDialogRef.openDialog(row.userId)"
|
||||
>
|
||||
<el-button v-if="row.processStatus == '2'" v-auth="'sys_user_edit'" icon="edit-pen"
|
||||
text type="primary" @click="userDialogRef.openDialog(row.userId)">
|
||||
修改
|
||||
</el-button>
|
||||
<!-- 人脸管理 -->
|
||||
<el-button
|
||||
v-if="row.processStatus == '2'"
|
||||
v-auth="'userFace_sysUserFace_view'"
|
||||
icon="User"
|
||||
text
|
||||
type="primary"
|
||||
@click="faceManageRef.openDialog(row.userId)"
|
||||
>
|
||||
<el-button v-if="row.processStatus == '2'" v-auth="'userFace_sysUserFace_view'"
|
||||
icon="User" text type="primary" @click="faceManageRef.openDialog(row.userId)">
|
||||
人脸管理
|
||||
</el-button>
|
||||
<el-button v-if="row.processStatus == 1" type="primary" size="small" link icon="VideoPlay" @click="deal(row)">
|
||||
<el-button v-if="row.processStatus == 1" type="primary" size="small" link
|
||||
icon="VideoPlay" @click="deal(row)">
|
||||
开始处理
|
||||
</el-button>
|
||||
<!-- 删除用户 -->
|
||||
<el-tooltip content="admin 不允许被删除" :disabled="row.userId !== '1'" placement="top">
|
||||
<span style="margin-left: 12px">
|
||||
<el-button
|
||||
icon="delete"
|
||||
v-auth="'sys_user_del'"
|
||||
:disabled="row.username === 'admin'"
|
||||
text
|
||||
type="primary"
|
||||
@click="handleDelete([row.userId])"
|
||||
>
|
||||
<el-button icon="delete" v-auth="'sys_user_del'"
|
||||
:disabled="row.username === 'admin'" text type="primary"
|
||||
@click="handleDelete([row.userId])">
|
||||
删除
|
||||
</el-button>
|
||||
</span>
|
||||
@@ -204,28 +140,25 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
|
||||
<pagination v-bind="state.pagination" @current-change="currentChangeHandle"
|
||||
@size-change="sizeChangeHandle" />
|
||||
</template>
|
||||
</DraggableDepTree>
|
||||
</div>
|
||||
|
||||
<user-form ref="userDialogRef" @refresh="getDataList(false)" :deptId="state.queryForm.deptId" />
|
||||
<face-manage ref="faceManageRef" @refresh="getDataList(false)" />
|
||||
<upload-excel
|
||||
ref="excelUploadRef"
|
||||
title="用户导入"
|
||||
temp-url="/admin/sys-file/local/file/user.xlsx"
|
||||
url="/admin/user/import-face"
|
||||
@refreshDataList="getDataList"
|
||||
/>
|
||||
<upload-excel ref="excelUploadRef" title="用户导入" temp-url="/admin/sys-file/local/file/user.xlsx"
|
||||
url="/admin/user/import-face" @refreshDataList="getDataList" />
|
||||
|
||||
<!-- 审批抽屉 -->
|
||||
<process-drawer ref="processDrawerRef" @task-submit-event="taskSubmitEvent" />
|
||||
|
||||
<!-- 批量审批对话框 -->
|
||||
<batch-deal ref="batchDealRef" @task-submit-event="taskSubmitEvent" />
|
||||
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess" @failure="handleExportFailure" />
|
||||
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess"
|
||||
@failure="handleExportFailure" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -333,15 +266,15 @@ const taskSubmitEvent = () => {
|
||||
// 导出excel
|
||||
/** 当前页面只声明原导出场景,进度及重复提交由公共 hook 管理。 */
|
||||
const { exportProgressRef, exportTaskConfig, submitExport, handleExportSuccess, handleExportFailure } = useBatchExport({
|
||||
progressUrl: "/admin/async-task/progress", redisKey: "admin:export:user",
|
||||
taskName: "用户管理", fileName: "用户管理.xlsx", submitTask: submitBatchExport,
|
||||
progressUrl: "/admin/async-task/progress", redisKey: "admin:export:user",
|
||||
taskName: "用户管理", fileName: "用户管理.xlsx", submitTask: submitBatchExport,
|
||||
})
|
||||
|
||||
const exportExcel = () => {
|
||||
const query = { ...state.queryForm }
|
||||
// 保留原导出角色参数的转换规则及勾选元数据。
|
||||
query.role = query.role && !Array.isArray(query.role) ? [query.role] : []
|
||||
return submitExport({ ...query, ids: [...selectObjs.value] })
|
||||
const query = { ...state.queryForm }
|
||||
// 保留原导出角色参数的转换规则及勾选元数据。
|
||||
query.role = query.role && !Array.isArray(query.role) ? [query.role] : []
|
||||
return submitExport({ ...query, ids: [...selectObjs.value] })
|
||||
}
|
||||
|
||||
// 是否可以多选
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-image :style="styles" v-bind="props" :src="src.includes('http') ? src : baseURL + src">
|
||||
<file-image :style="styles" v-bind="props" :src="$fileUrl(src)" @error="$fileRetry(src)">
|
||||
<template #placeholder>
|
||||
<div class="image-slot"></div>
|
||||
</template>
|
||||
@@ -8,7 +8,7 @@
|
||||
<el-icon><Picture /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
</el-image>
|
||||
</file-image>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="flex items-center news-title mx-[10px] my-[15px] text-[17px] font-medium">最新资讯</div>
|
||||
<div v-for="item in newsList" :key="item.id" class="news-card flex bg-white px-[10px] py-[16px] text-[#333] border-[#f2f2f2] border-b">
|
||||
<div class="mr-[10px]" v-if="item.image">
|
||||
<img :src="item.image.includes('http') ? item.image : baseURL + item.image" class="w-[120px] h-[90px]" />
|
||||
<img :src="$fileUrl(item.image)" class="w-[120px] h-[90px]" @error="$fileRetry(item.image)" />
|
||||
</div>
|
||||
<div class="flex flex-col justify-between flex-1">
|
||||
<div class="text-[15px] font-medium line-clamp-2">{{ item.title }}</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="pages-preview mx-[30px]">
|
||||
<div class="flex tabbar dark:bg-gray-700">
|
||||
<div class="flex flex-col items-center justify-center flex-1 tabbar-item" v-for="(item, index) in tabbar.list" :key="index">
|
||||
<img class="w-[22px] h-[22px]" :src="item.unselected.includes('http') ? item.unselected: baseURL + item.unselected" alt="" />
|
||||
<img class="w-[22px] h-[22px]" :src="$fileUrl(item.unselected)" alt="" @error="$fileRetry(item.unselected)" />
|
||||
<div class="leading-3 text-[12px] mt-[4px] dark:text-gray-300">{{ item.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -75,10 +75,10 @@
|
||||
</div>
|
||||
<div v-if="scope.row.repType === 'text'">{{ scope.row.repContent }}</div>
|
||||
<div v-if="scope.row.repType === 'image'">
|
||||
<a target="_blank" :href="scope.row.repUrl"><img :src="scope.row.repUrl" style="width: 100px" /></a>
|
||||
<a target="_blank" :href="$fileUrl(scope.row.repUrl)"><img :src="$fileUrl(scope.row.repUrl)" style="width: 100px" @error="$fileRetry(scope.row.repUrl)" /></a>
|
||||
</div>
|
||||
<div v-if="['video', 'voice', 'link', 'shortvideo'].includes(scope.row.repType)">
|
||||
<el-tag>链接</el-tag>:<a :href="scope.row.repUrl" target="_blank">{{ scope.row.repName }}</a>
|
||||
<el-tag>链接</el-tag>:<a :href="$fileUrl(scope.row.repUrl)" target="_blank">{{ scope.row.repName }}</a>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div v-for="(news, index) in articlesAdd" :key="news.id">
|
||||
<div v-if="index == 0" class="news-main father" :class="{ activeAddNews: isActiveAddNews === index }" @click="activeNews(index)">
|
||||
<div class="news-content">
|
||||
<img v-if="news.thumbUrl" class="material-img" :src="news.thumbUrl" />
|
||||
<img v-if="news.thumbUrl" class="material-img" :src="$fileUrl(news.thumbUrl)" @error="$fileRetry(news.thumbUrl)" />
|
||||
<div class="news-content-title">{{ news.title }}</div>
|
||||
</div>
|
||||
<div v-if="articlesAdd.length > 1" class="child">
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="news-content-item">
|
||||
<div class="news-content-item-title">{{ news.title }}</div>
|
||||
<div class="news-content-item-img">
|
||||
<img v-if="news.thumbUrl" class="material-img" :src="news.thumbUrl" height="100%" />
|
||||
<img v-if="news.thumbUrl" class="material-img" :src="$fileUrl(news.thumbUrl)" height="100%" @error="$fileRetry(news.thumbUrl)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="child">
|
||||
@@ -52,9 +52,9 @@
|
||||
<img
|
||||
v-if="articlesAdd[isActiveAddNews].thumbUrl"
|
||||
class="material-img"
|
||||
:src="articlesAdd[isActiveAddNews].thumbUrl"
|
||||
:src="$fileUrl(articlesAdd[isActiveAddNews].thumbUrl)"
|
||||
:class="isActiveAddNews === 0 ? 'avatar' : 'avatar1'"
|
||||
/>
|
||||
@error="$fileRetry(articlesAdd[isActiveAddNews].thumbUrl)" />
|
||||
<i v-else class="el-icon-plus avatar-uploader-icon" :class="isActiveAddNews === 0 ? 'avatar' : 'avatar1'"></i>
|
||||
<div class="thumb-but">
|
||||
<wx-file-upload :uploadData="uploadData" @success="handleImageChange"></wx-file-upload>
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
</div>
|
||||
<div v-loading="state.loading" class="waterfall">
|
||||
<div v-for="item in state.dataList" :key="item.id" class="waterfall-item">
|
||||
<a target="_blank" :href="item.url">
|
||||
<img class="material-img" :src="item.url" />
|
||||
<a target="_blank" :href="$fileUrl(item.url)">
|
||||
<img class="material-img" :src="$fileUrl(item.url)" @error="$fileRetry(item.url)" />
|
||||
<div class="item-name">{{ item.name }}</div>
|
||||
</a>
|
||||
<el-row class="ope-row">
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<td v-if="!loading" class="text-center" @click="addFood(1)">早餐</td>
|
||||
<div class="food_list">
|
||||
<td class="food_list_item" v-for="(item, index) in foodData1" :key="index" @click="delteData(item.tid)">
|
||||
<el-image style="width: 80px; height: 80px" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
@@ -56,7 +56,7 @@
|
||||
<td v-if="!loading" class="text-center" @click="addFood(2)">中餐</td>
|
||||
<div class="food_list">
|
||||
<td class="food_list_item" v-for="(item, index) in foodData2" :key="index" @click="delteData(item.tid)">
|
||||
<el-image style="width: 80px; height: 80px" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
@@ -70,7 +70,7 @@
|
||||
<td v-if="!loading" class="text-center" @click="addFood(3)">晚餐</td>
|
||||
<div class="food_list">
|
||||
<td class="food_list_item" v-for="(item, index) in foodData3" :key="index" @click="delteData(item.tid)">
|
||||
<el-image style="width: 80px; height: 80px" loading="lazy" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" loading="lazy" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
>
|
||||
<CircleClose />
|
||||
</el-icon>
|
||||
<el-image style="width: 80px; height: 80px" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<td v-if="!loading" class="text-center" @click="addFood(1)">早餐</td>
|
||||
<div class="food_list">
|
||||
<td class="food_list_item" v-for="(item, index) in foodData1" :key="index" @click="delteData(item.tid)">
|
||||
<el-image style="width: 80px; height: 80px" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
@@ -55,7 +55,7 @@
|
||||
<td v-if="!loading" class="text-center" @click="addFood(2)">中餐</td>
|
||||
<div class="food_list">
|
||||
<td class="food_list_item" v-for="(item, index) in foodData2" :key="index" @click="delteData(item.tid)">
|
||||
<el-image style="width: 80px; height: 80px" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
@@ -69,7 +69,7 @@
|
||||
<td v-if="!loading" class="text-center" @click="addFood(3)">晚餐</td>
|
||||
<div class="food_list">
|
||||
<td class="food_list_item" v-for="(item, index) in foodData3" :key="index" @click="delteData(item.tid)">
|
||||
<el-image style="width: 80px; height: 80px" loading="lazy" :src="imageBaseUrl + item.picUrl" fit="cover" />
|
||||
<file-image style="width: 80px; height: 80px" loading="lazy" :src="$fileUrl(imageBaseUrl + item.picUrl)" fit="cover" @error="$fileRetry(imageBaseUrl + item.picUrl)" />
|
||||
<div class="w-full flex justify-around items-center text-black mt-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="mx-1">|</span>
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
<div class="w-full flex flex-wrap items-center" v-for="(hourType, index) in foodData" :key="index">
|
||||
<div v-for="dish in hourType" :key="dish.id" class="p-2" :style="cardStyle">
|
||||
<div class="relative overflow-hidden rounded-tl rounded-tr" :style="foodCardStyle">
|
||||
<img :src="imageBaseUrl + dish.picUrl" :alt="dish.name"
|
||||
class="h-full w-full object-cover" />
|
||||
<img :src="$fileUrl(imageBaseUrl + dish.picUrl)" :alt="dish.name"
|
||||
class="h-full w-full object-cover" @error="$fileRetry(imageBaseUrl + dish.picUrl)" />
|
||||
<div class="ribbon">午餐</div>
|
||||
<div class="absolute left-1 top-1">
|
||||
<star-medal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="form.perm === 'R'" v-html="form.props.value" />
|
||||
<div v-if="form.perm === 'R'" v-html="$fileHtml(form.props.value)" />
|
||||
<editor v-else v-model:get-html="form.props.value" :placeholder="form.placeholder" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div v-if="form.perm === 'R'">
|
||||
<img :src="form.props.value" />
|
||||
<img :src="$fileUrl(form.props.value)" @error="$fileRetry(form.props.value)" />
|
||||
</div>
|
||||
<div v-else>
|
||||
<sign
|
||||
|
||||
@@ -734,10 +734,10 @@
|
||||
class="flex min-h-[180px] gap-4 rounded-[6px] border border-[var(--el-border-color-light)] bg-[var(--el-fill-color-blank)] p-3">
|
||||
<div
|
||||
class="flex h-[156px] w-40 flex-none items-center justify-center overflow-hidden rounded bg-[var(--el-fill-color-light)]">
|
||||
<el-image
|
||||
<file-image
|
||||
v-if="evidence.status === 'AVAILABLE' && evidence.imageUrl && !failedEvidenceImages.has(evidence.id)"
|
||||
class="h-full w-full" :src="evidenceImageUrl(evidence.imageUrl)"
|
||||
:preview-src-list="[evidenceImageUrl(evidence.imageUrl)]" fit="contain"
|
||||
class="h-full w-full" :src="$fileUrl(evidenceImageUrl(evidence.imageUrl))"
|
||||
:preview-src-list="$fileUrls([evidenceImageUrl(evidence.imageUrl)])" fit="contain"
|
||||
preview-teleported loading="lazy"
|
||||
@error="markEvidenceImageFailed(evidence.id)" />
|
||||
<span v-else-if="evidence.status === 'PENDING'"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:class="['nav-menu-item-top', item.id == currentActiveMenuId ? 'nav-menu-item-active' : '']"
|
||||
@click="handleClickMenvLevel1(item)"
|
||||
>
|
||||
<el-image class="nav-menu-item-icon" :src="imageBaseUrl + item.menuPic" fit="cover" />
|
||||
<file-image class="nav-menu-item-icon" :src="$fileUrl(imageBaseUrl + item.menuPic)" fit="cover" @error="$fileRetry(imageBaseUrl + item.menuPic)" />
|
||||
<div class="nav-menu-item-name">{{ $t(item.name) }}</div>
|
||||
</div>
|
||||
</el-col>
|
||||
@@ -27,7 +27,7 @@
|
||||
:class="['nav-menu-item-bottom', item.id == curLevel2ActiveMenuId ? 'nav-menu-item-active' : '']"
|
||||
@click="handleClickBottomMenu(item)"
|
||||
>
|
||||
<el-image class="nav-menu-item-icon" :src="imageBaseUrl + item.menuPic" fit="cover" />
|
||||
<file-image class="nav-menu-item-icon" :src="$fileUrl(imageBaseUrl + item.menuPic)" fit="cover" @error="$fileRetry(imageBaseUrl + item.menuPic)" />
|
||||
<div class="nav-menu-item-name">
|
||||
{{ $t(item.name) }}
|
||||
<el-icon v-if="item.children?.length > 0"><CaretBottom /></el-icon>
|
||||
@@ -47,7 +47,7 @@
|
||||
:key="index"
|
||||
>
|
||||
<div v-if="!item.meta?.isHide" class="nav-menu-item-bottom" @click="handleClickNavMenuLevel3(item)">
|
||||
<el-image class="nav-menu-item-icon" :src="imageBaseUrl + item.menuPic" fit="cover" />
|
||||
<file-image class="nav-menu-item-icon" :src="$fileUrl(imageBaseUrl + item.menuPic)" fit="cover" @error="$fileRetry(imageBaseUrl + item.menuPic)" />
|
||||
<div class="nav-menu-item-name">{{ $t(item.name) }}</div>
|
||||
</div>
|
||||
</el-col>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="text-center">
|
||||
<p class="text-xs text-gray-600 text-center mt-8">© {{ currentNew.createBy }} {{ currentNew.createTime }}</p>
|
||||
</div>
|
||||
<p class="text-sm text-gray-600 text-justify mt-8 mb-6" v-html="currentNew.content"></p>
|
||||
<p class="text-sm text-gray-600 text-justify mt-8 mb-6" v-html="$fileHtml(currentNew.content)"></p>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
@@ -10,7 +10,7 @@ export default {
|
||||
<el-card class="flex items-center justify-center h-[191px]">
|
||||
<div class="flex items-center justify-center">
|
||||
<div class="relative">
|
||||
<img class="object-cover w-16 h-16 rounded-full" :src="userData.avatar" alt="Avatar" />
|
||||
<img class="object-cover w-16 h-16 rounded-full" :src="$fileUrl(userData.avatar)" alt="Avatar" @error="$fileRetry(userData.avatar)" />
|
||||
<div class="absolute inset-0 rounded-full shadow-inner"></div>
|
||||
</div>
|
||||
<div class="ml-8">
|
||||
@@ -61,7 +61,7 @@ const initUserInfo = async (userId: any): Promise<void> => {
|
||||
userData.value = res.data; // 将查询到的数据保存到 userData 变量中
|
||||
userData.value.postName = res.data?.postList?.map((item: any) => item.postName).join(',') || ''; // 将 postList 中的 postName 合并成字符串并保存到 userData 变量中
|
||||
// 文件上传增加后端前缀
|
||||
userData.value.avatar = proxy.baseURL + res.data.avatar;
|
||||
userData.value.avatar = res.data.avatar;
|
||||
} finally {
|
||||
loading.value = false; // 结束加载状态
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="downloadUrl" label="下载地址" width="220" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link :href="row.downloadUrl" target="_blank" :underline="false">打开</el-link>
|
||||
<el-link :href="$fileUrl(row.downloadUrl)" target="_blank" :underline="false">下载</el-link>
|
||||
<el-divider direction="vertical" />
|
||||
<el-button text type="primary" icon="CopyDocument" @click="copyUrl(row.downloadUrl)">复制</el-button>
|
||||
</template>
|
||||
@@ -89,6 +89,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemAppVersion">
|
||||
import { accessFileUrl, isProtectedFile } from '/@/utils/file-access';
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import * as appVersionApi from "/@/api/integrated/app-version";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
@@ -157,8 +158,8 @@ const handleDelete = async (ids: string[]) => {
|
||||
|
||||
const copyUrl = async (url: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(url || '')
|
||||
useMessage().success('已复制下载链接')
|
||||
await navigator.clipboard.writeText(accessFileUrl(url))
|
||||
useMessage().success(isProtectedFile(url) ? '已复制临时文件地址,请通过应用加载,不支持浏览器直接打开' : '已复制下载链接')
|
||||
} catch (e) {
|
||||
useMessage().error('复制失败')
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<span class="tech-notice-time">{{ item.createTime?.slice(5, 16) }}</span>
|
||||
<span class="tech-notice-title" @click="toggleNoticeDetail(idx)">{{ item.title }}</span>
|
||||
</div>
|
||||
<div v-if=" hasValidDescription(item.description)" class="tech-notice-description" v-html="item.description"></div>
|
||||
<div v-if=" hasValidDescription(item.description)" class="tech-notice-description" v-html="$fileHtml(item.description)"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
</el-col>
|
||||
<el-col :span="1"></el-col>
|
||||
<el-col :span="8">
|
||||
<img :src="imgSrc" @click="getVerifyImageCode" />
|
||||
<img :src="$fileUrl(imgSrc)" @click="getVerifyImageCode" @error="$fileRetry(imgSrc)" />
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
<el-form-item class="mt-4 login-animation4">
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
<div class="relative transition-transform duration-300 transform group-hover:scale-110 group-hover:-translate-y-1">
|
||||
<img
|
||||
class="w-24 h-24 rounded-lg ring-gray-200 dark:ring-slate-700 dark:bg-slate-800"
|
||||
:src="!themeConfig.miniQr ? miniQr : baseURL + themeConfig.miniQr"
|
||||
:src="$fileUrl(!themeConfig.miniQr ? miniQr : themeConfig.miniQr)"
|
||||
:alt="t('scan.wechatApp')"
|
||||
/>
|
||||
@error="$fileRetry(!themeConfig.miniQr ? miniQr : themeConfig.miniQr)" />
|
||||
</div>
|
||||
<!-- 底部文字 -->
|
||||
<div class="mt-2">
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
>
|
||||
<img
|
||||
class="w-[85%] h-auto max-h-[650px] object-contain opacity-100 dark:opacity-75 transition-opacity duration-300 hover:opacity-90"
|
||||
:src="!themeConfig.background ? illustration : baseURL + themeConfig.background"
|
||||
:src="$fileUrl(!themeConfig.background ? illustration : themeConfig.background)"
|
||||
alt="Login illustration"
|
||||
/>
|
||||
@error="$fileRetry(!themeConfig.background ? illustration : themeConfig.background)" />
|
||||
</div>
|
||||
|
||||
<!-- 右侧登录表单区域 -->
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<DraggableDepTree
|
||||
ref="draggableDepTreeRef"
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<DraggableDepTree ref="draggableDepTreeRef" placeholder="请输入部门名称" :show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode" switch-inactive-text="包含" switch-active-text="不包含"
|
||||
:defaultTreeWidth="20" :nodeClickable="false">
|
||||
<template #default>
|
||||
<SearchPanel
|
||||
v-show="showSearch"
|
||||
ref="queryRef"
|
||||
:model="state.queryForm"
|
||||
:loading="Boolean(state.loading)"
|
||||
:search-text="$t('common.queryBtn')"
|
||||
:reset-text="$t('common.resetBtn')"
|
||||
@search="getDataList"
|
||||
@reset="resetQuery"
|
||||
>
|
||||
<SearchPanel v-show="showSearch" ref="queryRef" :model="state.queryForm"
|
||||
:loading="Boolean(state.loading)" :search-text="$t('common.queryBtn')"
|
||||
:reset-text="$t('common.resetBtn')" @search="getDataList" @reset="resetQuery">
|
||||
<el-form-item style="width: 300px" label="用户" prop="userId">
|
||||
<select-user v-model="state.queryForm.userId" />
|
||||
</el-form-item>
|
||||
@@ -39,37 +25,18 @@
|
||||
</SearchPanel>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button
|
||||
plain
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
v-auth="'wallet_walletManage_del'"
|
||||
@click="handleDelete(selectObjs)"
|
||||
>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||
v-auth="'wallet_walletManage_del'" @click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'wallet_walletManage_export'"
|
||||
@exportExcel="exportExcel"
|
||||
class="ml10 mr20"
|
||||
style="float: right"
|
||||
@queryTable="getDataList"
|
||||
></right-toolbar>
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'wallet_walletManage_export'"
|
||||
@exportExcel="exportExcel" class="ml10 mr20" style="float: right"
|
||||
@queryTable="getDataList"></right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="state.loading"
|
||||
border
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
@selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" border :summary-method="getSummaries"
|
||||
show-summary :cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
||||
@selection-change="selectionChangHandle" @sort-change="sortChangeHandle">
|
||||
<el-table-column type="index" label="#" width="60" />
|
||||
<el-table-column prop="username" width="100" label="用户" />
|
||||
<el-table-column prop="userAvatar" width="80" label="头像">
|
||||
@@ -112,58 +79,41 @@
|
||||
</el-table-column>
|
||||
<el-table-column v-if="false" prop="activeBindStatus" width="120" label="饭卡绑定状态" />
|
||||
<el-table-column prop="createTime" width="200" label="创建时间" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
fixed="right"
|
||||
width="250"
|
||||
v-auths="[
|
||||
'wallet_walletManage_edit',
|
||||
'wallet_walletTransaction_update_balance',
|
||||
'wallet_walletRuleTransaction_transfer_accounts',
|
||||
]"
|
||||
>
|
||||
<el-table-column label="操作" fixed="right" width="250" v-auths="[
|
||||
'wallet_walletManage_edit',
|
||||
'wallet_walletTransaction_update_balance',
|
||||
'wallet_walletRuleTransaction_transfer_accounts',
|
||||
]">
|
||||
<template #default="{ row }">
|
||||
<div class="flex items-start">
|
||||
<el-button
|
||||
icon="InfoFilled"
|
||||
text
|
||||
type="primary"
|
||||
v-auth="'wallet_walletManage_edit'"
|
||||
@click="formDialogRef.openDialog(row.id)"
|
||||
>
|
||||
<el-button icon="InfoFilled" text type="primary" v-auth="'wallet_walletManage_edit'"
|
||||
@click="formDialogRef.openDialog(row.id)">
|
||||
详情
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Money"
|
||||
text
|
||||
type="primary"
|
||||
<el-button icon="Money" text type="primary"
|
||||
v-auth="'wallet_walletTransaction_update_balance'"
|
||||
@click="changeBalanceRef.openDialog(row.userId, row.id)"
|
||||
>
|
||||
@click="changeBalanceRef.openDialog(row.userId, row.id)">
|
||||
充值/扣款
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.isRule == 1"
|
||||
icon="SwitchFilled"
|
||||
text
|
||||
type="primary"
|
||||
<el-button v-if="row.isRule == 1" icon="SwitchFilled" text type="primary"
|
||||
v-auth="'wallet_walletRuleTransaction_transfer'"
|
||||
@click="doTransferAccounts(row)"
|
||||
>
|
||||
@click="doTransferAccounts(row)">
|
||||
转账
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
</template>
|
||||
</DraggableDepTree>
|
||||
</div>
|
||||
<transaction-list ref="formDialogRef" @refresh="getDataList(false)" />
|
||||
<change-balance ref="changeBalanceRef" @refresh="getDataList(false)" />
|
||||
<transfer-accounts ref="transferAccountsRef" @refresh="getDataList(false)" />
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess" @failure="handleExportFailure" />
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess"
|
||||
@failure="handleExportFailure" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,82 +1,44 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<DraggableDepTree
|
||||
ref="draggableDepTreeRef"
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<DraggableDepTree ref="draggableDepTreeRef" placeholder="请输入部门名称" :show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode" switch-inactive-text="包含" switch-active-text="不包含"
|
||||
:defaultTreeWidth="20" :nodeClickable="false">
|
||||
<template #default>
|
||||
<SearchPanel
|
||||
v-show="showSearch"
|
||||
ref="queryRef"
|
||||
:model="state.queryForm"
|
||||
:loading="Boolean(state.loading)"
|
||||
:search-text="$t('common.queryBtn')"
|
||||
:reset-text="$t('common.resetBtn')"
|
||||
@search="getDataList"
|
||||
@reset="resetQuery"
|
||||
>
|
||||
<SearchPanel v-show="showSearch" ref="queryRef" :model="state.queryForm"
|
||||
:loading="Boolean(state.loading)" :search-text="$t('common.queryBtn')"
|
||||
:reset-text="$t('common.resetBtn')" @search="getDataList" @reset="resetQuery">
|
||||
<el-form-item style="width: 300px" label="用户" prop="userId">
|
||||
<select-user v-model="state.queryForm.userId" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 250px" label="钱包类型" prop="walletTypeIdList">
|
||||
<select-wallet-type multiple v-model="state.queryForm.walletTypeIdList" placeholder="饭卡类型" clearable />
|
||||
<select-wallet-type multiple v-model="state.queryForm.walletTypeIdList" placeholder="饭卡类型"
|
||||
clearable />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 200px" label="月份" prop="walletRecordMonth">
|
||||
<el-date-picker
|
||||
v-model="state.queryForm.walletRecordMonth"
|
||||
value-format="YYYY-MM"
|
||||
type="month"
|
||||
:clearable="false"
|
||||
placeholder="选择月份"
|
||||
/>
|
||||
<el-date-picker v-model="state.queryForm.walletRecordMonth" value-format="YYYY-MM"
|
||||
type="month" :clearable="false" placeholder="选择月份" />
|
||||
</el-form-item>
|
||||
</SearchPanel>
|
||||
<el-row>
|
||||
<div class="mb8 flex justify-between" style="width: 100%">
|
||||
<el-button
|
||||
plain
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
v-auth="'wallet_walletManage_del'"
|
||||
@click="handleDelete(selectObjs)"
|
||||
>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||
v-auth="'wallet_walletManage_del'" @click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<div class="flex gap-5">
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'wallet_walletRecord_export'"
|
||||
@exportExcel="exportExcel"
|
||||
class="ml10 mr20"
|
||||
style="float: right"
|
||||
@queryTable="getDataList"
|
||||
>
|
||||
<el-tooltip class="item" effect="dark" content="统计" placement="top">
|
||||
<el-button icon="DataLine" circle :loading="balanceStatisticsLoading" @click="viewBalanceStatistics" />
|
||||
</el-tooltip>
|
||||
</right-toolbar>
|
||||
</div>
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'wallet_walletRecord_export'"
|
||||
@exportExcel="exportExcel" class="ml10 mr20" style="float: right"
|
||||
@queryTable="getDataList">
|
||||
<el-tooltip class="item" effect="dark" content="统计" placement="top">
|
||||
<el-button icon="DataLine" circle :loading="balanceStatisticsLoading"
|
||||
@click="viewBalanceStatistics" />
|
||||
</el-tooltip>
|
||||
</right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="state.loading"
|
||||
border
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
@selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" border :summary-method="getSummaries"
|
||||
show-summary :cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
||||
@selection-change="selectionChangHandle" @sort-change="sortChangeHandle">
|
||||
<el-table-column type="index" label="#" width="60" />
|
||||
<el-table-column prop="username" width="120" label="用户" />
|
||||
<el-table-column prop="userAvatar" width="80" label="头像">
|
||||
@@ -115,18 +77,15 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
</template>
|
||||
</DraggableDepTree>
|
||||
</div>
|
||||
|
||||
<el-drawer v-model="showDrawer" @close="drawerClose">
|
||||
<el-table
|
||||
v-loading="balanceStatisticsLoading"
|
||||
:data="balanceStatisticsLoaded ? [balanceStatistics] : []"
|
||||
:empty-text="balanceStatisticsLoading ? '统计中…' : '暂无统计数据'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table v-loading="balanceStatisticsLoading" :data="balanceStatisticsLoaded ? [balanceStatistics] : []"
|
||||
:empty-text="balanceStatisticsLoading ? '统计中…' : '暂无统计数据'" style="width: 100%">
|
||||
<el-table-column align="center" label="余额统计">
|
||||
<el-table-column align="center" prop="total" label="总余额">
|
||||
<template #default="{ row }">
|
||||
@@ -151,7 +110,8 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess" @failure="handleExportFailure" />
|
||||
<async-task-progress-component ref="exportProgressRef" :config="exportTaskConfig" @success="handleExportSuccess"
|
||||
@failure="handleExportFailure" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
[
|
||||
{
|
||||
"fileName": "a.jpg",
|
||||
"appId": "mini",
|
||||
"kid": "v1",
|
||||
"ts": 1793232000,
|
||||
"key": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
|
||||
"canonical": "v1\noss-file-read\nmini\nv1\n1793232000\nYS5qcGc",
|
||||
"sign": "348b1a5dd5d20560b7537916a6ec525efd173ccc1ee4af5357ca634f26296eb4"
|
||||
},
|
||||
{
|
||||
"fileName": "照片 +&%.png",
|
||||
"appId": "admin",
|
||||
"kid": "v1",
|
||||
"ts": 1793232000,
|
||||
"key": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
|
||||
"canonical": "v1\noss-file-read\nadmin\nv1\n1793232000\n54Wn54mHICsmJS5wbmc",
|
||||
"sign": "9cdaa97a00bf333cf7af13cd915147d474367ef66c9a46adba27f2cbf910ea41"
|
||||
},
|
||||
{
|
||||
"fileName": "literal%2Fname.apk",
|
||||
"appId": "package",
|
||||
"kid": "v1",
|
||||
"ts": 1793232000,
|
||||
"key": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
|
||||
"canonical": "v1\noss-file-read\npackage\nv1\n1793232000\nbGl0ZXJhbCUyRm5hbWUuYXBr",
|
||||
"sign": "a28e0b9ec5854749128b0413f0d97c425b8ee785c0c53b41f4469ee509c37e10"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,67 @@
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
const fs = require("node:fs")
|
||||
const path = require("node:path")
|
||||
const ts = require("typescript")
|
||||
const vue = require("vue")
|
||||
const { parse, compileScript, compileTemplate } = require("@vue/compiler-sfc")
|
||||
const root = path.join(__dirname, "../src")
|
||||
|
||||
function load(source, mocks, globals = {}) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2021 },
|
||||
}).outputText
|
||||
const mod = { exports: {} }
|
||||
new Function("module", "exports", "require", ...Object.keys(globals), compiled)(mod, mod.exports,
|
||||
key => key in mocks ? mocks[key] : require(key), ...Object.values(globals))
|
||||
return mod.exports
|
||||
}
|
||||
|
||||
test("部门导出提交名称筛选快照,复用人员导出的进度和下载流程", async () => {
|
||||
const requests = []
|
||||
const progress = []
|
||||
const downloads = []
|
||||
const submitted = { taskId: "a".repeat(32), redisKey: "admin:export:dept", status: "PENDING" }
|
||||
const request = options => { requests.push(options); return Promise.resolve({ data: submitted }) }
|
||||
const tasks = load(fs.readFileSync(path.join(root, "api/asyncTask.ts"), "utf8"), {
|
||||
"/@/utils/request": { default: request },
|
||||
})
|
||||
const api = load(fs.readFileSync(path.join(root, "api/admin/dept.ts"), "utf8"), {
|
||||
"/@/utils/request": { default: request }, "/@/api/asyncTask": tasks,
|
||||
})
|
||||
const hook = load(fs.readFileSync(path.join(root, "hooks/batchExport.ts"), "utf8"), {
|
||||
vue, "/@/components/AsyncTaskProgress.vue": {},
|
||||
"/@/hooks/message": { useMessage: () => ({ error: message => assert.fail(message) }) },
|
||||
"/@/utils/exportDownload": { downloadExportFile: (...args) => downloads.push(args) },
|
||||
})
|
||||
const descriptor = parse(fs.readFileSync(path.join(root, "views/admin/system/dept/index.vue"), "utf8")).descriptor
|
||||
assert.deepEqual(compileTemplate({ source: descriptor.template.content, filename: "dept.vue", id: "dept" }).errors, [])
|
||||
const page = load(compileScript(descriptor, { id: "dept" }).content, {
|
||||
vue, "/@/api/admin/dept": api,
|
||||
"/@/components/AsyncTaskProgress.vue": {}, "/@/hooks/batchExport": hook,
|
||||
"vue-i18n": { useI18n: () => ({ t: key => key }) },
|
||||
"/@/stores/userInfo": { useUserInfo: () => ({ userInfos: { roleCodes: [] } }) },
|
||||
}, { ref: vue.ref, reactive: vue.reactive, defineAsyncComponent: vue.defineAsyncComponent })
|
||||
const state = page.default.setup({}, { expose() {} })
|
||||
state.exportProgressRef.value = {
|
||||
startSubmitting: name => progress.push(name), start: value => progress.push(value),
|
||||
show: () => progress.push("show"), submissionFailed: message => assert.fail(message),
|
||||
}
|
||||
state.state.queryForm.deptName = "人事"
|
||||
await state.exportExcel()
|
||||
assert.equal(requests.length, 1)
|
||||
assert.equal(requests[0].url, "/admin/dept/export-async")
|
||||
assert.equal(requests[0].method, "post")
|
||||
assert.deepEqual(requests[0].data, { deptName: "人事" })
|
||||
assert.equal(state.state.queryForm.deptName, "人事")
|
||||
assert.equal(state.exportTaskConfig.progressUrl, "/admin/async-task/progress")
|
||||
assert.equal(state.exportTaskConfig.redisKey, "admin:export:dept")
|
||||
assert.deepEqual(progress, ["部门管理", submitted])
|
||||
state.state.queryForm.deptName = "财务"
|
||||
await state.exportExcel()
|
||||
assert.equal(requests.length, 1)
|
||||
assert.equal(requests[0].data.deptName, "人事")
|
||||
assert.equal(progress.at(-1), "show")
|
||||
state.handleExportSuccess({ resultFileUrl: "/admin/sys-file/oss/file?fileName=depts.xlsx", resultFileName: "部门管理.xlsx" })
|
||||
assert.deepEqual(downloads, [["/admin/sys-file/oss/file?fileName=depts.xlsx", "部门管理.xlsx"]])
|
||||
})
|
||||
@@ -0,0 +1,131 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const Module = require('node:module');
|
||||
const ts = require('typescript');
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const corePath = fs.existsSync(path.join(root, 'src/utils/file-access-core.ts'))
|
||||
? path.join(root, 'src/utils/file-access-core.ts') : path.join(root, 'src/sheep/utils/file-access-core.ts');
|
||||
const loaded = new Module(corePath, module);
|
||||
loaded.filename = corePath; loaded.paths = Module._nodeModulePaths(path.dirname(corePath));
|
||||
loaded._compile(ts.transpileModule(fs.readFileSync(corePath, 'utf8'), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 } }).outputText, corePath);
|
||||
const { fileAccessSignature, fileAccessCanonical, createFileAccess, rewriteFileHtml, rewriteFileNodes } = loaded.exports;
|
||||
const vectors = JSON.parse(fs.readFileSync(path.join(root, 'test-vectors/file-access.json'), 'utf8'));
|
||||
for (const v of vectors) test('cross-language vector: ' + v.fileName, () => {
|
||||
assert.equal(fileAccessCanonical(v.fileName,v.appId,v.kid,v.ts),v.canonical);
|
||||
assert.equal(fileAccessSignature(v.fileName,v.appId,v.kid,v.ts,v.key),v.sign);
|
||||
});
|
||||
let time;
|
||||
function client(baseUrl='https://files.example/api') {
|
||||
time = 1793232000000;
|
||||
return createFileAccess({appId:'mini',kid:'v1',key:vectors[0].key,baseUrl:()=>baseUrl,now:()=>time,allowedOrigins:['https://legacy.example']});
|
||||
}
|
||||
test('prefixes, absolute URLs, and bare names address the same file',()=>{
|
||||
const c=client();
|
||||
for(const value of ['/admin/sys-file/oss/file?fileName=a.jpg','/api/admin/sys-file/oss/file?fileName=a.jpg','https://files.example/api/admin/sys-file/oss/file?fileName=a.jpg','a.jpg']) {
|
||||
const url=c.url(value); assert.match(url,/^https:\/\/files.example\/api\/admin\/sys-file\/oss\/file\?/);
|
||||
assert.equal(new URL(url).searchParams.get('sign'),vectors[0].sign);
|
||||
assert.ok(url.endsWith('fileName=a.jpg'));
|
||||
}
|
||||
});
|
||||
test('relative API base, no duplicate prefixes',()=>{
|
||||
const c=client('/api'); assert.match(c.url('/api/admin/sys-file/oss/file?fileName=a.jpg'),/^\/api\/admin/);
|
||||
});
|
||||
test('foreign URLs and local resources never receive credentials',()=>{
|
||||
const c=client();
|
||||
for(const value of ['https://other.example/admin/sys-file/oss/file?fileName=a.jpg','https://files.example.evil/api/admin/sys-file/oss/file?fileName=a.jpg','data:image/png;base64,AA==','blob:https://files.example/abc','/static/logo.png','https://files.example/qiniu/a.jpg']) assert.equal(c.url(value),value);
|
||||
});
|
||||
test('one decode, unusual names, no duplicated signature and cache renewal',()=>{
|
||||
const c=client(), name='照片 +&%.png', source='/admin/sys-file/oss/file?fileName='+encodeURIComponent(name);
|
||||
const first=c.url(source), params=new URL(first).searchParams;
|
||||
assert.equal(params.get('fileName'),name); assert.equal(params.get('sign'),fileAccessSignature(name,'mini','v1',1793232000,vectors[0].key));
|
||||
assert.equal(c.url(first),first); time+=10*60000; assert.equal(c.url(source),first);
|
||||
time+=16*60000; const renewed=c.url(source); assert.notEqual(renewed,first);
|
||||
assert.equal(c.strip(first),c.strip(renewed)); assert.equal(c.strip(source),source);
|
||||
});
|
||||
test('reject ambiguous file names and never silently use an empty key',()=>{
|
||||
const c=client(); assert.throws(()=>c.url('/admin/sys-file/oss/file?fileName=a&fileName=b'));
|
||||
assert.throws(()=>c.url('/admin/sys-file/oss/file?fileName='));
|
||||
assert.throws(()=>fileAccessSignature('a','mini','v1',1,''));
|
||||
});
|
||||
test('clock correction renews a skewed signature',()=>{
|
||||
const c=client();time+=86400000;c.synchronize(1793232000000,1800,0);
|
||||
assert.equal(new URL(c.url('a.jpg')).searchParams.get('ts'),'1793232000');
|
||||
});
|
||||
test('routine clock synchronization preserves usable signatures and corrects large clock changes', () => {
|
||||
const c = client(), first = c.url('a.jpg');
|
||||
time += 2000; c.synchronize(time + 4000, 1800, 0);
|
||||
assert.equal(c.url('a.jpg'), first);
|
||||
c.synchronize(time + 86400000, 1800, 0);
|
||||
assert.notEqual(c.url('a.jpg'), first);
|
||||
});
|
||||
test('HTML and rich-text nodes sign for presentation without mutating business values',()=>{
|
||||
const c=client(), html='<p>hello</p><img src="/api/admin/sys-file/oss/file?fileName=a.jpg"><a href="https://other.example/a">x</a>';
|
||||
const transform=s=>c.protected(s)?c.url(s):s;
|
||||
const rendered=rewriteFileHtml(html,transform);assert.match(rendered,/&sign=/);assert.match(rendered,/href="https:\/\/other.example\/a"/);
|
||||
const saved=rewriteFileHtml(rendered,s=>c.strip(s));assert.doesNotMatch(saved,/[?&](?:amp;)?(?:sign|ts|kid|appId)=/);assert.match(saved,/fileName=a.jpg/);
|
||||
const nodes=[{name:'img',attrs:{src:'/api/admin/sys-file/oss/file?fileName=a.jpg'}}], before=JSON.stringify(nodes);
|
||||
assert.match(rewriteFileNodes(nodes,transform)[0].attrs.src,/sign=/);assert.equal(JSON.stringify(nodes),before);
|
||||
});
|
||||
|
||||
test('configured deployment prefixes and encoded parameter names remain unambiguous', () => {
|
||||
const c = client('https://files.example/gateway/api');
|
||||
const relative = '/gateway/api/admin/sys-file/oss/file?%66ileName=a.jpg';
|
||||
const url = c.url(relative);
|
||||
assert.equal(new URL(url).pathname, '/gateway/api/admin/sys-file/oss/file');
|
||||
assert.equal(new URL(url).searchParams.get('sign'), vectors[0].sign);
|
||||
assert.equal(c.url(url), url);
|
||||
assert.throws(() => c.url(relative + '&fileName=b.jpg'));
|
||||
const special = c.url('/admin/sys-file/oss/file?fileName=a%252Bb.png');
|
||||
assert.equal(new URL(special).searchParams.get('fileName'), 'a%2Bb.png');
|
||||
});
|
||||
|
||||
test('real runtime wrapper initializes, calibrates without login, and renews reactively', async () => {
|
||||
const { computed } = require('vue');
|
||||
const filename = path.join(path.dirname(corePath), 'file-access.ts');
|
||||
const env = {
|
||||
VITE_FILE_ACCESS_APP_ID: 'mini', VITE_FILE_ACCESS_KEY_ID: 'v1', VITE_FILE_ACCESS_KEY: vectors[0].key,
|
||||
VITE_IMAGE_BASE_PATH: 'https://files.example/api', VITE_IMAGE_DEV_PATH: 'https://files.example/api',
|
||||
VITE_APP_DEV_SERVICE: 'https://files.example/api', VITE_APP_PROD_IMAGE: 'https://files.example/api',
|
||||
VITE_APP_PROD_SERVICE: 'https://files.example/api', VITE_FILE_ACCESS_ALLOWED_ORIGINS: 'https://legacy.example',
|
||||
};
|
||||
const runtime = new Module(filename, module); runtime.filename = filename; runtime.paths = loaded.paths;
|
||||
runtime.require = (name) => name === './file-access-core' ? loaded.exports : name === './app' ? { isDevEnv: () => true } : loaded.require(name);
|
||||
const source = fs.readFileSync(filename, 'utf8').replace(/import\.meta\.env/g, '(' + JSON.stringify(env) + ')');
|
||||
const originalFetch = global.fetch, originalUni = global.uni, realNow = Date.now;
|
||||
const serverTime = realNow() + 86400000;
|
||||
const info = { data: { serverTime, ttlSeconds: 1800 } };
|
||||
global.fetch = async (url, options) => {
|
||||
assert.equal(url, 'https://files.example/api/admin/sys-file/oss/access-info');
|
||||
assert.equal(options.credentials, 'omit'); return { ok: true, json: async () => info };
|
||||
};
|
||||
global.uni = { request: options => { assert.match(options.url, /oss\/access-info$/); options.success({ statusCode: 200, data: info }); } };
|
||||
let elapsed = 0;
|
||||
Date.now = () => realNow() + elapsed;
|
||||
try {
|
||||
runtime._compile(ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 } }).outputText, filename);
|
||||
const api = runtime.exports, raw = '/admin/sys-file/oss/file?fileName=a.jpg';
|
||||
const shown = computed(() => api.accessFileUrl(raw));
|
||||
const first = shown.value;
|
||||
assert.match(first, /sign=/);
|
||||
assert.match(api.accessFileUrl('https://legacy.example/api/admin/sys-file/oss/file?fileName=a.jpg'), /sign=/);
|
||||
await api.refreshFileAccess(true);
|
||||
assert.equal(Number(new URL(shown.value).searchParams.get('ts')), Math.floor(serverTime / 1000));
|
||||
const calibrated = shown.value;
|
||||
elapsed = 26 * 60000;
|
||||
api.fileAccessRevision.value++;
|
||||
assert.notEqual(shown.value, calibrated);
|
||||
assert.equal(api.originalFileUrl(shown.value), api.originalFileUrl(first));
|
||||
assert.equal(raw, '/admin/sys-file/oss/file?fileName=a.jpg');
|
||||
assert.equal(api.accessFileUrl('/static/logo.png'), '/static/logo.png');
|
||||
assert.equal(api.accessFileUrl('blob:https://files.example/test'), 'blob:https://files.example/test');
|
||||
} finally { global.fetch = originalFetch; global.uni = originalUni; Date.now = realNow; }
|
||||
});
|
||||
|
||||
test('frontend proxy /api is normalized to the configured file-server prefix', () => {
|
||||
const c = client('https://files.example');
|
||||
assert.equal(new URL(c.url('/api/admin/sys-file/oss/file?fileName=a.jpg')).pathname, '/admin/sys-file/oss/file');
|
||||
assert.equal(c.resolve('/api/admin/sys-file/oss/access-info'), 'https://files.example/admin/sys-file/oss/access-info');
|
||||
assert.equal(new URL(c.url('https://legacy.example/api/admin/sys-file/oss/file?fileName=a.jpg')).pathname, '/api/admin/sys-file/oss/file');
|
||||
});
|
||||
@@ -0,0 +1,164 @@
|
||||
const { test } = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const vue = require('vue')
|
||||
const { parse, compileScript } = require('@vue/compiler-sfc')
|
||||
const { runtime, compile, root } = require('./helpers/file-access-runtime.cjs')
|
||||
|
||||
const raw = file => '/admin/sys-file/oss/file?fileName=' + file
|
||||
const settle = async () => { await new Promise(resolve => setImmediate(resolve)); await vue.nextTick() }
|
||||
|
||||
function mountImages(api) {
|
||||
const descriptor = parse(fs.readFileSync(path.join(root, 'src/components/FileImage/index.vue'), 'utf8')).descriptor
|
||||
const component = compileScript(descriptor, { id: 'file-image-regression', inlineTemplate: true }).content
|
||||
const loaded = { exports: {} }
|
||||
const loads = [], failures = []
|
||||
// Element Plus restarts loading when its src prop changes. Record that boundary
|
||||
// while executing the real wrapper's setup, template, events and Vue lifecycle.
|
||||
const ElImage = vue.defineComponent({
|
||||
props: ['src', 'previewSrcList'], emits: ['load', 'error', 'show', 'switch', 'close'],
|
||||
setup(props, { emit }) {
|
||||
vue.watch(() => props.src, value => loads.push(value), { immediate: true })
|
||||
return () => vue.h('img', {
|
||||
src: props.src, preview: props.previewSrcList,
|
||||
onLoad: event => emit('load', event), onError: event => emit('error', event),
|
||||
onShow: () => emit('show'), onSwitch: index => emit('switch', index),
|
||||
})
|
||||
},
|
||||
})
|
||||
new Function('module', 'exports', 'require', compile(component))(loaded, loaded.exports, id => {
|
||||
if (id === 'element-plus') return { ElImage }
|
||||
if (id === '/@/utils/file-access') return api
|
||||
return require(id)
|
||||
})
|
||||
const renderer = vue.createRenderer({
|
||||
createElement: type => ({ type, props: {}, children: [] }), createText: text => ({ text }), createComment: text => ({ text }),
|
||||
setText: (node, text) => { node.text = text }, setElementText: (node, text) => { node.text = text },
|
||||
parentNode: node => node.parent, nextSibling: node => node.parent?.children[node.parent.children.indexOf(node) + 1],
|
||||
patchProp: (node, key, previous, next) => { node.props[key] = next },
|
||||
insert(node, parent, anchor) {
|
||||
if (node.parent) node.parent.children.splice(node.parent.children.indexOf(node), 1)
|
||||
node.parent = parent
|
||||
const index = anchor ? parent.children.indexOf(anchor) : -1
|
||||
parent.children.splice(index < 0 ? parent.children.length : index, 0, node)
|
||||
},
|
||||
remove(node) { if (node.parent) node.parent.children.splice(node.parent.children.indexOf(node), 1) },
|
||||
})
|
||||
const sources = vue.ref([raw('good.jpg'), raw('other.jpg')])
|
||||
const container = { children: [] }
|
||||
const app = renderer.createApp({
|
||||
setup() {
|
||||
return () => vue.h('section', sources.value.map((source, index) => vue.h(loaded.exports.default, {
|
||||
key: index, src: api.accessFileUrl(source), previewSrcList: api.fileUrls([source]),
|
||||
onError: () => failures.push(index),
|
||||
})))
|
||||
},
|
||||
})
|
||||
app.mount(container)
|
||||
return { loads, failures, sources, images: () => container.children[0].children, close: () => app.unmount() }
|
||||
}
|
||||
|
||||
test('one failed image renews only itself, coalesces concurrent retries, and remains bounded', async () => {
|
||||
const env = runtime(), { api, clock } = env
|
||||
try {
|
||||
const good = api.fileUrl(raw('good.jpg')), bad = api.fileUrl(raw('missing.jpg'))
|
||||
clock.now += 1000
|
||||
assert.deepEqual(await Promise.all([api.retryFileAccess(raw('missing.jpg')), api.retryFileAccess(raw('missing.jpg'))]), [true, true])
|
||||
assert.equal(clock.requests, 1)
|
||||
assert.equal(api.fileUrl(raw('good.jpg')), good)
|
||||
assert.notEqual(api.fileUrl(raw('missing.jpg')), bad)
|
||||
assert.equal(await api.retryFileAccess(raw('missing.jpg')), false)
|
||||
assert.equal(clock.requests, 1)
|
||||
const offline = api.fileUrl(raw('offline.jpg'))
|
||||
clock.offline = true; clock.now += 1000
|
||||
assert.equal(await api.retryFileAccess(raw('offline.jpg')), true)
|
||||
assert.notEqual(api.fileUrl(raw('offline.jpg')), offline)
|
||||
assert.equal(api.fileUrl(raw('good.jpg')), good)
|
||||
} finally { env.close() }
|
||||
})
|
||||
|
||||
test('owned anchors fetch through the app downloader, while external and already handled links keep their behaviour', () => {
|
||||
const env = runtime(), calls = []
|
||||
try {
|
||||
const event = (href, prevented = false) => ({
|
||||
defaultPrevented: prevented,
|
||||
target: { closest: () => ({ getAttribute: name => name === 'href' ? href : '' }) },
|
||||
preventDefault() { this.defaultPrevented = true }, stopImmediatePropagation() { this.stopped = true },
|
||||
})
|
||||
const source = raw(encodeURIComponent('附件 +&%.pdf')), signed = env.api.fileUrl(source)
|
||||
const click = event(signed)
|
||||
assert.equal(env.api.handleFileLinkClick(click, (...args) => calls.push(args)), true)
|
||||
assert.equal(click.defaultPrevented, true); assert.equal(click.stopped, true)
|
||||
assert.equal(calls.length, 1)
|
||||
assert.equal(calls[0][2], '附件 +&%.pdf')
|
||||
assert.doesNotMatch(calls[0][0], /[?&](?:sign|ts|kid|appId)=/)
|
||||
for (const href of ['https://other.example/file.pdf', 'blob:local-document', '/home']) {
|
||||
const outside = event(href)
|
||||
assert.equal(env.api.handleFileLinkClick(outside, () => assert.fail('unrelated link intercepted')), false)
|
||||
assert.equal(outside.defaultPrevented, false)
|
||||
}
|
||||
assert.equal(env.api.handleFileLinkClick(event(signed, true), () => assert.fail('already handled')), false)
|
||||
} finally { env.close() }
|
||||
})
|
||||
|
||||
test('loaded thumbnails never reload on minute checks, expiry, or foreground clock sync; previews receive fresh signatures', async () => {
|
||||
const env = runtime(), page = mountImages(env.api)
|
||||
try {
|
||||
page.images().forEach(image => image.props.onLoad(new Event('load')))
|
||||
const before = page.images().map(image => image.props.src)
|
||||
for (let minute = 0; minute < 31; minute++) {
|
||||
env.clock.now += 60000
|
||||
env.api.fileAccessRevision.value++
|
||||
await vue.nextTick()
|
||||
assert.deepEqual(page.images().map(image => image.props.src), before)
|
||||
}
|
||||
await env.api.refreshFileAccess(true); await settle()
|
||||
assert.equal(page.loads.length, 2)
|
||||
assert.deepEqual(page.images().map(image => image.props.src), before)
|
||||
page.images()[0].props.onShow(); await settle()
|
||||
const preview = page.images()[0].props.preview[0]
|
||||
assert.notEqual(preview, before[0])
|
||||
assert.equal(preview, env.api.fileUrl(raw('good.jpg')))
|
||||
assert.ok(Number(new URL(preview).searchParams.get('ts')) + 1800 > env.clock.now / 1000)
|
||||
assert.equal(page.loads.length, 2)
|
||||
assert.equal(page.sources.value[0], raw('good.jpg'))
|
||||
env.clock.now += 31 * 60000; env.api.fileAccessRevision.value++; await settle()
|
||||
assert.equal(page.images()[0].props.preview[0], preview)
|
||||
page.images()[0].props.onSwitch(0); await settle()
|
||||
assert.notEqual(page.images()[0].props.preview[0], preview)
|
||||
} finally { page.close(); env.close() }
|
||||
})
|
||||
|
||||
test('failed thumbnails retry once without resetting neighbours; a changed business image still loads', async () => {
|
||||
const env = runtime(), page = mountImages(env.api)
|
||||
try {
|
||||
page.images()[1].props.onLoad(new Event('load'))
|
||||
const neighbour = page.images()[1].props.src
|
||||
env.clock.now += 1000
|
||||
page.images()[0].props.onError(new Event('error')); await settle()
|
||||
assert.equal(page.loads.length, 3)
|
||||
assert.equal(page.images()[1].props.src, neighbour)
|
||||
page.images()[0].props.onError(new Event('error')); await settle()
|
||||
assert.equal(page.loads.length, 3)
|
||||
assert.deepEqual(page.failures, [0])
|
||||
env.api.fileAccessRevision.value++; await settle()
|
||||
assert.equal(page.loads.length, 3)
|
||||
page.sources.value[0] = raw('replacement.jpg'); await settle()
|
||||
assert.equal(new URL(page.images()[0].props.src).searchParams.get('fileName'), 'replacement.jpg')
|
||||
assert.equal(page.images()[1].props.src, neighbour)
|
||||
} finally { page.close(); env.close() }
|
||||
})
|
||||
|
||||
test('offscreen images keep a valid URL for their first lazy request without reloading an already visible image', async () => {
|
||||
const env = runtime(), page = mountImages(env.api)
|
||||
try {
|
||||
page.images()[1].props.onLoad(new Event('load'))
|
||||
const before = page.images().map(image => image.props.src)
|
||||
env.clock.now += 31 * 60000; env.api.fileAccessRevision.value++; await settle()
|
||||
assert.notEqual(page.images()[0].props.src, before[0])
|
||||
assert.equal(new URL(page.images()[0].props.src).searchParams.get('ts'), String(env.clock.now / 1000))
|
||||
assert.equal(page.images()[1].props.src, before[1])
|
||||
assert.equal(env.clock.requests, 0)
|
||||
} finally { page.close(); env.close() }
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const Module = require('node:module')
|
||||
const ts = require('typescript')
|
||||
|
||||
const root = path.resolve(__dirname, '../..')
|
||||
const compile = source => ts.transpileModule(source, {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
||||
}).outputText
|
||||
|
||||
function runtime() {
|
||||
const clock = { now: 1793232000000, requests: 0, offline: false }
|
||||
const realNow = Date.now, realFetch = global.fetch
|
||||
Date.now = () => clock.now
|
||||
global.fetch = async () => {
|
||||
clock.requests++
|
||||
if (clock.offline) throw new Error('Offline')
|
||||
return { ok: true, json: async () => ({ data: { serverTime: clock.now, ttlSeconds: 1800 } }) }
|
||||
}
|
||||
const filename = path.join(root, 'src/utils/file-access.ts')
|
||||
const core = new Module(path.join(root, 'src/utils/file-access-core.ts'), module)
|
||||
core.filename = core.id; core.paths = Module._nodeModulePaths(path.dirname(core.filename))
|
||||
core._compile(compile(fs.readFileSync(core.filename, 'utf8')), core.filename)
|
||||
const loaded = new Module(filename, module)
|
||||
loaded.filename = filename; loaded.paths = core.paths
|
||||
loaded.require = name => name === './file-access-core' ? core.exports : core.require(name)
|
||||
const env = {
|
||||
VITE_FILE_ACCESS_APP_ID: 'admin', VITE_FILE_ACCESS_KEY_ID: 'v1',
|
||||
VITE_FILE_ACCESS_KEY: JSON.parse(fs.readFileSync(path.join(root, 'test-vectors/file-access.json'), 'utf8'))[0].key,
|
||||
VITE_IMAGE_BASE_PATH: 'https://files.example/api', VITE_FILE_ACCESS_ALLOWED_ORIGINS: '',
|
||||
}
|
||||
loaded._compile(compile(fs.readFileSync(filename, 'utf8').replace(/import\.meta\.env/g, '(' + JSON.stringify(env) + ')')), filename)
|
||||
return { api: loaded.exports, clock, close() { Date.now = realNow; global.fetch = realFetch } }
|
||||
}
|
||||
|
||||
module.exports = { runtime, compile, root }
|
||||
@@ -0,0 +1,93 @@
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
const fs = require("node:fs")
|
||||
const path = require("node:path")
|
||||
const ts = require("typescript")
|
||||
const vue = require("vue")
|
||||
const { parse, compileScript, compileTemplate } = require("@vue/compiler-sfc")
|
||||
const root = path.join(__dirname, "../src")
|
||||
|
||||
function load(source, mocks, globals = {}) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2021 },
|
||||
}).outputText
|
||||
const mod = { exports: {} }
|
||||
new Function("module", "exports", "require", ...Object.keys(globals), compiled)(mod, mod.exports,
|
||||
key => key in mocks ? mocks[key] : require(key), ...Object.values(globals))
|
||||
return mod.exports
|
||||
}
|
||||
|
||||
function setup() {
|
||||
const requests = [], progress = [], downloads = [], errors = []
|
||||
const submitted = { taskId: "a".repeat(32), redisKey: "admin:export:log", status: "PENDING" }
|
||||
const request = options => { requests.push(options); return Promise.resolve({ data: submitted }) }
|
||||
const tasks = load(fs.readFileSync(path.join(root, "api/asyncTask.ts"), "utf8"), {
|
||||
"/@/utils/request": { default: request },
|
||||
})
|
||||
const api = load(fs.readFileSync(path.join(root, "api/admin/log.ts"), "utf8"), {
|
||||
"/@/utils/request": { default: request }, "/@/api/asyncTask": tasks,
|
||||
})
|
||||
const messages = { useMessage: () => ({ error: message => errors.push(message) }) }
|
||||
const hook = load(fs.readFileSync(path.join(root, "hooks/batchExport.ts"), "utf8"), {
|
||||
vue, "/@/components/AsyncTaskProgress.vue": {}, "/@/hooks/message": messages,
|
||||
"/@/utils/exportDownload": { downloadExportFile: (...args) => downloads.push(args) },
|
||||
})
|
||||
const descriptor = parse(fs.readFileSync(path.join(root, "views/admin/log/index.vue"), "utf8")).descriptor
|
||||
assert.deepEqual(compileTemplate({ source: descriptor.template.content, filename: "log.vue", id: "log" }).errors, [])
|
||||
const page = load(compileScript(descriptor, { id: "log" }).content, {
|
||||
vue, "/@/api/admin/log": api,
|
||||
"/@/components/AsyncTaskProgress.vue": {}, "/@/hooks/batchExport": hook,
|
||||
"vue-i18n": { useI18n: () => ({ t: key => key }) },
|
||||
"/@/hooks/table": { useTable: () => ({ getDataList() {}, tableStyle: {} }) },
|
||||
"/@/hooks/message": messages, "/@/hooks/dict": { useDict: () => ({ log_type: [] }) },
|
||||
}, {
|
||||
ref: vue.ref, reactive: vue.reactive, defineAsyncComponent: vue.defineAsyncComponent,
|
||||
onMounted() {}, useRoute: () => ({ query: {} }),
|
||||
})
|
||||
const state = page.default.setup({}, { expose() {} })
|
||||
state.exportProgressRef.value = {
|
||||
startSubmitting: name => progress.push(name), start: value => progress.push(value),
|
||||
show: () => progress.push("show"), submissionFailed: message => assert.fail(message),
|
||||
}
|
||||
return { state, requests, progress, downloads, errors, submitted }
|
||||
}
|
||||
|
||||
test("日志异步导出固定类型、时间和应用筛选,重复点击继续查看进度,成功后下载", async () => {
|
||||
const { state, requests, progress, downloads, submitted } = setup()
|
||||
Object.assign(state.state.queryForm, {
|
||||
logType: "9", serviceId: "sms", current: 3, size: 10,
|
||||
createTime: ["2026-10-29 00:00:00", "2026-10-29 23:59:59"],
|
||||
})
|
||||
await state.exportExcel()
|
||||
assert.equal(requests.length, 1)
|
||||
assert.equal(requests[0].url, "/admin/log/export-async")
|
||||
assert.equal(requests[0].method, "post")
|
||||
assert.deepEqual(requests[0].data, {
|
||||
logType: "9", serviceId: "sms", createTime: ["2026-10-29 00:00:00", "2026-10-29 23:59:59"],
|
||||
})
|
||||
assert.equal(state.state.queryForm.current, 3)
|
||||
assert.equal(state.state.queryForm.size, 10)
|
||||
assert.equal(state.exportTaskConfig.progressUrl, "/admin/async-task/progress")
|
||||
assert.equal(state.exportTaskConfig.redisKey, "admin:export:log")
|
||||
assert.deepEqual(progress, ["操作日志", submitted])
|
||||
state.state.queryForm.createTime[0] = "2026-10-28 00:00:00"
|
||||
await state.exportExcel()
|
||||
assert.equal(requests.length, 1)
|
||||
assert.equal(requests[0].data.createTime[0], "2026-10-29 00:00:00")
|
||||
assert.equal(progress.at(-1), "show")
|
||||
state.handleExportSuccess({ resultFileUrl: "/admin/sys-file/oss/file?fileName=logs.xlsx", resultFileName: "操作日志.xlsx" })
|
||||
assert.deepEqual(downloads, [["/admin/sys-file/oss/file?fileName=logs.xlsx", "操作日志.xlsx"]])
|
||||
})
|
||||
|
||||
test("未选择或清空日志时间时提交空数组,任务失败后可以重新导出", async () => {
|
||||
const { state, requests, errors } = setup()
|
||||
await state.exportExcel()
|
||||
assert.deepEqual(requests[0].data, { logType: "", createTime: [], serviceId: "" })
|
||||
assert.equal(state.state.queryForm.createTime, "")
|
||||
state.handleExportFailure({ message: "当前筛选条件没有可导出的日志" })
|
||||
assert.deepEqual(errors, ["当前筛选条件没有可导出的日志"])
|
||||
state.state.queryForm.createTime = null
|
||||
await state.exportExcel()
|
||||
assert.equal(requests.length, 2)
|
||||
assert.deepEqual(requests[1].data.createTime, [])
|
||||
})
|
||||
@@ -23,6 +23,13 @@ const alias: Record<string, string> = {
|
||||
|
||||
const viteConfig = defineConfig((mode: ConfigEnv) => {
|
||||
const env = loadEnv(mode.mode, process.cwd())
|
||||
const fileEnv = loadEnv(mode.mode, process.cwd(), '')
|
||||
if (fileEnv.VITE_FILE_ACCESS_APP_ID !== 'admin' || !/^[a-zA-Z0-9_-]{1,32}$/.test(fileEnv.VITE_FILE_ACCESS_KEY_ID || '')
|
||||
|| !/^[A-Za-z0-9+/]+={0,2}$/.test(fileEnv.VITE_FILE_ACCESS_KEY || '')
|
||||
|| Buffer.from(fileEnv.VITE_FILE_ACCESS_KEY || '', 'base64').length < 32) {
|
||||
throw new Error('请配置文件访问 appId、kid 和至少 32 字节的 Base64 密钥(.env.<mode>.local)')
|
||||
}
|
||||
|
||||
// 判断是否开发环境
|
||||
const isDev = env.ENV === "development"
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user