mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
No need to login with Stable-Diffusion page and Invite page
This commit is contained in:
parent
81545d192b
commit
6dbf61d4e4
@ -33,6 +33,8 @@ func (h *PowerLogHandler) List(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
session := h.DB.Session(&gorm.Session{})
|
session := h.DB.Session(&gorm.Session{})
|
||||||
|
userId := h.GetLoginUserId(c)
|
||||||
|
session = session.Where("user_id", userId)
|
||||||
if data.Model != "" {
|
if data.Model != "" {
|
||||||
session = session.Where("model", data.Model)
|
session = session.Where("model", data.Model)
|
||||||
}
|
}
|
||||||
|
@ -68,3 +68,7 @@ UPDATE chatgpt_api_keys set proxy_url='';
|
|||||||
|
|
||||||
-- 重置系统配置,系统配置的数据结构变了,旧数据解析会失败。
|
-- 重置系统配置,系统配置的数据结构变了,旧数据解析会失败。
|
||||||
UPDATE `chatgpt_configs` SET `config_json` = '{\"title\":\"ChatPlus AI 智能助手\",\"admin_title\":\"ChatPlus 控制台\",\"logo\":\"http://localhost:5678/static/upload/2024/3/1710732653645531.png\",\"init_power\":100,\"daily_power\":10,\"invite_power\":10,\"vip_month_power\":1000,\"register_ways\":[\"mobile\",\"username\",\"email\"],\"enabled_register\":true,\"reward_img\":\"http://localhost:5678/static/upload/2024/3/1710753716309668.jpg\",\"enabled_reward\":true,\"power_price\":0.1,\"order_pay_timeout\":1800,\"default_models\":[11,7,1,10,12,19,18,17],\"mj_power\":20,\"sd_power\":5,\"dall_power\":15,\"wechat_card_url\":\"/images/wx.png\",\"enable_context\":true,\"context_deep\":4}' WHERE `chatgpt_configs`.`id` = 1;
|
UPDATE `chatgpt_configs` SET `config_json` = '{\"title\":\"ChatPlus AI 智能助手\",\"admin_title\":\"ChatPlus 控制台\",\"logo\":\"http://localhost:5678/static/upload/2024/3/1710732653645531.png\",\"init_power\":100,\"daily_power\":10,\"invite_power\":10,\"vip_month_power\":1000,\"register_ways\":[\"mobile\",\"username\",\"email\"],\"enabled_register\":true,\"reward_img\":\"http://localhost:5678/static/upload/2024/3/1710753716309668.jpg\",\"enabled_reward\":true,\"power_price\":0.1,\"order_pay_timeout\":1800,\"default_models\":[11,7,1,10,12,19,18,17],\"mj_power\":20,\"sd_power\":5,\"dall_power\":15,\"wechat_card_url\":\"/images/wx.png\",\"enable_context\":true,\"context_deep\":4}' WHERE `chatgpt_configs`.`id` = 1;
|
||||||
|
|
||||||
|
-- 重置用户默认模型
|
||||||
|
UPDATE `chatgpt_users` set chat_models_json = '[1]';
|
||||||
|
|
||||||
|
@ -471,16 +471,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {nextTick, onMounted, onUnmounted, ref} from "vue"
|
import {nextTick, onMounted, onUnmounted, ref} from "vue"
|
||||||
import {
|
import {ChromeFilled, Delete, DocumentCopy, InfoFilled, Picture, Plus, Refresh} from "@element-plus/icons-vue";
|
||||||
ChromeFilled,
|
|
||||||
Delete,
|
|
||||||
DeleteFilled,
|
|
||||||
DocumentCopy,
|
|
||||||
InfoFilled,
|
|
||||||
Picture,
|
|
||||||
Plus,
|
|
||||||
Refresh
|
|
||||||
} from "@element-plus/icons-vue";
|
|
||||||
import Compressor from "compressorjs";
|
import Compressor from "compressorjs";
|
||||||
import {httpGet, httpPost} from "@/utils/http";
|
import {httpGet, httpPost} from "@/utils/http";
|
||||||
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
|
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
|
||||||
@ -489,7 +480,7 @@ import Clipboard from "clipboard";
|
|||||||
import {checkSession} from "@/action/session";
|
import {checkSession} from "@/action/session";
|
||||||
import {useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import {getSessionId} from "@/store/session";
|
import {getSessionId} from "@/store/session";
|
||||||
import {isMobile, removeArrayItem} from "@/utils/libs";
|
import {removeArrayItem} from "@/utils/libs";
|
||||||
import LoginDialog from "@/components/LoginDialog.vue";
|
import LoginDialog from "@/components/LoginDialog.vue";
|
||||||
|
|
||||||
const listBoxHeight = ref(window.innerHeight - 40)
|
const listBoxHeight = ref(window.innerHeight - 40)
|
||||||
@ -673,7 +664,6 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
|
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
checkSession().then(user => {
|
checkSession().then(user => {
|
||||||
power.value = user['power']
|
power.value = user['power']
|
||||||
@ -683,7 +673,6 @@ const initData = () => {
|
|||||||
fetchRunningJobs()
|
fetchRunningJobs()
|
||||||
fetchFinishJobs(1)
|
fetchFinishJobs(1)
|
||||||
connect()
|
connect()
|
||||||
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<div class="page-sd">
|
<div class="page-sd">
|
||||||
<div class="inner custom-scroll">
|
<div class="inner custom-scroll">
|
||||||
<div class="sd-box">
|
<div class="sd-box">
|
||||||
@ -297,7 +298,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="param-line" style="padding: 10px">
|
<div class="param-line" style="padding: 10px">
|
||||||
<el-tag type="success">绘图可用额度:{{ imgCalls }}</el-tag>
|
<el-tag type="success">当前可用算力:{{ power }}</el-tag>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@ -515,6 +516,9 @@
|
|||||||
|
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@ -527,6 +531,7 @@ import Clipboard from "clipboard";
|
|||||||
import {checkSession} from "@/action/session";
|
import {checkSession} from "@/action/session";
|
||||||
import {useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import {getSessionId} from "@/store/session";
|
import {getSessionId} from "@/store/session";
|
||||||
|
import LoginDialog from "@/components/LoginDialog.vue";
|
||||||
|
|
||||||
const listBoxHeight = ref(window.innerHeight - 40)
|
const listBoxHeight = ref(window.innerHeight - 40)
|
||||||
const mjBoxHeight = ref(window.innerHeight - 150)
|
const mjBoxHeight = ref(window.innerHeight - 150)
|
||||||
@ -534,6 +539,8 @@ const fullImgHeight = ref(window.innerHeight - 60)
|
|||||||
const showTaskDialog = ref(false)
|
const showTaskDialog = ref(false)
|
||||||
const item = ref({})
|
const item = ref({})
|
||||||
const translating = ref(false)
|
const translating = ref(false)
|
||||||
|
const showLoginDialog = ref(false)
|
||||||
|
const isLogin = ref(false)
|
||||||
|
|
||||||
window.onresize = () => {
|
window.onresize = () => {
|
||||||
listBoxHeight.value = window.innerHeight - 40
|
listBoxHeight.value = window.innerHeight - 40
|
||||||
@ -566,9 +573,14 @@ const _params = router.currentRoute.value.params["copyParams"]
|
|||||||
if (_params) {
|
if (_params) {
|
||||||
params.value = JSON.parse(_params)
|
params.value = JSON.parse(_params)
|
||||||
}
|
}
|
||||||
const imgCalls = ref(0)
|
const power = ref(0)
|
||||||
|
|
||||||
const rewritePrompt = () => {
|
const rewritePrompt = () => {
|
||||||
|
if (!isLogin.value) {
|
||||||
|
showLoginDialog.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
translating.value = true
|
translating.value = true
|
||||||
httpPost("/api/prompt/rewrite", {"prompt": params.value.prompt}).then(res => {
|
httpPost("/api/prompt/rewrite", {"prompt": params.value.prompt}).then(res => {
|
||||||
params.value.prompt = res.data
|
params.value.prompt = res.data
|
||||||
@ -580,6 +592,11 @@ const rewritePrompt = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const translatePrompt = () => {
|
const translatePrompt = () => {
|
||||||
|
if (!isLogin.value) {
|
||||||
|
showLoginDialog.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
translating.value = true
|
translating.value = true
|
||||||
httpPost("/api/prompt/translate", {"prompt": params.value.prompt}).then(res => {
|
httpPost("/api/prompt/translate", {"prompt": params.value.prompt}).then(res => {
|
||||||
params.value.prompt = res.data
|
params.value.prompt = res.data
|
||||||
@ -640,15 +657,7 @@ const connect = () => {
|
|||||||
|
|
||||||
const clipboard = ref(null)
|
const clipboard = ref(null)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
checkSession().then(user => {
|
initData()
|
||||||
imgCalls.value = user['img_calls']
|
|
||||||
userId.value = user.id
|
|
||||||
fetchRunningJobs()
|
|
||||||
fetchFinishJobs()
|
|
||||||
connect()
|
|
||||||
}).catch(() => {
|
|
||||||
router.push('/login')
|
|
||||||
});
|
|
||||||
clipboard.value = new Clipboard('.copy-prompt-sd');
|
clipboard.value = new Clipboard('.copy-prompt-sd');
|
||||||
clipboard.value.on('success', () => {
|
clipboard.value.on('success', () => {
|
||||||
ElMessage.success("复制成功!");
|
ElMessage.success("复制成功!");
|
||||||
@ -663,6 +672,20 @@ onUnmounted(() => {
|
|||||||
clipboard.value.destroy()
|
clipboard.value.destroy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const initData = () => {
|
||||||
|
checkSession().then(user => {
|
||||||
|
power.value = user['power']
|
||||||
|
userId.value = user.id
|
||||||
|
isLogin.value = true
|
||||||
|
fetchRunningJobs()
|
||||||
|
fetchFinishJobs()
|
||||||
|
connect()
|
||||||
|
}).catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const fetchRunningJobs = (userId) => {
|
const fetchRunningJobs = (userId) => {
|
||||||
// 获取运行中的任务
|
// 获取运行中的任务
|
||||||
httpGet(`/api/sd/jobs?status=0&user_id=${userId}`).then(res => {
|
httpGet(`/api/sd/jobs?status=0&user_id=${userId}`).then(res => {
|
||||||
@ -676,7 +699,7 @@ const fetchRunningJobs = (userId) => {
|
|||||||
message: `任务ID:${jobs[i]['task_id']}<br />原因:${jobs[i]['err_msg']}`,
|
message: `任务ID:${jobs[i]['task_id']}<br />原因:${jobs[i]['err_msg']}`,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
imgCalls.value += 1
|
power.value += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_jobs.push(jobs[i])
|
_jobs.push(jobs[i])
|
||||||
@ -726,13 +749,19 @@ const generate = () => {
|
|||||||
promptRef.value.focus()
|
promptRef.value.focus()
|
||||||
return ElMessage.error("请输入绘画提示词!")
|
return ElMessage.error("请输入绘画提示词!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isLogin.value) {
|
||||||
|
showLoginDialog.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (params.value.seed === '') {
|
if (params.value.seed === '') {
|
||||||
params.value.seed = -1
|
params.value.seed = -1
|
||||||
}
|
}
|
||||||
params.value.session_id = getSessionId()
|
params.value.session_id = getSessionId()
|
||||||
httpPost("/api/sd/image", params.value).then(() => {
|
httpPost("/api/sd/image", params.value).then(() => {
|
||||||
ElMessage.success("绘画任务推送成功,请耐心等待任务执行...")
|
ElMessage.success("绘画任务推送成功,请耐心等待任务执行...")
|
||||||
imgCalls.value -= 1
|
power.value -= 1
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
ElMessage.error("任务推送失败:" + e.message)
|
ElMessage.error("任务推送失败:" + e.message)
|
||||||
})
|
})
|
||||||
|
@ -84,6 +84,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ import {ElMessage} from "element-plus";
|
|||||||
import Clipboard from "clipboard";
|
import Clipboard from "clipboard";
|
||||||
import InviteList from "@/components/InviteList.vue";
|
import InviteList from "@/components/InviteList.vue";
|
||||||
import {checkSession} from "@/action/session";
|
import {checkSession} from "@/action/session";
|
||||||
import {useRouter} from "vue-router";
|
import LoginDialog from "@/components/LoginDialog.vue";
|
||||||
|
|
||||||
const inviteURL = ref("")
|
const inviteURL = ref("")
|
||||||
const qrImg = ref("")
|
const qrImg = ref("")
|
||||||
@ -104,10 +106,24 @@ const inviteImgCalls = ref(0)
|
|||||||
const hits = ref(0)
|
const hits = ref(0)
|
||||||
const regNum = ref(0)
|
const regNum = ref(0)
|
||||||
const rate = ref(0)
|
const rate = ref(0)
|
||||||
const router = useRouter()
|
|
||||||
const isLogin = ref(false)
|
const isLogin = ref(false)
|
||||||
|
const showLoginDialog = ref(true)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
initData()
|
||||||
|
|
||||||
|
// 复制链接
|
||||||
|
const clipboard = new Clipboard('.copy-link');
|
||||||
|
clipboard.on('success', () => {
|
||||||
|
ElMessage.success('复制成功!');
|
||||||
|
})
|
||||||
|
|
||||||
|
clipboard.on('error', () => {
|
||||||
|
ElMessage.error('复制失败!');
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const initData = () => {
|
||||||
checkSession().then(() => {
|
checkSession().then(() => {
|
||||||
isLogin.value = true
|
isLogin.value = true
|
||||||
httpGet("/api/invite/code").then(res => {
|
httpGet("/api/invite/code").then(res => {
|
||||||
@ -136,19 +152,8 @@ onMounted(() => {
|
|||||||
ElMessage.error("获取系统配置失败:" + e.message)
|
ElMessage.error("获取系统配置失败:" + e.message)
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
router.push('/login')
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// 复制链接
|
|
||||||
const clipboard = new Clipboard('.copy-link');
|
|
||||||
clipboard.on('success', () => {
|
|
||||||
ElMessage.success('复制成功!');
|
|
||||||
})
|
|
||||||
|
|
||||||
clipboard.on('error', () => {
|
|
||||||
ElMessage.error('复制失败!');
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user