Browse Source

change usertype

master
godo 9 months ago
parent
commit
af818db7ef
  1. 5
      CHANGELOG.md
  2. 19
      frontend/package-lock.json
  3. 1
      frontend/package.json
  4. 132
      frontend/src/components/setting/SetSystem.vue
  5. 11
      frontend/src/system/config.ts

5
CHANGELOG.md

@ -28,3 +28,8 @@ bug梳理:
5. web 的甘特图保存不了 5. web 的甘特图保存不了
6. 场景适用性:系统默认连接gitee远程软件安装包,缺少默认读取本地安装包路径的json配置文件的打包设置选项(比如在安装时自动读取安装U盘当前目录中/或已直接打包进安装包中的mysql/nginx/php/python本地离线安装包、以及企业自用OA WebApp的本地离线安装包,无需联网,直接同步离线安装) 6. 场景适用性:系统默认连接gitee远程软件安装包,缺少默认读取本地安装包路径的json配置文件的打包设置选项(比如在安装时自动读取安装U盘当前目录中/或已直接打包进安装包中的mysql/nginx/php/python本地离线安装包、以及企业自用OA WebApp的本地离线安装包,无需联网,直接同步离线安装)
7. 功能完整性:安装的服务型应用(如mysql/nginx/php/python)没有跟随软件环境启动后自动启动的设置选项,依赖于服务型应用的AI Web UI、php /python应用没有创建桌面快捷方式/菜单快捷方式的入口(即:AI Web UI、php /python应用无法安装和自动开箱即用)。 7. 功能完整性:安装的服务型应用(如mysql/nginx/php/python)没有跟随软件环境启动后自动启动的设置选项,依赖于服务型应用的AI Web UI、php /python应用没有创建桌面快捷方式/菜单快捷方式的入口(即:AI Web UI、php /python应用无法安装和自动开箱即用)。
### 后续开放:
1. 优化内网聊天
2. 新增 权限管理 文件加密 以及远程存储服务端(企业版本)
3. 应用商店重构 陆续会新增php/node/go/java

19
frontend/package-lock.json

@ -13,6 +13,7 @@
"dexie": "^4.0.8", "dexie": "^4.0.8",
"element-plus": "^2.7.7", "element-plus": "^2.7.7",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"js-md5": "^0.8.3",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"lunar-typescript": "^1.7.5", "lunar-typescript": "^1.7.5",
"moment": "^2.30.1", "moment": "^2.30.1",
@ -1262,6 +1263,17 @@
"integrity": "sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==", "integrity": "sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==",
"dev": true "dev": true
}, },
"node_modules/core-js": {
"version": "3.38.1",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.38.1.tgz",
"integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==",
"hasInstallScript": true,
"peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/core-util-is": { "node_modules/core-util-is": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz",
@ -1566,6 +1578,11 @@
"resolved": "https://registry.npmmirror.com/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmmirror.com/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
}, },
"node_modules/js-md5": {
"version": "0.8.3",
"resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.8.3.tgz",
"integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ=="
},
"node_modules/js-tokens": { "node_modules/js-tokens": {
"version": "9.0.0", "version": "9.0.0",
"resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-9.0.0.tgz", "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-9.0.0.tgz",
@ -2180,7 +2197,7 @@
"version": "5.5.4", "version": "5.5.4",
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.5.4.tgz", "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.5.4.tgz",
"integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==",
"dev": true, "devOptional": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"

1
frontend/package.json

@ -14,6 +14,7 @@
"dexie": "^4.0.8", "dexie": "^4.0.8",
"element-plus": "^2.7.7", "element-plus": "^2.7.7",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"js-md5": "^0.8.3",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"lunar-typescript": "^1.7.5", "lunar-typescript": "^1.7.5",
"moment": "^2.30.1", "moment": "^2.30.1",

132
frontend/src/components/setting/SetSystem.vue

@ -2,12 +2,8 @@
<div class="container"> <div class="container">
<div class="nav"> <div class="nav">
<ul> <ul>
<li <li v-for="(item, index) in items" :key="index" @click="selectItem(index)"
v-for="(item, index) in items" :class="{ active: index === activeIndex }">
:key="index"
@click="selectItem(index)"
:class="{ active: index === activeIndex }"
>
{{ item }} {{ item }}
</li> </li>
</ul> </ul>
@ -17,38 +13,23 @@
<div class="setting-item" style="margin-top: 60px"> <div class="setting-item" style="margin-top: 60px">
<label>存储方式</label> <label>存储方式</label>
<el-select v-model="config.storeType"> <el-select v-model="config.storeType">
<el-option <el-option v-for="(item, key) in storeList" :key="key" :label="item.title" :value="item.value" />
v-for="(item, key) in storeList"
:key="key"
:label="item.title"
:value="item.value"
/>
</el-select> </el-select>
</div> </div>
<div class="setting-item" v-if="config.storeType === 'local'"> <div class="setting-item" v-if="config.storeType === 'local'">
<label>存储地址</label> <label>存储地址</label>
<el-input <el-input v-model="config.storePath" @click="selectFile()" placeholder="可为空,为空则取系统默认存储地址" />
v-model="config.storePath"
@click="selectFile()"
placeholder="可为空,为空则取系统默认存储地址"
/>
</div> </div>
<template v-if="config.storeType === 'net'"> <template v-if="config.storeType === 'net'">
<div class="setting-item"> <div class="setting-item">
<label>服务器地址</label> <label>服务器地址</label>
<el-input <el-input v-model="config.storenet.url" placeholder="http://192.168.1.16:56780 不要加斜杠" />
v-model="config.storenet.url"
placeholder="http://192.168.1.16:56780 不要加斜杠"
/>
</div> </div>
</template> </template>
<template v-if="config.storeType === 'webdav'"> <template v-if="config.storeType === 'webdav'">
<div class="setting-item"> <div class="setting-item">
<label>服务器地址</label> <label>服务器地址</label>
<el-input <el-input v-model="config.webdavClient.url" placeholder="https://godoos.com/webdav 不要加斜杠" />
v-model="config.webdavClient.url"
placeholder="https://godoos.com/webdav/"
/>
</div> </div>
<div class="setting-item"> <div class="setting-item">
<label>登陆用户名</label> <label>登陆用户名</label>
@ -82,12 +63,35 @@
<div class="setting-item"> <div class="setting-item">
<label></label> <label></label>
<el-button @click="selectZipfile" type="primary"> 导入 </el-button> <el-button @click="selectZipfile" type="primary"> 导入 </el-button>
<input <input type="file" accept=".zip" style="display: none" ref="zipFileInput" />
type="file" </div>
accept=".zip" </div>
style="display: none" <div v-if="2 === activeIndex">
ref="zipFileInput" <div class="setting-item" style="margin-top: 60px">
/> <label>用户角色</label>
<el-select v-model="config.userType">
<el-option v-for="(item, key) in userTypes" :key="key" :label="item.title" :value="item.value" />
</el-select>
</div>
<template v-if="config.userType === 'member'">
<div class="setting-item">
<label>服务器地址</label>
<el-input v-model="config.userInfo.url" placeholder="网址或域名,例子:https://godoos.com 不要加斜杠" />
</div>
<div class="setting-item">
<label>用户名</label>
<el-input v-model="config.userInfo.username" placeholder="登录用户名" />
</div>
<div class="setting-item">
<label>密码</label>
<el-input v-model="config.userInfo.password" type="password" placeholder="登录密码" />
</div>
</template>
<div class="setting-item">
<label></label>
<el-button @click="saveUserInfo" type="primary">
{{ t("confirm") }}
</el-button>
</div> </div>
</div> </div>
</div> </div>
@ -101,6 +105,8 @@ import JSZip from "jszip";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import { getSystemConfig, setSystemConfig } from "@/system/config"; import { getSystemConfig, setSystemConfig } from "@/system/config";
import { OpenDirDialog, RestartApp } from "@/util/goutil"; import { OpenDirDialog, RestartApp } from "@/util/goutil";
import { notifyError, notifySuccess } from "@/util/msg";
import { md5 } from 'js-md5';
const config = ref(getSystemConfig()); const config = ref(getSystemConfig());
const sys = inject<System>("system")!; const sys = inject<System>("system")!;
let zipFile: File | undefined = undefined; let zipFile: File | undefined = undefined;
@ -125,8 +131,18 @@ const storeList = [
}, },
]; ];
const items = ["个人存储", "备份还原"]; const items = ["个人存储", "备份还原", "用户角色"];
const urlRegex = /^(https?:\/\/)/;
const userTypes = [
{
title: "独立用户",
value: "person",
},
{
title: "企业用户",
value: "member",
},
]
const activeIndex = ref(0); const activeIndex = ref(0);
const selectItem = (index: number) => { const selectItem = (index: number) => {
@ -231,7 +247,53 @@ function submitOsInfo() {
}); });
} }
} }
async function saveUserInfo() {
const saveData = toRaw(config.value);
if (saveData.userType == 'person') {
setSystemConfig(saveData);
notifySuccess("保存成功");
return
}
if (!urlRegex.test(saveData.userInfo.url.trim())) {
Dialog.showMessageBox({
message: "服务器地址格式错误",
type: "error",
});
return;
}
if (saveData.userInfo.username === "" || saveData.userInfo.password === "") {
Dialog.showMessageBox({
message: "用户名或密码不能为空",
type: "error",
});
return;
}
const password = md5(saveData.userInfo.password)
const serverUrl = saveData.userInfo.url + '/api/v1/login'
const res = await fetch(serverUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: saveData.userInfo.username,
password: password,
}),
});
if (res.status === 200) {
const data = await res.json();
if (data.success) {
data.data.url = saveData.userInfo.url
data.data.password = password
saveData.userInfo = data.data
setSystemConfig(saveData);
notifySuccess("登录成功");
return
}
}
notifyError("登录失败");
return
}
async function exportBackup() { async function exportBackup() {
const { setProgress } = Dialog.showProcessDialog({ const { setProgress } = Dialog.showProcessDialog({
message: `正在打包`, message: `正在打包`,
@ -334,6 +396,8 @@ async function importBackup(path = "") {
}, 100); }, 100);
} }
} }
</script> </script>
<style scoped> <style scoped>
@import "./setStyle.css"; @import "./setStyle.css";

11
frontend/src/system/config.ts

@ -26,11 +26,13 @@ export const getSystemConfig = (ifset = false) => {
if (!config.apiUrl) { if (!config.apiUrl) {
config.apiUrl = 'http://localhost:56780'; config.apiUrl = 'http://localhost:56780';
} }
if(!config.userType){
config.userType = 'person'
}
// 初始化用户信息,若本地存储中已存在则不进行覆盖 // 初始化用户信息,若本地存储中已存在则不进行覆盖
if (!config.userInfo) { if (!config.userInfo) {
config.userInfo = { config.userInfo = {
serverUrl:'', url:'',
username: '', username: '',
password: '', password: '',
memberId: 0, memberId: 0,
@ -38,8 +40,9 @@ export const getSystemConfig = (ifset = false) => {
avatar: '', avatar: '',
email: '', email: '',
mobile: '', mobile: '',
role: '', role: 0,
department: '' department: 0,
token:''
}; };
} }

Loading…
Cancel
Save