🔨 优化偏好处理逻辑.
This commit is contained in:
@@ -13,11 +13,11 @@ export interface PreferenceUpdateRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户偏好更新请求-部分
|
||||
* 用户偏好更新请求-多个
|
||||
*/
|
||||
export interface PreferenceUpdatePartialRequest {
|
||||
export interface PreferenceUpdateBatchRequest {
|
||||
type: PreferenceType;
|
||||
config: Record<string, any> | object;
|
||||
config: Record<string, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,10 +28,10 @@ export function updatePreference(request: PreferenceUpdateRequest) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户偏好-部分
|
||||
* 更新用户偏好-多个
|
||||
*/
|
||||
export function updatePreferencePartial(request: PreferenceUpdatePartialRequest) {
|
||||
return axios.put('/infra/preference/update-partial', request);
|
||||
export function updatePreferenceBatch(request: PreferenceUpdateBatchRequest) {
|
||||
return axios.put('/infra/preference/update-batch', request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, watch } from 'vue';
|
||||
import { TypeEnum, useFormProps, useFromEmits, useFormSetup } from './use-mixin';
|
||||
import { TypeEnum, useFormProps, useFormSetup, useFromEmits } from './use-mixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DayForm',
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
}),
|
||||
emits: useFromEmits(),
|
||||
setup(props, context) {
|
||||
setup(props: any, context) {
|
||||
const disabledChoice = computed(() => {
|
||||
return (props.week && props.week !== '?') || props.disabled;
|
||||
});
|
||||
|
||||
@@ -170,7 +170,7 @@ export function useFormSetup(props: any, context: any, options: any) {
|
||||
}));
|
||||
|
||||
// 输入框属性
|
||||
const inputNumberAttrs = computed(() => ({
|
||||
const inputNumberAttrs = computed<any>(() => ({
|
||||
max: maxValue.value,
|
||||
min: minValue.value,
|
||||
precision: 0,
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
},
|
||||
}),
|
||||
emits: useFromEmits(),
|
||||
setup(props, context) {
|
||||
setup(props: any, context) {
|
||||
const disabledChoice = computed(() => {
|
||||
return (props.day && props.day !== '?') || props.disabled;
|
||||
});
|
||||
@@ -81,13 +81,13 @@
|
||||
return options;
|
||||
});
|
||||
|
||||
const typeRangeSelectAttrs = computed(() => ({
|
||||
const typeRangeSelectAttrs = computed<any>(() => ({
|
||||
disabled: setup.typeRangeAttrs.value.disabled,
|
||||
size: 'small',
|
||||
class: ['w80'],
|
||||
}));
|
||||
|
||||
const typeLoopSelectAttrs = computed(() => ({
|
||||
const typeLoopSelectAttrs = computed<any>(() => ({
|
||||
disabled: setup.typeLoopAttrs.value.disabled,
|
||||
size: 'small',
|
||||
class: ['w80'],
|
||||
|
||||
@@ -24,6 +24,7 @@ interface XHRCustom extends XHR {
|
||||
match: boolean;
|
||||
}
|
||||
|
||||
// 防止 blob 格式的文件流被污染
|
||||
// @ts-ignore
|
||||
Mock.XHR.prototype.send = (() => {
|
||||
// @ts-ignore
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
import type { GetParams } from '@/types/global';
|
||||
import Mock from 'mockjs';
|
||||
import qs from 'query-string';
|
||||
import dayjs from 'dayjs';
|
||||
import setupMock, { successResponseWrap } from '@/utils/setup-mock';
|
||||
|
||||
const textList = [
|
||||
{
|
||||
key: 1,
|
||||
clickNumber: '1w+',
|
||||
title: 'text...',
|
||||
increases: 35,
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
clickNumber: '2w+',
|
||||
title: 'text...',
|
||||
increases: 22,
|
||||
},
|
||||
];
|
||||
|
||||
setupMock({
|
||||
setup() {
|
||||
Mock.mock(new RegExp('/api/content-data'), () => {
|
||||
const presetData = [58, 81, 53, 90, 64, 88, 49, 79];
|
||||
const getLineData = () => {
|
||||
const count = 8;
|
||||
return new Array(count).fill(0).map((el, idx) => ({
|
||||
x: dayjs()
|
||||
.day(idx - 2)
|
||||
.format('YYYY-MM-DD'),
|
||||
y: presetData[idx],
|
||||
}));
|
||||
};
|
||||
return successResponseWrap([...getLineData()]);
|
||||
});
|
||||
Mock.mock(new RegExp('/api/popular/list'), (params: GetParams) => {
|
||||
const { type = 'text' } = qs.parseUrl(params.url).query;
|
||||
if (type === 'text') {
|
||||
return successResponseWrap([...textList]);
|
||||
} else {
|
||||
return successResponseWrap([]);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
// import type { GetParams } from '@/types/global';
|
||||
// import Mock from 'mockjs';
|
||||
// import qs from 'query-string';
|
||||
// import dayjs from 'dayjs';
|
||||
// import setupMock, { successResponseWrap } from '@/utils/setup-mock';
|
||||
//
|
||||
// const textList = [
|
||||
// {
|
||||
// key: 1,
|
||||
// clickNumber: '1w+',
|
||||
// title: 'text...',
|
||||
// increases: 35,
|
||||
// },
|
||||
// {
|
||||
// key: 2,
|
||||
// clickNumber: '2w+',
|
||||
// title: 'text...',
|
||||
// increases: 22,
|
||||
// },
|
||||
// ];
|
||||
//
|
||||
// setupMock({
|
||||
// setup() {
|
||||
// Mock.mock(new RegExp('/api/content-data'), () => {
|
||||
// const presetData = [58, 81, 53, 90, 64, 88, 49, 79];
|
||||
// const getLineData = () => {
|
||||
// const count = 8;
|
||||
// return new Array(count).fill(0).map((el, idx) => ({
|
||||
// x: dayjs()
|
||||
// .day(idx - 2)
|
||||
// .format('YYYY-MM-DD'),
|
||||
// y: presetData[idx],
|
||||
// }));
|
||||
// };
|
||||
// return successResponseWrap([...getLineData()]);
|
||||
// });
|
||||
// Mock.mock(new RegExp('/api/popular/list'), (params: GetParams) => {
|
||||
// const { type = 'text' } = qs.parseUrl(params.url).query;
|
||||
// if (type === 'text') {
|
||||
// return successResponseWrap([...textList]);
|
||||
// } else {
|
||||
// return successResponseWrap([]);
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user