Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd2cf1c576 | ||
|
|
b7e9e5e472 | ||
|
|
491f2afe3f |
6
docs/releases/1.6.2.md
Normal file
6
docs/releases/1.6.2.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# 1.6.2
|
||||||
|
|
||||||
|
## 系统优化
|
||||||
|
|
||||||
|
- 简化用户角色体系,移除未使用的 Guest 角色。
|
||||||
|
- 优化类型安全性,加强用户认证流程健壮性。
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "erpauto",
|
"name": "erpauto",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "erpauto",
|
"name": "erpauto",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.929.0",
|
"@aws-sdk/client-s3": "^3.929.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "erpauto",
|
"name": "erpauto",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"description": "An Electron application with React and TypeScript",
|
"description": "An Electron application with React and TypeScript",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "example.com",
|
"author": "example.com",
|
||||||
|
|||||||
@@ -28,7 +28,13 @@ export function registerSettingsHandlers(): void {
|
|||||||
|
|
||||||
ipcMain.handle(IPC_CHANNELS.SETTINGS_GET_USER_TYPE, async (): Promise<IpcResult<UserType>> => {
|
ipcMain.handle(IPC_CHANNELS.SETTINGS_GET_USER_TYPE, async (): Promise<IpcResult<UserType>> => {
|
||||||
return withErrorHandling(
|
return withErrorHandling(
|
||||||
async () => (sessionManager.getUserType() as UserType) || 'Guest',
|
async () => {
|
||||||
|
const userType = sessionManager.getUserType()
|
||||||
|
if (!userType) {
|
||||||
|
throw new ValidationError('未找到用户类型', 'VAL_INVALID_INPUT')
|
||||||
|
}
|
||||||
|
return userType as UserType
|
||||||
|
},
|
||||||
'settings:getUserType'
|
'settings:getUserType'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export type LoginRequestZod = z.infer<typeof LoginRequestSchema>
|
|||||||
export const UserInfoSchema = z.object({
|
export const UserInfoSchema = z.object({
|
||||||
id: z.number().int().positive(),
|
id: z.number().int().positive(),
|
||||||
username: z.string().min(1),
|
username: z.string().min(1),
|
||||||
userType: z.enum(['Admin', 'User', 'Guest']),
|
userType: z.enum(['Admin', 'User']),
|
||||||
computerName: z.string().optional()
|
computerName: z.string().optional()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class UpdateCatalogService {
|
|||||||
|
|
||||||
public getDialogCatalog(status: UpdateStatus, catalog: UpdateCatalog): UpdateDialogCatalog {
|
public getDialogCatalog(status: UpdateStatus, catalog: UpdateCatalog): UpdateDialogCatalog {
|
||||||
const currentUserType = status.currentUserType
|
const currentUserType = status.currentUserType
|
||||||
if (!status.enabled || !currentUserType || currentUserType === 'Guest') {
|
if (!status.enabled || !currentUserType) {
|
||||||
return { mode: 'disabled' }
|
return { mode: 'disabled' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export class UpdateService {
|
|||||||
this.ensureInitialized()
|
this.ensureInitialized()
|
||||||
this.status.currentUserType = userType
|
this.status.currentUserType = userType
|
||||||
|
|
||||||
if (!this.status.enabled || !userType || userType === 'Guest') {
|
if (!this.status.enabled || !userType) {
|
||||||
this.clearPolling()
|
this.clearPolling()
|
||||||
this.catalog = { stable: [], preview: [] }
|
this.catalog = { stable: [], preview: [] }
|
||||||
this.publishStatus({
|
this.publishStatus({
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export class BIPUsersDAO {
|
|||||||
return {
|
return {
|
||||||
id: row.ID as number,
|
id: row.ID as number,
|
||||||
username: row.UserName as string,
|
username: row.UserName as string,
|
||||||
userType: row.UserType as 'Admin' | 'User' | 'Guest'
|
userType: row.UserType as 'Admin' | 'User'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -157,7 +157,7 @@ export class BIPUsersDAO {
|
|||||||
return {
|
return {
|
||||||
id: row.ID as number,
|
id: row.ID as number,
|
||||||
username: row.UserName as string,
|
username: row.UserName as string,
|
||||||
userType: row.UserType as 'Admin' | 'User' | 'Guest'
|
userType: row.UserType as 'Admin' | 'User'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -198,7 +198,7 @@ export class BIPUsersDAO {
|
|||||||
return {
|
return {
|
||||||
id: row.ID as number,
|
id: row.ID as number,
|
||||||
username: row.UserName as string,
|
username: row.UserName as string,
|
||||||
userType: row.UserType as 'Admin' | 'User' | 'Guest'
|
userType: row.UserType as 'Admin' | 'User'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -216,7 +216,7 @@ export class BIPUsersDAO {
|
|||||||
return {
|
return {
|
||||||
id: row.ID as number,
|
id: row.ID as number,
|
||||||
username: row.UserName as string,
|
username: row.UserName as string,
|
||||||
userType: row.UserType as 'Admin' | 'User' | 'Guest'
|
userType: row.UserType as 'Admin' | 'User'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -254,7 +254,7 @@ export class BIPUsersDAO {
|
|||||||
return result.rows.map((row) => ({
|
return result.rows.map((row) => ({
|
||||||
id: row.ID as number,
|
id: row.ID as number,
|
||||||
username: row.UserName as string,
|
username: row.UserName as string,
|
||||||
userType: row.UserType as 'Admin' | 'User' | 'Guest',
|
userType: row.UserType as 'Admin' | 'User',
|
||||||
createTime: row.CreateTime as Date | undefined
|
createTime: row.CreateTime as Date | undefined
|
||||||
}))
|
}))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -270,7 +270,7 @@ export class BIPUsersDAO {
|
|||||||
* Create a new user
|
* Create a new user
|
||||||
* @param username - The username (must be unique)
|
* @param username - The username (must be unique)
|
||||||
* @param password - The password
|
* @param password - The password
|
||||||
* @param userType - User type ('Admin', 'User', or 'Guest')
|
* @param userType - User type ('Admin' or 'User')
|
||||||
* @param computerName - Optional computer name for silent login
|
* @param computerName - Optional computer name for silent login
|
||||||
* @returns True if successful
|
* @returns True if successful
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -126,13 +126,6 @@ export class SessionManager {
|
|||||||
return this.currentUser?.userType === 'Admin'
|
return this.currentUser?.userType === 'Admin'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the current user is a guest
|
|
||||||
*/
|
|
||||||
public isGuest(): boolean {
|
|
||||||
return this.currentUser?.userType === 'Guest'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current username
|
* Get the current username
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
/**
|
/**
|
||||||
* User type for settings permission control
|
* User type for settings permission control
|
||||||
*/
|
*/
|
||||||
export type UserType = 'Admin' | 'User' | 'Guest'
|
export type UserType = 'Admin' | 'User'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database type selection
|
* Database type selection
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/**
|
/**
|
||||||
* User type enumeration
|
* User type enumeration
|
||||||
*/
|
*/
|
||||||
export type UserType = 'Admin' | 'User' | 'Guest'
|
export type UserType = 'Admin' | 'User'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User information interface
|
* User information interface
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { Modal } from './ui/Modal'
|
|||||||
export interface UserInfo {
|
export interface UserInfo {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
userType: 'Admin' | 'User' | 'Guest'
|
userType: 'Admin' | 'User'
|
||||||
createTime?: Date
|
createTime?: Date
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +61,7 @@ export const UserSelectionDialog: React.FC<UserSelectionDialogProps> = ({
|
|||||||
|
|
||||||
const userTypeStyles: Record<string, string> = {
|
const userTypeStyles: Record<string, string> = {
|
||||||
Admin: 'bg-amber-50 text-amber-600',
|
Admin: 'bg-amber-50 text-amber-600',
|
||||||
User: 'bg-blue-50 text-blue-600',
|
User: 'bg-blue-50 text-blue-600'
|
||||||
Guest: 'bg-gray-100 text-gray-600'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOpen) return null
|
if (!isOpen) return null
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import UserSelectionDialog, { type UserInfo as SelectedUserInfo } from '../UserS
|
|||||||
|
|
||||||
interface CurrentUser {
|
interface CurrentUser {
|
||||||
username: string
|
username: string
|
||||||
userType: 'Admin' | 'User' | 'Guest'
|
userType: 'Admin' | 'User'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnauthenticatedAppProps {
|
interface UnauthenticatedAppProps {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export interface CurrentUser {
|
|||||||
export interface SelectedUserInfo {
|
export interface SelectedUserInfo {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
userType: 'Admin' | 'User' | 'Guest'
|
userType: 'Admin' | 'User'
|
||||||
computerName?: string
|
computerName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useState, useCallback } from 'react'
|
|||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
userType: 'Admin' | 'User' | 'Guest'
|
userType: 'Admin' | 'User'
|
||||||
computerName?: string
|
computerName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { create } from 'zustand'
|
|||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
userType: 'Admin' | 'User' | 'Guest'
|
userType: 'Admin' | 'User'
|
||||||
computerName?: string
|
computerName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user