🔨 优化偏好处理逻辑.

This commit is contained in:
lijiahang
2025-01-13 11:01:11 +08:00
parent a734ec40ec
commit c481cb0ae4
6 changed files with 59 additions and 58 deletions

View File

@@ -13,11 +13,11 @@ export interface PreferenceUpdateRequest {
} }
/** /**
* 用户偏好更新请求-部分 * 用户偏好更新请求-多个
*/ */
export interface PreferenceUpdatePartialRequest { export interface PreferenceUpdateBatchRequest {
type: PreferenceType; 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) { export function updatePreferenceBatch(request: PreferenceUpdateBatchRequest) {
return axios.put('/infra/preference/update-partial', request); return axios.put('/infra/preference/update-batch', request);
} }
/** /**

View File

@@ -47,7 +47,7 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, watch } from 'vue'; 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({ export default defineComponent({
name: 'DayForm', name: 'DayForm',
@@ -58,7 +58,7 @@
}, },
}), }),
emits: useFromEmits(), emits: useFromEmits(),
setup(props, context) { setup(props: any, context) {
const disabledChoice = computed(() => { const disabledChoice = computed(() => {
return (props.week && props.week !== '?') || props.disabled; return (props.week && props.week !== '?') || props.disabled;
}); });

View File

@@ -170,7 +170,7 @@ export function useFormSetup(props: any, context: any, options: any) {
})); }));
// 输入框属性 // 输入框属性
const inputNumberAttrs = computed(() => ({ const inputNumberAttrs = computed<any>(() => ({
max: maxValue.value, max: maxValue.value,
min: minValue.value, min: minValue.value,
precision: 0, precision: 0,

View File

@@ -55,7 +55,7 @@
}, },
}), }),
emits: useFromEmits(), emits: useFromEmits(),
setup(props, context) { setup(props: any, context) {
const disabledChoice = computed(() => { const disabledChoice = computed(() => {
return (props.day && props.day !== '?') || props.disabled; return (props.day && props.day !== '?') || props.disabled;
}); });
@@ -81,13 +81,13 @@
return options; return options;
}); });
const typeRangeSelectAttrs = computed(() => ({ const typeRangeSelectAttrs = computed<any>(() => ({
disabled: setup.typeRangeAttrs.value.disabled, disabled: setup.typeRangeAttrs.value.disabled,
size: 'small', size: 'small',
class: ['w80'], class: ['w80'],
})); }));
const typeLoopSelectAttrs = computed(() => ({ const typeLoopSelectAttrs = computed<any>(() => ({
disabled: setup.typeLoopAttrs.value.disabled, disabled: setup.typeLoopAttrs.value.disabled,
size: 'small', size: 'small',
class: ['w80'], class: ['w80'],

View File

@@ -24,6 +24,7 @@ interface XHRCustom extends XHR {
match: boolean; match: boolean;
} }
// 防止 blob 格式的文件流被污染
// @ts-ignore // @ts-ignore
Mock.XHR.prototype.send = (() => { Mock.XHR.prototype.send = (() => {
// @ts-ignore // @ts-ignore

View File

@@ -1,46 +1,46 @@
import type { GetParams } from '@/types/global'; // import type { GetParams } from '@/types/global';
import Mock from 'mockjs'; // import Mock from 'mockjs';
import qs from 'query-string'; // import qs from 'query-string';
import dayjs from 'dayjs'; // import dayjs from 'dayjs';
import setupMock, { successResponseWrap } from '@/utils/setup-mock'; // import setupMock, { successResponseWrap } from '@/utils/setup-mock';
//
const textList = [ // const textList = [
{ // {
key: 1, // key: 1,
clickNumber: '1w+', // clickNumber: '1w+',
title: 'text...', // title: 'text...',
increases: 35, // increases: 35,
}, // },
{ // {
key: 2, // key: 2,
clickNumber: '2w+', // clickNumber: '2w+',
title: 'text...', // title: 'text...',
increases: 22, // increases: 22,
}, // },
]; // ];
//
setupMock({ // setupMock({
setup() { // setup() {
Mock.mock(new RegExp('/api/content-data'), () => { // Mock.mock(new RegExp('/api/content-data'), () => {
const presetData = [58, 81, 53, 90, 64, 88, 49, 79]; // const presetData = [58, 81, 53, 90, 64, 88, 49, 79];
const getLineData = () => { // const getLineData = () => {
const count = 8; // const count = 8;
return new Array(count).fill(0).map((el, idx) => ({ // return new Array(count).fill(0).map((el, idx) => ({
x: dayjs() // x: dayjs()
.day(idx - 2) // .day(idx - 2)
.format('YYYY-MM-DD'), // .format('YYYY-MM-DD'),
y: presetData[idx], // y: presetData[idx],
})); // }));
}; // };
return successResponseWrap([...getLineData()]); // return successResponseWrap([...getLineData()]);
}); // });
Mock.mock(new RegExp('/api/popular/list'), (params: GetParams) => { // Mock.mock(new RegExp('/api/popular/list'), (params: GetParams) => {
const { type = 'text' } = qs.parseUrl(params.url).query; // const { type = 'text' } = qs.parseUrl(params.url).query;
if (type === 'text') { // if (type === 'text') {
return successResponseWrap([...textList]); // return successResponseWrap([...textList]);
} else { // } else {
return successResponseWrap([]); // return successResponseWrap([]);
} // }
}); // });
}, // },
}); // });