diff --git a/frontend/components.d.ts b/frontend/components.d.ts index f8bbe10..f86d08a 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -42,11 +42,9 @@ declare module 'vue' { EditType: typeof import('./src/components/builtin/EditType.vue')['default'] ElBadge: typeof import('element-plus/es')['ElBadge'] ElButton: typeof import('element-plus/es')['ElButton'] - ElCard: typeof import('element-plus/es')['ElCard'] ElCarousel: typeof import('element-plus/es')['ElCarousel'] ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem'] ElCol: typeof import('element-plus/es')['ElCol'] - ElColorPicker: typeof import('element-plus/es')['ElColorPicker'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] ElEmpty: typeof import('element-plus/es')['ElEmpty'] @@ -64,7 +62,6 @@ declare module 'vue' { ElSpace: typeof import('element-plus/es')['ElSpace'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] - ElText: typeof import('element-plus/es')['ElText'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] Error: typeof import('./src/components/taskbar/Error.vue')['default'] FileIcon: typeof import('./src/components/builtin/FileIcon.vue')['default'] @@ -81,6 +78,8 @@ declare module 'vue' { InstallMember: typeof import('./src/components/install/InstallMember.vue')['default'] InstallPerson: typeof import('./src/components/install/InstallPerson.vue')['default'] LockDesktop: typeof import('./src/components/desktop/LockDesktop.vue')['default'] + LoginDeskop: typeof import('./src/components/desktop/LoginDeskop.vue')['default'] + LoginDesktop: typeof import('./src/components/desktop/LoginDesktop.vue')['default'] Magnet: typeof import('./src/components/taskbar/Magnet.vue')['default'] MarkDown: typeof import('./src/components/builtin/MarkDown.vue')['default'] MenuBar: typeof import('./src/components/window/MenuBar.vue')['default'] diff --git a/frontend/src/components/desktop/DesktopBackground.vue b/frontend/src/components/desktop/DesktopBackground.vue index 486f4d2..3ddc442 100644 --- a/frontend/src/components/desktop/DesktopBackground.vue +++ b/frontend/src/components/desktop/DesktopBackground.vue @@ -18,7 +18,7 @@ import { onMounted, ref, watch } from "vue"; import { useSystem } from "@/system"; const rootState = useSystem()._rootState; const backgroundType = ref("color"); -const background = ref("#3A98CE"); +const background:any = ref("#3A98CE"); const loaded = ref(false); function imgload() { @@ -32,8 +32,8 @@ watch(rootState.options, (nv) => { }); function refershBack(val: string | undefined) { background.value = val || "#3A98CE"; - - if (background.value.startsWith("/image/")) { + console.log(background.value) + if (background.value || background.value.startsWith("/image/")) { backgroundType.value = "image"; } else { backgroundType.value = "color"; diff --git a/frontend/src/components/desktop/LockDesktop.vue b/frontend/src/components/desktop/LockDesktop.vue index a31ba6e..a9c74a3 100644 --- a/frontend/src/components/desktop/LockDesktop.vue +++ b/frontend/src/components/desktop/LockDesktop.vue @@ -1,31 +1,71 @@ @@ -33,60 +73,32 @@ async function onLogin() {
- + -
- +
- + @@ -113,6 +125,7 @@ async function onLogin() { background-color: rgba(25, 28, 34, 0.78); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); + .login-box { position: absolute; top: 45%; @@ -122,12 +135,14 @@ async function onLogin() { flex-direction: column; justify-content: center; align-items: center; + .ant-avatar { text-align: center; vertical-align: middle; background: #ccc; border-radius: 50%; margin-bottom: 14px; + .anticon { display: inline-block; color: inherit; @@ -141,14 +156,17 @@ async function onLogin() { -moz-osx-font-smoothing: grayscale; } } + .ant-input-group { display: flex; + .ant-input { padding: 6px 11px; font-size: 16px; outline: none; border: none; } + .ant-btn-primary { color: #fff; background: #1890ff; @@ -163,11 +181,13 @@ async function onLogin() { transition: all 0.3s; cursor: pointer; } + .ant-btn-primary:hover { color: #fff; background: #40a9ff; border-color: #40a9ff; } + .ant-btn-primary:active { color: #fff; background: #096dd9; @@ -180,6 +200,7 @@ async function onLogin() { margin-bottom: 14px; } } + .tip { padding: 4px 0px; font-size: 12px; @@ -190,16 +211,20 @@ async function onLogin() { .screen-hidean { animation: outan 0.5s forwards; } + .screen-hide { display: none; } + @keyframes outan { 0% { opacity: 1; } + 30% { opacity: 0; } + 100% { transform: translateY(-100%); opacity: 0; diff --git a/frontend/src/components/setting/SetSystem.vue b/frontend/src/components/setting/SetSystem.vue index 9d3f25c..f30dc94 100644 --- a/frontend/src/components/setting/SetSystem.vue +++ b/frontend/src/components/setting/SetSystem.vue @@ -251,6 +251,7 @@ async function saveUserInfo() { if (saveData.userType == 'person') { setSystemConfig(saveData); notifySuccess("保存成功"); + RestartApp(); return } if (!urlRegex.test(saveData.userInfo.url.trim())) { diff --git a/frontend/src/system/index.ts b/frontend/src/system/index.ts index 2cce232..4c5f6da 100644 --- a/frontend/src/system/index.ts +++ b/frontend/src/system/index.ts @@ -22,9 +22,10 @@ import { Notify, NotifyConstructorOptions } from './notification/Notification'; import { Dialog } from './window/Dialog'; import { pick } from '../util/modash'; import { Tray, TrayOptions } from './menu/Tary'; -import { getSystemConfig, getSystemKey, setSystemKey, setSystemConfig, clearSystemConfig, getFileUrl,fetchGet } from './config' +import { getSystemConfig, getSystemKey, setSystemKey, setSystemConfig, clearSystemConfig, getFileUrl, fetchGet, getClientId } from './config' import { useUpgradeStore } from '@/stores/upgrade'; import { RestartApp } from '@/util/goutil'; +import { notifyError, notifySuccess } from '@/util/msg'; export type OsPlugin = (system: System) => void; export type FileOpener = { @@ -92,17 +93,17 @@ export class System { private async initSystem() { this._rootState.state = SystemStateEnum.opening; this.fs = useOsFile(); // 初始化文件系统 - initBuiltinApp(this); + initBuiltinApp(this); initBuiltinFileOpener(this); // 注册内建文件打开器 await this.initSavedConfig(); // 初始化保存的配置 // 判断是否登录 - this.isLogin(); + await this.isLogin(); initEventListener(); // 初始化事件侦听 - + this.initBackground(); // 初始化壁纸 this.refershAppList(); - + setTimeout(() => { const upgradeStore = useUpgradeStore(); upgradeStore.systemMessage() @@ -114,29 +115,85 @@ export class System { /** * @description: 判断是否登录 */ - private isLogin() { - if (!this._options.login) { - this._rootState.state = SystemStateEnum.open; - return; - } else { - if (this._options.login.init?.()) { + private async isLogin() { + const config = getSystemConfig(); + if (config.userType == 'person') { + if (!this._options.login) { this._rootState.state = SystemStateEnum.open; return; + } else { + if (this._options.login.init?.()) { + this._rootState.state = SystemStateEnum.open; + return; + } + + this._rootState.state = SystemStateEnum.lock; + const tempCallBack = this._options.loginCallback; + if (!tempCallBack) { + throw new Error('没有设置登录回调函数'); + } + this._options.loginCallback = async (username: string, password: string) => { + const res = await tempCallBack(username, password); + if (res) { + this._rootState.state = SystemStateEnum.open; + return true; + } + return false; + }; } + } else { + const userInfo = config.userInfo; + if (userInfo.url == '') { + return true; + } + const res = await fetchGet(`${userInfo.url}/member/islogin`); + if (!res.ok) { + notifyError('登录失败,请检查网络连接或重新登录'); + return true; + } + const data = await res.json(); + //console.log(data) + if (data.success) { + this._rootState.state = SystemStateEnum.open; + return true; + } else { + //return true; + this._rootState.state = SystemStateEnum.lock; - this._rootState.state = SystemStateEnum.lock; - const tempCallBack = this._options.loginCallback; - if (!tempCallBack) { - throw new Error('没有设置登录回调函数'); + this._options.loginCallback = async (username: string, password: string) => { + const serverUrl = config.userInfo.url + '/member/login' + const res: any = await fetch(serverUrl, { + method: "POST", + body: JSON.stringify({ + username: username, + password: password, + clientId: getClientId(), + }), + }); + if (!res.ok) { + return false + } + const jsondata = await res.json(); + if (jsondata.success) { + jsondata.data.url = config.userInfo.url + jsondata.data.password = password + config.userInfo = jsondata.data + setSystemConfig(config); + this._rootState.state = SystemStateEnum.open; + this.refershAppList() + return true + } else { + notifyError(jsondata.message) + return false + } + }; + // //const tmpCallBack = this._options.authCallback; + // this._options.authCallback = async (username: string, password: string, captcha :string) => { + // //this._rootState.state = SystemStateEnum.open; + // return false; + // }; + // return false; } - this._options.loginCallback = async (username: string, password: string) => { - const res = await tempCallBack(username, password); - if (res) { - this._rootState.state = SystemStateEnum.open; - return true; - } - return false; - }; } } @@ -159,12 +216,12 @@ export class System { } refershAppList() { - + const system = useSystem(); if (!system) return; const fileUrl = getFileUrl(); if (!fileUrl) return; - + fetchGet(`${fileUrl}/desktop`).then(res => res.json()).then(res => { if (res && res.code == 0) { system._rootState.apps.splice(0, system._rootState.apps.length, ...res.data.apps); @@ -173,7 +230,7 @@ export class System { }) } - + initAppList() { this.isReadyUpdateAppList = true; nextTick(() => { diff --git a/frontend/src/system/type/enum.ts b/frontend/src/system/type/enum.ts index 0649c8a..2900aa7 100644 --- a/frontend/src/system/type/enum.ts +++ b/frontend/src/system/type/enum.ts @@ -2,5 +2,5 @@ export const enum SystemStateEnum { close = 0, opening = 1, open = 2, - lock = 3, + lock = 3 }