mirror of https://gitee.com/godoos/godoos.git
6 changed files with 443 additions and 189 deletions
@ -1,199 +1,341 @@ |
|||||
<template> |
<template> |
||||
<div class="container"> |
<div class="container"> |
||||
<div class="nav"> |
<div class="nav"> |
||||
<ul> |
<ul> |
||||
<li v-for="(item, index) in items" :key="index" @click="selectItem(index)" |
<li |
||||
:class="{ active: index === activeIndex }"> |
v-for="(item, index) in items" |
||||
{{ item }} |
:key="index" |
||||
</li> |
@click="selectItem(index)" |
||||
</ul> |
:class="{ active: index === activeIndex }" |
||||
</div> |
> |
||||
<div class="setting"> |
{{ item }} |
||||
<div v-if="0 === activeIndex"> |
</li> |
||||
<div class="setting-item"> |
</ul> |
||||
<h1 class="setting-title">{{ t("background") }}</h1> |
</div> |
||||
</div> |
<div class="setting"> |
||||
<div class="setting-item"> |
<div v-if="0 === activeIndex"> |
||||
<el-select v-model="config.background.type"> |
<div class="setting-item"> |
||||
<el-option v-for="(item, key) in desktopOptions" :key="key" :label="item.label" :value="item.value" /> |
<h1 class="setting-title">{{ t("background") }}</h1> |
||||
</el-select> |
</div> |
||||
</div> |
<div class="setting-item"> |
||||
<template v-if="config.background.type === 'color'"> |
<el-select v-model="config.background.type"> |
||||
<div class="setting-item"> |
<el-option |
||||
<label> </label> |
v-for="(item, key) in desktopOptions" |
||||
<ColorPicker v-model:modelValue="config.background.color" @update:modelValue="onColorChange"></ColorPicker> |
:key="key" |
||||
</div> |
:label="item.label" |
||||
</template> |
:value="item.value" |
||||
<template v-if="config.background.type === 'image'"> |
/> |
||||
<div class="setting-item"> |
</el-select> |
||||
<ul class="image-gallery"> |
</div> |
||||
<li v-for="(item, index) in config.background.imageList" :key="index" |
<template v-if="config.background.type === 'color'"> |
||||
:class="config.background.url === item ? 'selected' : ''" @click="setBg(item)"> |
<div class="setting-item"> |
||||
<img :src="item" /> |
<label> </label> |
||||
</li> |
<ColorPicker |
||||
</ul> |
v-model:modelValue="config.background.color" |
||||
</div> |
@update:modelValue="onColorChange" |
||||
<div class="setting-item"> |
></ColorPicker> |
||||
<label> </label> |
</div> |
||||
</div> |
</template> |
||||
</template> |
<template v-if="config.background.type === 'image'"> |
||||
</div> |
<div class="setting-item"> |
||||
<div v-if="1 === activeIndex"> |
<ul class="image-gallery"> |
||||
<div class="setting-item"> |
<li |
||||
<h1 class="setting-title">锁屏</h1> |
v-for="(item, index) in config.background |
||||
</div> |
.imageList" |
||||
<div class="setting-item"> |
:key="index" |
||||
<label> {{ t('account') }} </label> |
:class=" |
||||
<el-input v-model="account.username" :placeholder="t('account')" clearable /> |
config.background.url === item |
||||
</div> |
? 'selected' |
||||
<div class="setting-item"> |
: '' |
||||
<label> {{ t('password') }} </label> |
" |
||||
<el-input v-model="account.password" type="password" :placeholder="t('password')" clearable /> |
@click="setBg(item)" |
||||
</div> |
> |
||||
|
<img :src="item" /> |
||||
|
</li> |
||||
|
</ul> |
||||
|
</div> |
||||
|
<div class="setting-item"> |
||||
|
<label> </label> |
||||
|
</div> |
||||
|
</template> |
||||
|
</div> |
||||
|
<div v-if="1 === activeIndex"> |
||||
|
<div class="setting-item"> |
||||
|
<h1 class="setting-title">锁屏</h1> |
||||
|
</div> |
||||
|
<div class="setting-item"> |
||||
|
<label> {{ t("account") }} </label> |
||||
|
<el-input |
||||
|
v-model="account.username" |
||||
|
:placeholder="t('account')" |
||||
|
clearable |
||||
|
/> |
||||
|
</div> |
||||
|
<div class="setting-item"> |
||||
|
<label> {{ t("password") }} </label> |
||||
|
<el-input |
||||
|
v-model="account.password" |
||||
|
type="password" |
||||
|
:placeholder="t('password')" |
||||
|
clearable |
||||
|
/> |
||||
|
</div> |
||||
|
|
||||
<div class="setting-item"> |
<div class="setting-item"> |
||||
<label></label> |
<label></label> |
||||
<el-button @click="submit" type="primary"> |
<el-button |
||||
{{ t('confirm') }} |
@click="submit" |
||||
</el-button> |
type="primary" |
||||
</div> |
> |
||||
</div> |
<span v-if="loginOrRegister">锁屏</span> |
||||
<div v-if="2 === activeIndex"> |
<span v-else>立即注册</span> |
||||
<div class="setting-item"> |
</el-button> |
||||
<h1 class="setting-title">广告与更新提示</h1> |
</div> |
||||
|
|
||||
</div> |
<div class="setting-item"> |
||||
<div class="setting-item"> |
<label></label> |
||||
<label></label> |
<small |
||||
<el-switch v-model="ad" active-text="开启" inactive-text="关闭" size="large" :before-change="setAd"></el-switch> |
v-if="loginOrRegister" |
||||
</div> |
style="font-size: 12px" |
||||
</div> |
>还没有账号?<a |
||||
<div v-if="3 === activeIndex"> |
href="#" |
||||
<div class="setting-item"> |
@click.prevent="loginOrRegister = false" |
||||
<h1 class="setting-title">{{ t("language") }}</h1> |
><span>立即注册</span></a |
||||
</div> |
></small |
||||
<div class="setting-item"> |
> |
||||
<label></label> |
<span |
||||
<el-select v-model="modelvalue"> |
v-else |
||||
<el-option v-for="(item, key) in langList" :key="key" :label="item.label" :value="item.value" /> |
style="font-size: 12px" |
||||
</el-select> |
> |
||||
</div> |
<span>注册完成,</span> |
||||
|
<a |
||||
|
href="#" |
||||
|
@click.prevent="loginOrRegister = true" |
||||
|
><span>点我返回</span></a |
||||
|
> |
||||
|
</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div v-if="2 === activeIndex"> |
||||
|
<div class="setting-item"> |
||||
|
<h1 class="setting-title">广告与更新提示</h1> |
||||
|
</div> |
||||
|
<div class="setting-item"> |
||||
|
<label></label> |
||||
|
<el-switch |
||||
|
v-model="ad" |
||||
|
active-text="开启" |
||||
|
inactive-text="关闭" |
||||
|
size="large" |
||||
|
:before-change="setAd" |
||||
|
></el-switch> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div v-if="3 === activeIndex"> |
||||
|
<div class="setting-item"> |
||||
|
<h1 class="setting-title">{{ t("language") }}</h1> |
||||
|
</div> |
||||
|
<div class="setting-item"> |
||||
|
<label></label> |
||||
|
<el-select v-model="modelvalue"> |
||||
|
<el-option |
||||
|
v-for="(item, key) in langList" |
||||
|
:key="key" |
||||
|
:label="item.label" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</div> |
||||
|
|
||||
<div class="setting-item"> |
<div class="setting-item"> |
||||
<label></label> |
<label></label> |
||||
<el-button @click="submitLang" type="primary"> |
<el-button |
||||
{{ t("confirm") }} |
@click="submitLang" |
||||
</el-button> |
type="primary" |
||||
</div> |
> |
||||
</div> |
{{ t("confirm") }} |
||||
</div> |
</el-button> |
||||
</div> |
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||
|
import { getLang, setLang, t } from "@/i18n"; |
||||
|
import { |
||||
|
getSystemConfig, |
||||
|
getSystemKey, |
||||
|
setSystemConfig, |
||||
|
setSystemKey, |
||||
|
} from "@/system/config"; |
||||
|
import { useSystem } from "@/system/index.ts"; |
||||
|
import { SystemStateEnum } from "@/system/type/enum"; |
||||
|
import { notifyError, notifySuccess } from "@/util/msg"; |
||||
|
import { ElMessageBox } from "element-plus"; |
||||
|
import { ref, watch } from "vue"; |
||||
|
import { useI18n } from "vue-i18n"; |
||||
|
const { locale } = useI18n(); |
||||
|
const sys = useSystem(); |
||||
|
const items = [t("background"), "锁屏设置", "广告设置", "语言"]; |
||||
|
const activeIndex = ref(0); |
||||
|
const account = ref(getSystemKey("account")); |
||||
|
const ad = ref(account.value.ad); |
||||
|
const config: any = ref(getSystemConfig()); |
||||
|
const loginOrRegister = ref(true); |
||||
|
const langList = [ |
||||
|
{ |
||||
|
label: "中文", |
||||
|
value: "zh-cn", |
||||
|
}, |
||||
|
{ |
||||
|
label: "English", |
||||
|
value: "en", |
||||
|
}, |
||||
|
]; |
||||
|
const currentLang = getLang(); |
||||
|
const modelvalue = ref(currentLang); |
||||
|
const selectItem = (index: number) => { |
||||
|
activeIndex.value = index; |
||||
|
}; |
||||
|
const desktopOptions = [ |
||||
|
{ |
||||
|
label: t("image"), |
||||
|
value: "image", |
||||
|
}, |
||||
|
{ |
||||
|
label: t("color"), |
||||
|
value: "color", |
||||
|
}, |
||||
|
]; |
||||
|
async function submit() { |
||||
|
// setSystemKey("account", account.value); |
||||
|
// Dialog.showMessageBox({ |
||||
|
// message: t("save.success"), |
||||
|
// title: t("account"), |
||||
|
// type: "info", |
||||
|
// }).then(() => { |
||||
|
// location.reload(); |
||||
|
// }); |
||||
|
const data = { |
||||
|
username: account.value.username, |
||||
|
password: account.value.password, |
||||
|
}; |
||||
|
|
||||
import { ref } from 'vue'; |
const aiUrl = config.value.aiUrl; |
||||
import { Dialog, useSystem } from '@/system/index.ts'; |
if (!loginOrRegister.value) { |
||||
import { getSystemKey, setSystemKey, getSystemConfig, setSystemConfig } from '@/system/config' |
console.log(data); |
||||
import { ElMessageBox } from 'element-plus' |
|
||||
import { getLang, setLang, t } from "@/i18n"; |
|
||||
import { useI18n } from "vue-i18n"; |
|
||||
const { locale } = useI18n(); |
|
||||
const sys = useSystem(); |
|
||||
const items = [t("background"), '锁屏设置', '广告设置', '语言']; |
|
||||
const activeIndex = ref(0); |
|
||||
const account = ref(getSystemKey('account')); |
|
||||
const ad = ref(account.value.ad) |
|
||||
const config: any = ref(getSystemConfig()); |
|
||||
const langList = [ |
|
||||
{ |
|
||||
label: "中文", |
|
||||
value: "zh-cn", |
|
||||
}, |
|
||||
{ |
|
||||
label: "English", |
|
||||
value: "en", |
|
||||
}, |
|
||||
]; |
|
||||
const currentLang = getLang(); |
|
||||
const modelvalue = ref(currentLang); |
|
||||
const selectItem = (index: number) => { |
|
||||
activeIndex.value = index; |
|
||||
}; |
|
||||
const desktopOptions = [ |
|
||||
{ |
|
||||
label: t("image"), |
|
||||
value: "image", |
|
||||
}, |
|
||||
{ |
|
||||
label: t("color"), |
|
||||
value: "color", |
|
||||
}, |
|
||||
]; |
|
||||
async function submit() { |
|
||||
setSystemKey('account', account.value); |
|
||||
Dialog.showMessageBox({ |
|
||||
message: t('save.success'), |
|
||||
title: t('account'), |
|
||||
type: 'info', |
|
||||
}).then(() => { |
|
||||
location.reload(); |
|
||||
}); |
|
||||
} |
|
||||
function setAd() { |
|
||||
const data = toRaw(account.value) |
|
||||
if (ad.value) { |
|
||||
return new Promise((resolve) => { |
|
||||
setTimeout(() => { |
|
||||
ElMessageBox.confirm( |
|
||||
'广告关闭后您将收不到任何系统通知和更新提示!', |
|
||||
'Warning', |
|
||||
{ |
|
||||
confirmButtonText: '确定关闭', |
|
||||
cancelButtonText: '取消', |
|
||||
type: 'warning', |
|
||||
} |
|
||||
) |
|
||||
.then(() => { |
|
||||
data.ad = false |
|
||||
setSystemKey('account', data); |
|
||||
return resolve(true) |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
return resolve(false) |
|
||||
}) |
|
||||
|
|
||||
}, 1000) |
try { |
||||
}) |
const response = await fetch(aiUrl + "/user/register", { |
||||
} else { |
method: "POST", |
||||
data.ad = true |
headers: { |
||||
setSystemKey('account', data); |
"Content-Type": "application/json", |
||||
return Promise.resolve(true) |
}, |
||||
} |
body: JSON.stringify(data), |
||||
|
}); |
||||
|
|
||||
} |
if (response.ok) { |
||||
function setBg(item: any) { |
const result = await response.json(); |
||||
config.value.background.url = item |
if (result.code == 0) { |
||||
config.value.background.type = "image"; |
notifySuccess("注册成功"); |
||||
setSystemConfig(config.value); |
loginOrRegister.value = true; |
||||
sys.initBackground(); |
} else { |
||||
|
notifyError("注册失败"); |
||||
|
} |
||||
|
} else { |
||||
|
notifyError("注册失败"); |
||||
|
} |
||||
|
} catch (error) { |
||||
|
notifyError("注册失败"); |
||||
|
console.error("请求错误:", error); |
||||
|
} |
||||
|
} else { |
||||
|
const response = await fetch(aiUrl + "/user/screen/lock", { |
||||
|
method: "POST", |
||||
|
headers: { |
||||
|
"Content-Type": "application/json", |
||||
|
}, |
||||
|
body: JSON.stringify(data), |
||||
|
}); |
||||
|
|
||||
} |
if (response.ok) { |
||||
function onColorChange(color: string) { |
const result = await response.json(); |
||||
config.value.background.color = color; |
if (result.code == 0) { |
||||
config.value.background.type = "color"; |
notifySuccess("锁屏成功"); |
||||
setSystemConfig(config.value); |
loginOrRegister.value = true; |
||||
sys.initBackground(); |
// 获取返回头中的sysuser |
||||
} |
const data = { |
||||
async function submitLang() { |
sysuser: result.data, |
||||
|
lock: true, |
||||
|
}; |
||||
|
localStorage.setItem("syslock", JSON.stringify(data)); |
||||
|
sys._rootState.state = SystemStateEnum.lock; |
||||
|
} else { |
||||
|
notifyError("锁屏失败"); |
||||
|
} |
||||
|
} else { |
||||
|
notifyError("锁屏失败"); |
||||
|
} |
||||
|
} |
||||
|
setSystemKey("account", account.value); |
||||
|
} |
||||
|
function setAd() { |
||||
|
const data = toRaw(account.value); |
||||
|
if (ad.value) { |
||||
|
return new Promise((resolve) => { |
||||
|
setTimeout(() => { |
||||
|
ElMessageBox.confirm( |
||||
|
"广告关闭后您将收不到任何系统通知和更新提示!", |
||||
|
"Warning", |
||||
|
{ |
||||
|
confirmButtonText: "确定关闭", |
||||
|
cancelButtonText: "取消", |
||||
|
type: "warning", |
||||
|
} |
||||
|
) |
||||
|
.then(() => { |
||||
|
data.ad = false; |
||||
|
setSystemKey("account", data); |
||||
|
return resolve(true); |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
return resolve(false); |
||||
|
}); |
||||
|
}, 1000); |
||||
|
}); |
||||
|
} else { |
||||
|
data.ad = true; |
||||
|
setSystemKey("account", data); |
||||
|
return Promise.resolve(true); |
||||
|
} |
||||
|
} |
||||
|
function setBg(item: any) { |
||||
|
config.value.background.url = item; |
||||
|
config.value.background.type = "image"; |
||||
|
setSystemConfig(config.value); |
||||
|
sys.initBackground(); |
||||
|
} |
||||
|
function onColorChange(color: string) { |
||||
|
config.value.background.color = color; |
||||
|
config.value.background.type = "color"; |
||||
|
setSystemConfig(config.value); |
||||
|
sys.initBackground(); |
||||
|
} |
||||
|
async function submitLang() { |
||||
setLang(modelvalue.value); |
setLang(modelvalue.value); |
||||
locale.value = modelvalue.value; |
locale.value = modelvalue.value; |
||||
ElMessageBox.alert(t("save.success"), t("language"), { |
ElMessageBox.alert(t("save.success"), t("language"), { |
||||
confirmButtonText: "OK", |
confirmButtonText: "OK", |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
|
watch(loginOrRegister, () => { |
||||
|
account.value.username = ""; |
||||
|
account.value.password = ""; |
||||
|
}); |
||||
</script> |
</script> |
||||
<style scoped> |
<style scoped> |
||||
@import "./setStyle.css"; |
@import "./setStyle.css"; |
||||
@import "@/assets/imglist.scss"; |
@import "@/assets/imglist.scss"; |
||||
</style> |
</style> |
||||
|
Loading…
Reference in new issue