Skip to content

Commit bdff305

Browse files
committed
fix: 升级v3
1 parent a3947d6 commit bdff305

File tree

12 files changed

+109
-74
lines changed

12 files changed

+109
-74
lines changed

components.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ export {}
77

88
declare module 'vue' {
99
export interface GlobalComponents {
10+
copy: typeof import('./src/components/Login-Modal copy/index.vue')['default']
1011
ElImage: typeof import('element-plus/es')['ElImage']
1112
GroupModal: typeof import('./src/components/Group-Modal/index.vue')['default']
1213
Image: typeof import('./src/components/Image.vue')['default']
13-
'Image copy': typeof import('./src/components/Image copy.vue')['default']
1414
Loading: typeof import('./src/components/Loading/index.vue')['default']
1515
LoginModal: typeof import('./src/components/Login-Modal/index.vue')['default']
1616
Modal: typeof import('./src/components/Modal/index.vue')['default']
1717
SettingsModal: typeof import('./src/components/Settings-Modal/index.vue')['default']
1818
Tag: typeof import('./src/components/Tag.vue')['default']
1919
Toast: typeof import('./src/components/Toast/index.vue')['default']
2020
UseModal: typeof import('./src/components/Use-Modal/index.vue')['default']
21+
UserModal: typeof import('./src/components/User-Modal/index.vue')['default']
2122
}
2223
export interface ComponentCustomProperties {
2324
vLoading: typeof import('element-plus/es')['ElLoadingDirective']

src/DrawPanel.vue

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useLimitHook } from '@/hooks/use-limit-hook';
1414
import { userStorage } from '@/utils/storage';
1515
import { useUser } from '@/hooks/use-user'
1616
import GroupModal from '@/components/Group-Modal/index.vue'
17+
import UserModal from '@/components/User-Modal/index.vue'
1718
1819
1920
const { isLogin, showLoginModal, userLogout } = useUser()
@@ -140,7 +141,8 @@ const onUpscale = async (msg: Message) => {
140141
prompt,
141142
index,
142143
msgHash,
143-
msgId
144+
msgId,
145+
flags: msg.flags || 0
144146
}) as any;
145147
console.log("newId: ", newId);
146148
const newMsg: Message = {
@@ -208,6 +210,13 @@ const showGroupModal = () => {
208210
})
209211
}
210212
213+
const showUserModal = () => {
214+
showModal(UserModal, {
215+
closeOnClickModal: true,
216+
closeOnPressEscape: true
217+
})
218+
}
219+
211220
onMounted(() => {
212221
getList({ pageNum: 1, pageSize: data.pageSize }).finally(() => {
213222
data.initLoading = false
@@ -239,18 +248,23 @@ onMounted(() => {
239248
class="absolute left-10 right-10 max-sm:left-2 max-sm:right-2 bottom-4 max-sm:bottom-2 flex-row items-center justify-between px-2 py-2 bg-gray-100 border-gray-400 rounded-[4px]">
240249
<!-- 快捷/帮助区域 -->
241250
<div class="flex w-full px-2 pb-2 pt-1 text-md select-none flex-wrap">
242-
<p class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm" @click.stop="helpThink">想一个</p>
243-
<p class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm" @click.stop="showSettingsModal">设置</p>
244-
<!-- <p class="underline text-orange-400 pr-4 cursor-pointer" @click.stop="showSettingsModal">设置风格</p> -->
245-
<p class="underline text-orange-400 cursor-pointer max-sm:text-sm" @click.stop="showUseModal">使用说明</p>
246-
<p class="underline text-orange-400 pr-4 ml-4 max-sm:text-sm" @click.stop="onlyForMe">
247-
<input id="onlyMe" v-model="data.onlyCurrentUser" type="checkbox" class="cursor-pointer">
251+
<p class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm max-sm:pr-1" @click.stop="helpThink">想一个
252+
</p>
253+
<p class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm max-sm:pr-1"
254+
@click.stop="showSettingsModal">设置</p>
255+
<p class="underline text-orange-400 cursor-pointer max-sm:text-sm max-sm:pr-1" @click.stop="showUseModal">使用说明
256+
</p>
257+
<p class="underline text-orange-400 pr-4 ml-4 max-sm:text-sm max-sm:pr-1 max-sm:ml-1" @click.stop="onlyForMe">
258+
<input id="onlyMe" v-model="data.onlyCurrentUser" type="checkbox" class="cursor-pointer max-sm:pl-1">
248259
<label for="onlyMe" class="cursor-pointer">只看自己</label>
249260
</p>
250261
<p class="flex-1"></p>
251-
<p class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm" @click="showGroupModal">交流群</p>
252-
<p v-if="!isLogin" class="underline text-orange-400 pr-4 cursor-pointer font-bold max-sm:text-sm" @click.stop="showLoginModal">登录/注册</p>
253-
<p v-if="isLogin" class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm" @click.stop="userLogout">退出</p>
262+
<p class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm max-sm:pr-1" @click="showGroupModal">交流群
263+
</p>
264+
<p v-if="!isLogin" class="underline text-orange-400 pr-4 cursor-pointer font-bold max-sm:text-sm max-sm:pr-1"
265+
@click.stop="showLoginModal">我的</p>
266+
<p v-if="isLogin" class="underline text-orange-400 pr-4 cursor-pointer max-sm:text-sm max-sm:pr-1"
267+
@click.stop="showUserModal">我的</p>
254268
</div>
255269
<!-- 输入框 -->
256270
<div class="w-full bg-white flex items-center">
@@ -263,4 +277,8 @@ onMounted(() => {
263277
</div>
264278
</div>
265279
</div>
266-
</template>
280+
</template>
281+
282+
<style>#contentWrap .el-loading-mask {
283+
background-color: transparent;
284+
}</style>

src/Message.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import Image from './components/Image.vue';
66
import { useDebounceFn } from '@vueuse/core'
77
import { onMounted, ref, computed } from 'vue'
88
import Toast from './components/Toast';
9+
import { useUser } from '@/hooks/use-user'
910
10-
const itemWidth = ref(0)
11+
const { isLogin, userInfo } = useUser()
1112
const imageRef = ref<any>()
1213
const props = defineProps({
1314
message: {
@@ -71,7 +72,10 @@ const getMessageStatus = (status: number) => {
7172
<Image v-if="message.uri" ref="imageRef" loadText="排队生成中" :url="message.uri" />
7273

7374
<!-- upscale area 升级区域 -->
74-
<div v-if="message?.status == MessageStatus.DONE && !message.index">
75+
<div v-if="!isLogin && message?.status == MessageStatus.DONE && !message.index">
76+
<p class=" text-gray-400 text-sm leading-6">请登录进行Upscale升级</p>
77+
</div>
78+
<div v-else-if="isLogin && userInfo.username === message?.creator && message?.status == MessageStatus.DONE && !message.index">
7579
<Tag text="U1" @click="onClickUV(1)" />
7680
<Tag text="U2" @click="onClickUV(2)" />
7781
<Tag text="U3" @click="onClickUV(3)" />

src/api/midjourney.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ interface IUpscaleAPI {
44
msgHash: string
55
msgId: string
66
index: number
7+
flags?: number
78
}
89

910
export const getMessagesAPI = (params?: any) => {

src/api/user.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { $http } from '../utils/axios'
2+
import { userStorage } from '@/utils/storage';
23

34
interface IUser {
45
username: string;
@@ -13,3 +14,7 @@ export const registerUserAPI = (data: IUser) => {
1314
export const loginUserAPI = (data: IUser) => {
1415
return $http.post('/user/login', data)
1516
}
17+
18+
export const getUserInfo = () => {
19+
return $http.post('/user/' + userStorage.get().id)
20+
}

src/components/Group-Modal/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const onClickCancel = () => {
1212
</script>
1313

1414
<template>
15-
<div class="">
16-
<img src="/src/assets/group.jpg" alt="">
15+
<div class="max-w-[400px]">
16+
<img class="w-full" src="/src/assets/group.jpg" alt="">
1717
</div>
1818
</template>

src/components/Image copy.vue

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/components/Login-Modal/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ const onClickCancel = () => {
8888
</script>
8989

9090
<template>
91-
<div class="max-w-[600px] px-8 py-4 min-w-[420px]" todayUsed="form.loading">
91+
<div class="max-w-[600px] px-8 py-4 min-w-[420px] max-sm:min-w-[auto]" todayUsed="form.loading">
9292
<img class="block m-auto pb-4" src="/src/assets/coffee.png" alt="">
9393
<p class="py-1 pb-4 text-center text-orange-100 font-bold">欢迎使用</p>
9494
<div class="flex justify-between items-center py-2 text-sm mb-2" >
95-
<div class="pr-2 text-sm min-w-[80px]">账号:</div>
95+
<div class="pr-2 text-sm min-w-[80px] max-sm:min-w-[auto]">账号:</div>
9696
<input v-model.trim="form.username" type="text" class="flex-1 outline-none rounded text-gray-500 px-3 py-1.5">
9797
</div>
9898
<div class="flex justify-between items-center py-2 text-sm">
99-
<div class="pr-2 text-sm min-w-[80px]">密码:</div>
99+
<div class="pr-2 text-sm min-w-[80px] max-sm:min-w-[auto]">密码:</div>
100100
<input autocomplete="off" v-model.trim="form.password" type="password" style="-webkit-text-security: disc;" class="flex-1 outline-none rounded text-gray-500 px-3 py-1.5">
101101
</div>
102-
<div class="flex justify-between items-center py-2 text-sm mt-2" v-if="form.type === FORM_TYPE.REGISTER">
103-
<div class="pr-2 text-sm min-w-[80px]">输入密码:</div>
102+
<div class="flex justify-between items-center py-2 text-sm mt-2 whitespace-nowrap" v-if="form.type === FORM_TYPE.REGISTER">
103+
<div class="pr-2 text-sm min-w-[80px] max-sm:min-w-[auto]">输入密码:</div>
104104
<input autocomplete="off" v-model.trim="form.rePassword" type="password" class="flex-1 outline-none rounded text-gray-500 px-3 py-1.5">
105105
</div>
106106

src/components/User-Modal/index.vue

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<script setup lang="ts">
2+
import { onMounted, reactive } from 'vue';
3+
import { useUser } from '@/hooks/use-user'
4+
import { getUserInfo } from '@/api/user'
5+
6+
const { userInfo, isLogin } = useUser();
7+
8+
const props = defineProps({
9+
close: {
10+
type: Function
11+
}
12+
})
13+
14+
const data = reactive({
15+
loading: false,
16+
times: 0
17+
})
18+
19+
const onClickCancel = () => {
20+
props.close?.()
21+
}
22+
23+
onMounted(() => {
24+
data.loading = true
25+
getUserInfo().then((res: any) => {
26+
data.times = res.times
27+
}).finally(() => {
28+
data.loading = false;
29+
})
30+
})
31+
32+
</script>
33+
34+
<template>
35+
<div class="max-w-[600px] px-8 py-4 min-w-[420px] max-sm:min-w-[auto]" todayUsed="form.loading" v-loading="data.loading">
36+
<img class="block m-auto pb-4" src="/src/assets/coffee.png" alt="">
37+
<p class="py-1 pb-4 text-center text-orange-100 font-bold">你好,{{ userInfo.username }}</p>
38+
39+
<div class="py-2 text-white">
40+
<div class="flex justify-between items-center">
41+
<div class="text-sm">剩余绘画次数:</div>
42+
<div class="flex-1 text-center text-orange-200 font-bold">{{ data.times }}</div>
43+
</div>
44+
</div>
45+
46+
<div class="flex flex-col justify-center text-center pt-6 text-sm">
47+
<!-- <div class="px-4 py-2 cursor-pointer rounded text-gray bg-orange-500 hover:bg-orange-600 mb-4" @click="onClickSave">保存</div>
48+
<div class="px-4 py-2 cursor-pointer rounded text-gray border border-orange-500 text-orange-400" @click="onClickCancel">取消</div> -->
49+
<div class="px-4 py-2 cursor-pointer rounded text-gray border border-orange-500 text-orange-400"
50+
@click="onClickCancel">关闭</div>
51+
</div>
52+
</div>
53+
</template>

src/hooks/use-user.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ export const useUser = () => {
66

77
userStorage.addChangeListener((newUserValue) => {
88
isLogin.value = !!newUserValue && !!tokenStorage.get()
9+
userInfo.value = newUserValue;
910
})
1011

1112
const isLogin = ref(!!userStorage.get())
13+
const userInfo = ref(userStorage.get())
1214

1315
const userLogout = () => {
1416
userStorage.remove()
@@ -18,6 +20,7 @@ export const useUser = () => {
1820

1921
return {
2022
isLogin,
23+
userInfo,
2124
showLoginModal,
2225
userLogout
2326
}

src/interfaces/message.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface Message {
1010
createTime?: string | number
1111
// 生成描述,比如我是upscale第四张
1212
generateText?: string
13+
creator?: string
14+
flags?: number
1315
}
1416

1517
export enum MessageStatus {

src/utils/axios.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { tokenStorage, userStorage } from '@/utils/storage'
44
import { showLoginModal } from '@/utils/index';
55

66
export const host = import.meta.env.VITE_APP_API_URL;
7+
// export const host = "http://43.153.50.34:8999";
78

89
export const $http = axios.create({
910
baseURL: host

0 commit comments

Comments
 (0)