fix: 优化代码内容
This commit is contained in:
parent
8f65b1390b
commit
e6b4c02e34
@ -1,5 +1,5 @@
|
||||
XIAOJU_SURVEY_MONGO_DB_NAME=xiaojuSurvey
|
||||
XIAOJU_SURVEY_MONGO_URL=#mongodb://127.0.0.1:27017 # 建议设置强密码,放开注释不能有空格
|
||||
XIAOJU_SURVEY_MONGO_URL=mongodb://127.0.0.1:27017
|
||||
XIAOJU_SURVEY_MONGO_AUTH_SOURCE=admin
|
||||
|
||||
XIAOJU_SURVEY_REDIS_HOST=
|
||||
@ -9,7 +9,7 @@ XIAOJU_SURVEY_REDIS_PASSWORD=
|
||||
XIAOJU_SURVEY_REDIS_DB=
|
||||
|
||||
|
||||
XIAOJU_SURVEY_RESPONSE_AES_ENCRYPT_SECRET_KEY= # dataAesEncryptSecretKey
|
||||
XIAOJU_SURVEY_RESPONSE_AES_ENCRYPT_SECRET_KEY=dataAesEncryptSecretKey
|
||||
XIAOJU_SURVEY_HTTP_DATA_ENCRYPT_TYPE=rsa
|
||||
|
||||
XIAOJU_SURVEY_JWT_SECRET=xiaojuSurveyJwtSecret
|
||||
|
@ -37,9 +37,7 @@ describe('SurveyMetaService', () => {
|
||||
surveyRepository = module.get<MongoRepository<SurveyMeta>>(
|
||||
getRepositoryToken(SurveyMeta),
|
||||
);
|
||||
pluginManager = module.get<PluginManager>(
|
||||
PluginManager,
|
||||
);
|
||||
pluginManager = module.get<PluginManager>(PluginManager);
|
||||
pluginManager.registerPlugin(new SurveyUtilPlugin());
|
||||
});
|
||||
|
||||
|
@ -153,9 +153,7 @@ describe('SurveyResponseController', () => {
|
||||
clientEncryptService =
|
||||
module.get<ClientEncryptService>(ClientEncryptService);
|
||||
|
||||
const pluginManager = module.get<PluginManager>(
|
||||
PluginManager,
|
||||
);
|
||||
const pluginManager = module.get<PluginManager>(PluginManager);
|
||||
pluginManager.registerPlugin(
|
||||
new ResponseSecurityPlugin('dataAesEncryptSecretKey'),
|
||||
);
|
||||
|
@ -1,4 +1,4 @@
|
||||
export interface XiaojuSurveyPlugin {
|
||||
export interface SecurityPlugin {
|
||||
encryptResponseData?(responseData);
|
||||
afterResponseFind?(responseData);
|
||||
maskData?(data: Record<string, any>);
|
||||
|
@ -1,9 +1,7 @@
|
||||
import xiaojuSurveyPluginManager, {
|
||||
PluginManager,
|
||||
} from './pluginManager';
|
||||
import securityPluginManager, { PluginManager } from './pluginManager';
|
||||
import { Provider } from '@nestjs/common';
|
||||
|
||||
export const PluginManagerProvider: Provider = {
|
||||
provide: PluginManager,
|
||||
useValue: xiaojuSurveyPluginManager,
|
||||
useValue: securityPluginManager,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { XiaojuSurveyPlugin } from './interface';
|
||||
import { SecurityPlugin } from './interface';
|
||||
|
||||
type AllowHooks =
|
||||
| 'encryptResponseData'
|
||||
@ -7,9 +7,9 @@ type AllowHooks =
|
||||
| 'genSurveyPath';
|
||||
|
||||
export class PluginManager {
|
||||
private plugins: Array<XiaojuSurveyPlugin> = [];
|
||||
private plugins: Array<SecurityPlugin> = [];
|
||||
// 注册插件
|
||||
registerPlugin(...plugins: Array<XiaojuSurveyPlugin>) {
|
||||
registerPlugin(...plugins: Array<SecurityPlugin>) {
|
||||
this.plugins.push(...plugins);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,8 @@
|
||||
import { XiaojuSurveyPlugin } from '../interface';
|
||||
import { SecurityPlugin } from '../interface';
|
||||
import { SurveyResponse } from 'src/models/surveyResponse.entity';
|
||||
import {
|
||||
decryptData,
|
||||
encryptData,
|
||||
isDataSensitive,
|
||||
maskData,
|
||||
} from './utils';
|
||||
import { decryptData, encryptData, isDataSensitive, maskData } from './utils';
|
||||
|
||||
export class ResponseSecurityPlugin implements XiaojuSurveyPlugin {
|
||||
export class ResponseSecurityPlugin implements SecurityPlugin {
|
||||
constructor(private readonly secretKey: string) {}
|
||||
encryptResponseData(responseData: SurveyResponse) {
|
||||
const secretKeys = [];
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { XiaojuSurveyPlugin } from '../interface';
|
||||
import { SecurityPlugin } from '../interface';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
|
||||
const surveyPathAlphabet =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
export class SurveyUtilPlugin implements XiaojuSurveyPlugin {
|
||||
export class SurveyUtilPlugin implements SecurityPlugin {
|
||||
genSurveyPath() {
|
||||
const id = customAlphabet(surveyPathAlphabet, 8);
|
||||
return id();
|
||||
|
@ -7,7 +7,7 @@ import { watch, onBeforeUnmount } from 'vue'
|
||||
import { useUserStore } from '@/management/stores/user'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessageBox, ElMessage, type Action } from 'element-plus'
|
||||
import { checkIsTokenValid } from '@/management/api/auth';
|
||||
import { checkIsTokenValid } from '@/management/api/auth'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
@ -31,7 +31,7 @@ const checkAuth = async () => {
|
||||
try {
|
||||
const res: Record<string, any> = await checkIsTokenValid()
|
||||
if (res.code !== 200 || !res.data) {
|
||||
showConfirmBox();
|
||||
showConfirmBox()
|
||||
} else {
|
||||
timer = setTimeout(
|
||||
() => {
|
||||
|
@ -21,5 +21,5 @@ export const getPasswordStrength = (password) => {
|
||||
}
|
||||
|
||||
export const checkIsTokenValid = () => {
|
||||
return axios.get('/auth/verifyToken');
|
||||
}
|
||||
return axios.get('/auth/verifyToken')
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
<div class="left">
|
||||
<img class="logo-img" src="/imgs/Logo.webp" alt="logo" />
|
||||
<el-menu router default-active-index="survey" class="el-menu-demo" mode="horizontal">
|
||||
<el-menu-item index="survey" >
|
||||
<el-menu-item index="survey">
|
||||
<router-link :to="{ name: 'survey' }">问卷列表</router-link>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="download">
|
||||
@ -34,8 +34,6 @@ const handleLogout = () => {
|
||||
userStore.logout()
|
||||
router.replace({ name: 'login' })
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -88,4 +86,4 @@ const handleLogout = () => {
|
||||
color: #faa600;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
@ -88,15 +88,20 @@ export const noSpaceDataConfig = {
|
||||
img: '/imgs/icons/list-empty.webp'
|
||||
}
|
||||
export const noSpaceSearchDataConfig = {
|
||||
title: '没有满足该查询条件的团队空间哦',
|
||||
title: '没有满足该查询条件的团队空间',
|
||||
desc: '可以更换条件查询试试',
|
||||
img: '/imgs/icons/list-empty.webp'
|
||||
}
|
||||
export const noSearchDataConfig = {
|
||||
title: '没有满足该查询条件的问卷哦',
|
||||
title: '没有满足该查询条件的问卷',
|
||||
desc: '可以更换条件查询试试',
|
||||
img: '/imgs/icons/list-empty.webp'
|
||||
}
|
||||
export const noDownloadTaskConfig = {
|
||||
title: '没有下载任务',
|
||||
desc: '可以在数据分析进行下载',
|
||||
img: '/imgs/icons/list-empty.webp'
|
||||
}
|
||||
|
||||
export const statusMaps = {
|
||||
new: '未发布',
|
||||
|
@ -2,7 +2,9 @@
|
||||
<div class="data-table-page">
|
||||
<template v-if="tableData.total">
|
||||
<div class="menus">
|
||||
<el-button type="primary" :loading="isDownloading" @click="onDownload">导出全部数据</el-button>
|
||||
<el-button type="primary" :loading="isDownloading" @click="onDownload"
|
||||
>导出全部数据</el-button
|
||||
>
|
||||
<el-switch
|
||||
class="desensitize-switch"
|
||||
:model-value="isShowOriginData"
|
||||
@ -63,7 +65,7 @@ import EmptyIndex from '@/management/components/EmptyIndex.vue'
|
||||
import { getRecycleList } from '@/management/api/analysis'
|
||||
import { noDataConfig } from '@/management/config/analysisConfig'
|
||||
import DataTable from '../components/DataTable.vue'
|
||||
import { createDownloadTask, getDownloadTask } from '@/management/api/downloadTask'
|
||||
import { createDownloadTask, getDownloadTask } from '@/management/api/download'
|
||||
|
||||
const dataTableState = reactive({
|
||||
mainTableLoading: false,
|
||||
@ -78,8 +80,8 @@ const dataTableState = reactive({
|
||||
isDownloading: false,
|
||||
downloadDialogVisible: false,
|
||||
downloadForm: {
|
||||
isMasked: true,
|
||||
},
|
||||
isMasked: true
|
||||
}
|
||||
})
|
||||
|
||||
const { mainTableLoading, tableData, isShowOriginData, downloadDialogVisible, isDownloading } =
|
||||
@ -162,20 +164,22 @@ const confirmDownload = async () => {
|
||||
}
|
||||
try {
|
||||
isDownloading.value = true
|
||||
const createRes = await createDownloadTask({ surveyId: route.params.id, isMasked: downloadForm.isMasked })
|
||||
const createRes = await createDownloadTask({
|
||||
surveyId: route.params.id,
|
||||
isMasked: downloadForm.isMasked
|
||||
})
|
||||
dataTableState.downloadDialogVisible = false
|
||||
if (createRes.code === 200) {
|
||||
ElMessage.success(`下载文件计算中,可前往“下载中心”查看`)
|
||||
try {
|
||||
const taskInfo = await checkIsTaskFinished(createRes.data.taskId)
|
||||
if (taskInfo.url) {
|
||||
window.open(taskInfo.url)
|
||||
ElMessage.success('导出成功')
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('导出失败,请重试')
|
||||
if (createRes.code !== 200) {
|
||||
ElMessage.error('导出失败,请重试')
|
||||
}
|
||||
ElMessage.success(`下载文件计算中,可前往“下载中心”查看`)
|
||||
try {
|
||||
const taskInfo = await checkIsTaskFinished(createRes.data.taskId)
|
||||
if (taskInfo.url) {
|
||||
window.open(taskInfo.url)
|
||||
ElMessage.success('导出成功')
|
||||
}
|
||||
} else {
|
||||
} catch (error) {
|
||||
ElMessage.error('导出失败,请重试')
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -2,15 +2,14 @@
|
||||
<div class="question-list-root">
|
||||
<TopNav></TopNav>
|
||||
<div class="table-container">
|
||||
<DownloadTaskList></DownloadTaskList>
|
||||
<TaskList></TaskList>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import TopNav from '@/management/components/TopNav.vue';
|
||||
import DownloadTaskList from './components/DownloadTaskList.vue'
|
||||
|
||||
import TopNav from '@/management/components/TopNav.vue'
|
||||
import TaskList from './components/TaskList.vue'
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div v-loading="loading" class="list-wrapper" v-if="total">
|
||||
<div v-loading="loading" class="list-wrapper">
|
||||
<el-table
|
||||
v-if="total"
|
||||
ref="multipleListTable"
|
||||
@ -19,7 +19,7 @@
|
||||
:prop="field.key"
|
||||
:label="field.title"
|
||||
:width="field.width"
|
||||
:class-name="[field.key]"
|
||||
:class-name="field.key"
|
||||
:formatter="field.formatter"
|
||||
>
|
||||
</el-table-column>
|
||||
@ -36,6 +36,9 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div v-else>
|
||||
<EmptyIndex :data="noDownloadTaskConfig" />
|
||||
</div>
|
||||
<div class="list-pagination" v-if="total">
|
||||
<el-pagination
|
||||
background
|
||||
@ -54,7 +57,10 @@
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { get, map } from 'lodash-es'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { deleteDownloadTask, getDownloadTaskList } from '@/management/api/downloadTask'
|
||||
import EmptyIndex from '@/management/components/EmptyIndex.vue'
|
||||
import { noDownloadTaskConfig } from '@/management/config/listConfig'
|
||||
|
||||
import { deleteDownloadTask, getDownloadTaskList } from '@/management/api/download'
|
||||
import { CODE_MAP } from '@/management/api/base'
|
||||
|
||||
const loading = ref(false)
|
||||
@ -160,10 +166,6 @@ const downloadListConfig = {
|
||||
title: '状态',
|
||||
key: 'curStatus.status',
|
||||
formatter(row: Record<string, any>, column: Record<string, any>) {
|
||||
console.log({
|
||||
row,
|
||||
column
|
||||
})
|
||||
return statusTextMap[get(row, column.rawColumnKey)]
|
||||
}
|
||||
}
|
@ -69,11 +69,9 @@ import SliderBar from './components/SliderBar.vue'
|
||||
import SpaceModify from './components/SpaceModify.vue'
|
||||
import TopNav from '@/management/components/TopNav.vue'
|
||||
import { SpaceType } from '@/management/utils/types/workSpace'
|
||||
import { useUserStore } from '@/management/stores/user'
|
||||
import { useWorkSpaceStore } from '@/management/stores/workSpace'
|
||||
import { useSurveyListStore } from '@/management/stores/surveyList'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const workSpaceStore = useWorkSpaceStore()
|
||||
const surveyListStore = useSurveyListStore()
|
||||
|
||||
@ -87,7 +85,6 @@ const loading = ref(false)
|
||||
const spaceListRef = ref<any>(null)
|
||||
const spaceLoading = ref(false)
|
||||
|
||||
|
||||
const fetchSpaceList = async (params?: any) => {
|
||||
spaceLoading.value = true
|
||||
workSpaceStore.changeWorkSpace('')
|
||||
@ -165,7 +162,6 @@ const onSpaceCreate = () => {
|
||||
const onCreate = () => {
|
||||
router.push('/create')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { type Ref, ref, toRef, computed } from 'vue'
|
||||
import { ref, toRef, computed } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { set as _set, isNumber as _isNumber } from 'lodash-es'
|
||||
import { QUESTION_TYPE } from '@/common/typeEnum'
|
||||
|
@ -7,7 +7,7 @@
|
||||
<script setup>
|
||||
import { useSurveyStore } from '../../stores/survey'
|
||||
|
||||
import { getSurveyData, getSurveySubmit } from '../../utils/storage'
|
||||
import { getSurveyData } from '../../utils/storage'
|
||||
|
||||
import ConfirmDialog from '../ConfirmDialog.vue'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user