Commit de3c4e82 by haojie

1

parent 8aeb6fa1
......@@ -12,13 +12,13 @@
<template #body>
<div class="custom-dialog-body">
<div class="content narrow-scrollbar">
<div v-for="(item, index) in list" :key="item.img">
<div v-for="(item, index) in list" :key="item.id">
<div class="img-box">
<img class="img" :src="item.img" alt="" />
<template v-if="item.split_img">
<img class="split-img img" :src="item.split_img" alt="" />
</template>
<template v-else>
<template v-else-if="item.loading">
<div class="split_img_loading">
<t-loading size="24px"></t-loading>
</div>
......@@ -49,7 +49,7 @@ import {
Button as TButton,
Loading as TLoading,
} from 'tdesign-vue-next';
import { ref, watch } from 'vue';
import { PropType, ref, watch } from 'vue';
import Animation from '@/components/Animation.vue';
const btns = [
{
......@@ -69,11 +69,11 @@ const btns = [
value: 4,
},
];
const props = defineProps<{
modelValue: boolean;
list: any[];
dialogloading: boolean;
}>();
const props = defineProps({
modelValue: Boolean,
list: Array as PropType<any[]>,
dialogloading: Boolean,
});
const emit = defineEmits(['update:modelValue', 'SubmitSplit']);
const visible = ref(props.modelValue);
const to_split = (prompt_id: number, click_id: number, index: number) => {
......
......@@ -6,6 +6,8 @@ import {
Button as TButton,
Upload as TUpload,
Progress as TProgress,
UploadFile,
RequestMethodResponse,
} from 'tdesign-vue-next';
import { useStore } from 'vuex';
import { getUserCookie } from '@/utils/api/userApi';
......@@ -54,11 +56,6 @@ export default defineComponent({
const handleFail = ({ file }: any) => {
MessagePlugin.error(`文件 ${file.name} 上传失败`);
};
// 第一个上传链接
const formatResponseOne = (response: any, context: any) => {
console.log(response);
// return { name: 'FileName', url: response.url };
};
// 上传成功回调
const UploadSuccessCallback = (uuid: any, url: any) => {
// 关闭定时器
......@@ -120,9 +117,9 @@ export default defineComponent({
});
};
// 外网上传-func
const ExtranetUpload = (file: any, config: any) => {
const ExtranetUpload = (file: any) => {
openpercentage();
return new Promise((resolve) => {
return new Promise<RequestMethodResponse>((resolve) => {
let uuid = v4();
// 上传中状态
Curfile.status = 1;
......@@ -169,16 +166,8 @@ export default defineComponent({
}, 1000);
});
};
const requestSuccessMethod = async (file: any) => {
// if (uploadStrategy.value.oss) {
// // 外网
// return ExtranetUpload(file, uploadStrategy.value.config);
// } else {
// // 内网
// return IntranetUpload(file);
// }
//
return ExtranetUpload(file, uploadStrategy.value.config);
const requestSuccessMethod = async (file: UploadFile | UploadFile[]) => {
return ExtranetUpload(file);
};
// 未上传
const notUploadHtml = () => {
......@@ -197,7 +186,6 @@ export default defineComponent({
multiple
max={1}
draggable={true}
formatResponse={formatResponseOne}
onfail={handleFail}
>
<div class="custom-upload-click-box">
......
import { defineComponent, onMounted, reactive, ref, watch } from 'vue';
import { defineComponent, onMounted, reactive, ref } from 'vue';
import './index.less';
import EnterKeywords from './components/EnterKeywords';
import { useStore } from 'vuex';
......@@ -21,7 +21,9 @@ export default defineComponent({
let split_interval: any = null;
const task_id = ref();
const prompt_num = ref();
const task_result_list = reactive({
const task_result_list = reactive<{
list: any[];
}>({
list: [],
});
// 关键词
......@@ -32,6 +34,8 @@ export default defineComponent({
const Img_url = ref('');
// 弹窗状态
const DialogVisible = ref(false);
// 测试
const test_num = ref(1);
onMounted(() => {
store.dispatch('user/AdminConfig');
});
......@@ -47,11 +51,10 @@ export default defineComponent({
item.loading = false;
}
});
// 合并去重
task_result_list.list = filterRepeatTimestamp(
task_result_list.list,
res.data
);
if (res.data.length > task_result_list.list.length) {
// 合并去重
filterRepeatTimestamp(task_result_list.list, res.data);
}
if (prompt_num.value == task_result_list.list.length) {
// 关闭定时器
closeInterval();
......@@ -74,6 +77,7 @@ export default defineComponent({
// 切割成功--找到list对应的id,将cut_img添加进去
task_result_list.list.forEach((item: any) => {
if (item.id == res.data.id) {
console.log('我执行了');
item.split_img = res.data.cut_img;
item.loading = false;
}
......@@ -114,10 +118,11 @@ export default defineComponent({
if (!keywords.value) {
return;
}
// prompt_img需要传数组
let params: any = {
type: Img_url.value ? Tasks.img_to_img : Tasks.text_to_img,
prompt: keywords.value,
prompt_img: Img_url.value,
prompt_img: [Img_url.value],
prompt_num: 5,
};
try {
......
......@@ -56,6 +56,7 @@ import {
FormItem as TFormItem,
Input as TInput,
Button as TButton,
FormRule,
} from 'tdesign-vue-next';
import { DesktopIcon, LockOnIcon } from 'tdesign-icons-vue-next';
import { UserLogin } from '@/utils/api/userApi';
......@@ -71,8 +72,12 @@ const formData = reactive({
});
const FORM_RULES = computed(() => {
return {
account: [{ required: true, messgae: '账号不能为空', type: 'error' }],
password: [{ required: true, message: '密码不能为空', type: 'error' }],
account: [
{ required: true, message: '账号不能为空', type: 'error' },
] as FormRule[],
password: [
{ required: true, message: '密码不能为空', type: 'error' },
] as FormRule[],
};
});
const onReset = () => {
......
......@@ -83,7 +83,7 @@ export const SubmitSplitImgTask = (data: any) => {
// 轮询获取图片切割任务状态
export const get_split_img_status = (data: any) => {
return request.get('/api/users/task/callback', {
return request.get('/api/users/split/status', {
params: data,
headers: {
authorization: `Bearer ${getUserCookie()}`,
......
......@@ -406,8 +406,8 @@ export const filterRepeatTimestamp = (list: any, newList: any) => {
let index = list.findIndex((item: any) => item.id == newList[i].id);
if (index == -1) {
// 没找到重复的
NewData.push(newList[i]);
list.push(newList[i]);
}
}
return NewData;
return list;
};
......@@ -12,7 +12,7 @@ export default defineConfig(({ command, mode }) => {
let newDate = `${date.getFullYear()}-${
date.getMonth() + 1
}-${date.getDate()}--${date.getHours()}.${date.getMinutes()}`;
let api = 0 ? 'http://42.194.143.229:90' : 'http://gpt.test';
let api = 0 ? 'http://42.194.143.229:90' : 'http://test.phpgpt.com';
return {
base: '/',
resolve: {
......@@ -52,7 +52,7 @@ export default defineConfig(({ command, mode }) => {
terserOptions: {
compress: {
//生产环境时移除console
drop_console: true,
drop_console: false,
// drop_debugger: true,
},
output: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment