Compare commits
2 Commits
178551efba
...
75d277a7b4
| Author | SHA1 | Date |
|---|---|---|
|
|
75d277a7b4 | |
|
|
71bbeb1c94 |
|
|
@ -15,7 +15,7 @@ VITE_APP_MONITOR_ADMIN = '/admin/applications'
|
|||
VITE_APP_SNAILJOB_ADMIN = '/snail-job'
|
||||
|
||||
# 生产环境
|
||||
VITE_APP_BASE_API = '/prod-api'
|
||||
VITE_APP_BASE_API = '/twk71hc7r9khxy2026v1'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
|
|
|||
|
|
@ -0,0 +1,207 @@
|
|||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
RuoYi-Vue-Plus is a multi-tenant management system frontend built with **Vue 3**, **TypeScript**, **Element Plus**, and **Vite**. This is the official UI for the RuoYi-Vue-Plus backend framework (distributed/microservices architecture).
|
||||
|
||||
**Tech Stack:** Vue 3.5+ | TypeScript 5.9+ | Element Plus 2.11+ | Vite 6+ | Pinia 3+ | Vue Router 4.6+
|
||||
|
||||
## Development Commands
|
||||
|
||||
```bash
|
||||
# Install dependencies (using npm mirror for China)
|
||||
npm install --registry=https://registry.npmmirror.com
|
||||
|
||||
# Start development server (runs on http://localhost:80)
|
||||
npm run dev
|
||||
|
||||
# Build for production
|
||||
npm run build:prod
|
||||
|
||||
# Build for development environment
|
||||
npm run build:dev
|
||||
|
||||
# Lint code
|
||||
npm run lint:eslint
|
||||
|
||||
# Fix linting issues automatically
|
||||
npm run lint:eslint:fix
|
||||
|
||||
# Format code with Prettier
|
||||
npm run prettier
|
||||
```
|
||||
|
||||
**Engine Requirements:** Node.js >= 18.18.0 | npm >= 8.9.0
|
||||
|
||||
## Architecture
|
||||
|
||||
### Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
├── api/ # API modules organized by domain (system, monitor, workflow, net, demo)
|
||||
├── assets/ # Static assets (images, styles, icons)
|
||||
├── components/ # Reusable components (UI + business components)
|
||||
├── directive/ # Custom Vue directives (v-auth, v-copy, etc.)
|
||||
├── enums/ # TypeScript enums and constants
|
||||
├── hooks/ # Vue 3 Composition API hooks
|
||||
├── lang/ # i18n language files (Chinese/English)
|
||||
├── layout/ # Layout components (Sidebar, Navbar, TagsView)
|
||||
├── plugins/ # Global plugins ($tab, $modal, $cache, $auth)
|
||||
├── router/ # Vue Router configuration
|
||||
├── store/ # Pinia state management
|
||||
├── types/ # TypeScript type definitions
|
||||
├── utils/ # Utility functions (request, crypto, validation)
|
||||
├── views/ # Page components (mirrors api structure)
|
||||
├── App.vue # Root component
|
||||
├── main.ts # Application entry point
|
||||
├── permission.ts # Route permission control
|
||||
└── settings.ts # Global settings
|
||||
```
|
||||
|
||||
### Dynamic Routing & Permissions
|
||||
|
||||
The application uses **backend-driven routing** with permission-based access control:
|
||||
|
||||
1. **Route Loading Flow** (`src/permission.ts`):
|
||||
- User authentication check via `getToken()`
|
||||
- If authenticated but no user info: fetch user info → generate routes → add routes dynamically
|
||||
- Routes are fetched from backend via `getRouters()` API
|
||||
- Components are lazy-loaded using `import.meta.glob('./../../views/**/*.vue')`
|
||||
|
||||
2. **Route Types**:
|
||||
- `constantRoutes`: Always accessible (login, 404, etc.)
|
||||
- `dynamicRoutes`: Permission-based routes added dynamically
|
||||
- Special components: `Layout`, `ParentView`, `InnerLink` (handled specially in `src/store/modules/permission.ts:76-99`)
|
||||
|
||||
3. **Permission Checking**: Uses custom directives and plugins for fine-grained control
|
||||
|
||||
### State Management (Pinia)
|
||||
|
||||
Located in `src/store/modules/`:
|
||||
|
||||
- **user.ts**: Authentication, user info, logout logic
|
||||
- **permission.ts**: Dynamic route generation and management
|
||||
- **app.ts**: Application settings (sidebar, language, size) - persisted with `@vueuse/core`
|
||||
- **settings.ts**: Theme and UI preferences
|
||||
- **tagsView.ts**: Visited page tabs management
|
||||
- **dict.ts**: Dictionary data caching
|
||||
- **notice.ts**: Notification state
|
||||
|
||||
### API Layer
|
||||
|
||||
- **Base configuration**: `src/utils/request.ts` - Axios instance with interceptors
|
||||
- **Features**:
|
||||
- JWT token management (`Authorization: Bearer <token>`)
|
||||
- Request/response encryption support (RSA + AES)
|
||||
- Duplicate submission prevention (500ms interval)
|
||||
- Internationalized error messages
|
||||
- Download progress loading
|
||||
- **API modules**: Organized by domain in `src/api/` mirroring backend structure
|
||||
|
||||
### Global Plugins
|
||||
|
||||
Available in all components via `this.$pluginName` or composables:
|
||||
|
||||
- **`$tab`**: Tab/page operations (openPage, closePage, refreshPage)
|
||||
- **`$modal`**: Modal/dialog management (msg, alert, confirm, loading)
|
||||
- **`$cache`**: Session/local storage wrapper
|
||||
- **`$auth`**: Permission checking (hasPermi, hasRole, hasPermiOr)
|
||||
|
||||
### Code Style & Configuration
|
||||
|
||||
- **Prettier**: 150 char line width, single quotes, 2 spaces, no trailing commas
|
||||
- **ESLint**: Vue + TypeScript + Prettier integration
|
||||
- **TypeScript**: Path alias `@/*` → `./src/*`, strict mode with some relaxations (`noImplicitAny: false`, `strictNullChecks: false`)
|
||||
- **Import**: Auto-import for Vue APIs via `unplugin-auto-import`
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Defined in `.env.development` and `.env.production`:
|
||||
|
||||
- `VITE_APP_TITLE`: Application title
|
||||
- `VITE_APP_BASE_API`: API base URL (e.g., `/dev-api`)
|
||||
- `VITE_APP_CONTEXT_PATH`: Application context path
|
||||
- `VITE_APP_CLIENT_ID`: OAuth client ID
|
||||
- `VITE_APP_ENCRYPT`: Enable request/response encryption
|
||||
- `VITE_APP_RSA_PUBLIC_KEY`: Request encryption public key
|
||||
- `VITE_APP_RSA_PRIVATE_KEY`: Response decryption private key
|
||||
- `VITE_APP_WEBSOCKET`: WebSocket toggle (defaults to SSE)
|
||||
- `VITE_APP_SSE`: Server-Sent Events toggle
|
||||
|
||||
### Component Patterns
|
||||
|
||||
- **Composition API**: Use `<script setup lang="ts">` syntax
|
||||
- **Props**: Use `vue-types` for runtime type validation
|
||||
- **Auto-import**: Vue APIs (`ref`, `reactive`, `computed`, etc.) are auto-imported
|
||||
- **Component naming**: Use `defineOptions` with `name` property for keep-alive compatibility
|
||||
|
||||
### Key Features
|
||||
|
||||
- **Multi-tenancy**: Full tenant isolation support
|
||||
- **Workflow Engine**: Business process management integration
|
||||
- **Real-time**: WebSocket and SSE support for push notifications
|
||||
- **Code Generation**: Scaffolding tools for CRUD operations
|
||||
- **File Management**: Upload/download with configurable storage
|
||||
- **Monitoring**: Cache, logs, server metrics, online users
|
||||
- **i18n**: Chinese/English with Element Plus locale integration
|
||||
- **Theme**: Light/dark mode with CSS variables
|
||||
|
||||
### Module Organization
|
||||
|
||||
- **system**: Core system management (users, roles, menus, departments, tenants)
|
||||
- **monitor**: System monitoring (logs, cache, online users, server metrics)
|
||||
- **workflow**: Workflow process management
|
||||
- **net**: Networking/communication features
|
||||
- **demo**: Example features and use cases
|
||||
- **tool**: Development tools (code generation, form builder)
|
||||
|
||||
### Backend Integration
|
||||
|
||||
This frontend pairs with:
|
||||
- **RuoYi-Vue-Plus**: Distributed cluster framework
|
||||
- **RuoYi-Cloud-Plus**: Microservices framework
|
||||
|
||||
Both available on Gitee/GitHub under `dromara` organization.
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### Adding a New Feature
|
||||
|
||||
1. Create API module in `src/api/<domain>/`
|
||||
2. Create views in `src/views/<domain>/`
|
||||
3. Add types in `src/types/` if needed
|
||||
4. Routes will be loaded dynamically from backend
|
||||
|
||||
### Permission Checking
|
||||
|
||||
```typescript
|
||||
// In template
|
||||
<v-auth="'system:user:add'">Button</v-auth>
|
||||
|
||||
// In code
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
const { hasPermi } = useAuth();
|
||||
if (hasPermi('system:user:add')) { ... }
|
||||
```
|
||||
|
||||
### API Call Pattern
|
||||
|
||||
```typescript
|
||||
import { getUserList } from '@/api/system/user';
|
||||
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
const loading = ref(true);
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getUserList(queryParams.value);
|
||||
// Handle response
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
"image-conversion": "2.1.1",
|
||||
"js-cookie": "3.0.5",
|
||||
"jsencrypt": "3.5.4",
|
||||
"monaco-editor": "^0.55.1",
|
||||
"nprogress": "0.2.0",
|
||||
"pinia": "3.0.3",
|
||||
"screenfull": "6.0.2",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { IdeaVO, IdeaForm, IdeaQuery } from '@/api/net/idea/types';
|
||||
|
||||
/**
|
||||
* 查询用户反馈列表
|
||||
* @param query
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const listIdea = (query?: IdeaQuery): AxiosPromise<IdeaVO[]> => {
|
||||
return request({
|
||||
url: '/net/idea/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询用户反馈详细
|
||||
* @param id
|
||||
*/
|
||||
export const getIdea = (id: string | number): AxiosPromise<IdeaVO> => {
|
||||
return request({
|
||||
url: '/net/idea/' + id,
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 新增用户反馈
|
||||
* @param data
|
||||
*/
|
||||
export const addIdea = (data: IdeaForm) => {
|
||||
return request({
|
||||
url: '/net/idea',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改用户反馈
|
||||
* @param data
|
||||
*/
|
||||
export const updateIdea = (data: IdeaForm) => {
|
||||
return request({
|
||||
url: '/net/idea',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除用户反馈
|
||||
* @param id
|
||||
*/
|
||||
export const delIdea = (id: string | number | Array<string | number>) => {
|
||||
return request({
|
||||
url: '/net/idea/' + id,
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
export interface IdeaVO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
userId: string | number;
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
score: number;
|
||||
|
||||
/**
|
||||
* 反馈意见
|
||||
*/
|
||||
ideaContent: string;
|
||||
|
||||
}
|
||||
|
||||
export interface IdeaForm extends BaseEntity {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
userId?: string | number;
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
score?: number;
|
||||
|
||||
/**
|
||||
* 反馈意见
|
||||
*/
|
||||
ideaContent?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface IdeaQuery extends PageQuery {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
userId?: string | number;
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
score?: number;
|
||||
|
||||
/**
|
||||
* 反馈意见
|
||||
*/
|
||||
ideaContent?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
|
@ -14,6 +14,16 @@ export interface InvitationVO {
|
|||
*/
|
||||
invitationName: string;
|
||||
|
||||
/**
|
||||
* 短信模板
|
||||
*/
|
||||
smsTemplate?: string;
|
||||
|
||||
/**
|
||||
* 邮件模板
|
||||
*/
|
||||
emailTemplate?: string;
|
||||
|
||||
/**
|
||||
* 加速计划ID
|
||||
*/
|
||||
|
|
@ -77,6 +87,11 @@ export interface InvitationForm extends BaseEntity {
|
|||
*/
|
||||
smsTemplate?: string;
|
||||
|
||||
/**
|
||||
* 邮件模板
|
||||
*/
|
||||
emailTemplate?: string;
|
||||
|
||||
/**
|
||||
* 加速计划ID
|
||||
*/
|
||||
|
|
@ -155,162 +170,4 @@ export interface InvitationQuery extends PageQuery {
|
|||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
export interface InvitationVO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 渠道编号
|
||||
*/
|
||||
invitationCode: string;
|
||||
|
||||
/**
|
||||
* 渠道名称
|
||||
*/
|
||||
invitationName: string;
|
||||
|
||||
/**
|
||||
* 加速计划ID
|
||||
*/
|
||||
planId: string | number;
|
||||
|
||||
/**
|
||||
* 最近多少天
|
||||
*/
|
||||
ipRegisterDay: number;
|
||||
|
||||
/**
|
||||
* 注册多少个
|
||||
*/
|
||||
ipRegisterNum: number;
|
||||
|
||||
/**
|
||||
* 邮箱绑定赠送分钟数
|
||||
*/
|
||||
emailBindGift: number;
|
||||
|
||||
/**
|
||||
* 签到赠送分钟数
|
||||
*/
|
||||
signInGift: number;
|
||||
|
||||
/**
|
||||
* 保护地区
|
||||
*/
|
||||
protectedArea: string;
|
||||
|
||||
/**
|
||||
* 节点选择
|
||||
*/
|
||||
nodeFlag: number;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark: string;
|
||||
|
||||
}
|
||||
|
||||
export interface InvitationForm extends BaseEntity {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 渠道编号
|
||||
*/
|
||||
invitationCode?: string;
|
||||
|
||||
/**
|
||||
* 渠道名称
|
||||
*/
|
||||
invitationName?: string;
|
||||
|
||||
/**
|
||||
* 短信模板
|
||||
*/
|
||||
smsTemplate?: string;
|
||||
|
||||
/**
|
||||
* 加速计划ID
|
||||
*/
|
||||
planId?: string | number;
|
||||
|
||||
/**
|
||||
* 最近多少天
|
||||
*/
|
||||
ipRegisterDay?: number;
|
||||
|
||||
/**
|
||||
* 注册多少个
|
||||
*/
|
||||
ipRegisterNum?: number;
|
||||
|
||||
/**
|
||||
* 注册赠送分钟数
|
||||
*/
|
||||
registerGift?: number;
|
||||
|
||||
/**
|
||||
* 绑定手机号赠送分钟数
|
||||
*/
|
||||
phoneBindGift?: number;
|
||||
|
||||
/**
|
||||
* 邮箱绑定赠送分钟数
|
||||
*/
|
||||
emailBindGift?: number;
|
||||
|
||||
/**
|
||||
* 签到赠送分钟数
|
||||
*/
|
||||
signInGift?: number;
|
||||
|
||||
/**
|
||||
* 保护地区
|
||||
*/
|
||||
protectedArea?: string;
|
||||
|
||||
/**
|
||||
* 节点选择
|
||||
*/
|
||||
nodeFlag?: number;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface InvitationQuery extends PageQuery {
|
||||
|
||||
/**
|
||||
* 渠道编号
|
||||
*/
|
||||
invitationCode?: string;
|
||||
|
||||
/**
|
||||
* 渠道名称
|
||||
*/
|
||||
invitationName?: string;
|
||||
|
||||
/**
|
||||
* 加速计划ID
|
||||
*/
|
||||
planId?: string | number;
|
||||
|
||||
/**
|
||||
* 保护地区
|
||||
*/
|
||||
protectedArea?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
}
|
||||
|
|
@ -129,6 +129,51 @@ export interface NodeVO {
|
|||
*/
|
||||
serviceName: string;
|
||||
|
||||
/**
|
||||
* cpu使用率
|
||||
*/
|
||||
cpuUsageRate: number;
|
||||
|
||||
/**
|
||||
* 内存总量
|
||||
*/
|
||||
memTotal: number;
|
||||
|
||||
/**
|
||||
* 内存使用量
|
||||
*/
|
||||
memUsed: number;
|
||||
|
||||
/**
|
||||
* 交换区总量
|
||||
*/
|
||||
swapTotal: number;
|
||||
|
||||
/**
|
||||
* 交换区使用量
|
||||
*/
|
||||
swapUsed: number;
|
||||
|
||||
/**
|
||||
* 硬盘总量
|
||||
*/
|
||||
diskTotal: number;
|
||||
|
||||
/**
|
||||
* 硬盘使用量
|
||||
*/
|
||||
diskUsed: number;
|
||||
|
||||
/**
|
||||
* 本次运行时间(秒)
|
||||
*/
|
||||
uptime: number;
|
||||
|
||||
/**
|
||||
* 当前使用人数
|
||||
*/
|
||||
userUsed: number;
|
||||
|
||||
}
|
||||
|
||||
export interface NodeForm extends BaseEntity {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,18 @@ export const updatePlan = (data: PlanForm) => {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改加速计划
|
||||
* @param data
|
||||
*/
|
||||
export const configVm = (data: PlanForm) => {
|
||||
return request({
|
||||
url: '/net/plan/configVm',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除加速计划
|
||||
* @param id
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ export interface PlanVO {
|
|||
*/
|
||||
groupIds?: string | number;
|
||||
|
||||
/**
|
||||
* 配置模板
|
||||
*/
|
||||
configVm?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface PlanForm extends BaseEntity {
|
||||
|
|
@ -77,6 +82,11 @@ export interface PlanForm extends BaseEntity {
|
|||
*/
|
||||
groupIds?: string | number;
|
||||
|
||||
/**
|
||||
* 配置模板
|
||||
*/
|
||||
configVm?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface PlanQuery extends PageQuery {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,226 @@
|
|||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="用户ID" prop="userId">
|
||||
<el-input v-model="queryParams.userId" placeholder="请输入用户ID" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分数" prop="score">
|
||||
<el-input v-model="queryParams.score" placeholder="请输入分数" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['net:idea:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['net:idea:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['net:idea:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['net:idea:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="ideaList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="ID" align="center" prop="id" v-if="true" />
|
||||
<el-table-column label="用户ID" align="center" prop="userId" />
|
||||
<el-table-column label="分数" align="center" prop="score" />
|
||||
<el-table-column label="反馈意见" align="center" prop="ideaContent" />
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['net:idea:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['net:idea:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改用户反馈对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="ideaFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="用户ID" prop="userId">
|
||||
<el-input v-model="form.userId" placeholder="请输入用户ID" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分数" prop="score">
|
||||
<el-input v-model="form.score" placeholder="请输入分数" />
|
||||
</el-form-item>
|
||||
<el-form-item label="反馈意见">
|
||||
<editor v-model="form.ideaContent" :min-height="192"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Idea" lang="ts">
|
||||
import { listIdea, getIdea, delIdea, addIdea, updateIdea } from '@/api/net/idea';
|
||||
import { IdeaVO, IdeaQuery, IdeaForm } from '@/api/net/idea/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const ideaList = ref<IdeaVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const ideaFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: IdeaForm = {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
score: undefined,
|
||||
ideaContent: undefined,
|
||||
}
|
||||
const data = reactive<PageData<IdeaForm, IdeaQuery>>({
|
||||
form: {...initFormData},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userId: undefined,
|
||||
score: undefined,
|
||||
ideaContent: undefined,
|
||||
params: {
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
id: [
|
||||
{ required: true, message: "不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询用户反馈列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listIdea(queryParams.value);
|
||||
ideaList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = {...initFormData};
|
||||
ideaFormRef.value?.resetFields();
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: IdeaVO[]) => {
|
||||
ids.value = selection.map(item => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = "添加用户反馈";
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: IdeaVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0]
|
||||
const res = await getIdea(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改用户反馈";
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
ideaFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateIdea(form.value).finally(() => buttonLoading.value = false);
|
||||
} else {
|
||||
await addIdea(form.value).finally(() => buttonLoading.value = false);
|
||||
}
|
||||
proxy?.$modal.msgSuccess("操作成功");
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: IdeaVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除用户反馈编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
|
||||
await delIdea(_ids);
|
||||
proxy?.$modal.msgSuccess("删除成功");
|
||||
await getList();
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download('net/idea/export', {
|
||||
...queryParams.value
|
||||
}, `idea_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
|
@ -92,6 +92,9 @@
|
|||
<el-form-item label="短信模板" prop="smsTemplate">
|
||||
<el-input v-model="form.smsTemplate" placeholder="请输入短信模板" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮件模板" prop="emailTemplate">
|
||||
<el-input v-model="form.emailTemplate" placeholder="请输入邮件模板" />
|
||||
</el-form-item>
|
||||
<el-form-item label="加速计划" prop="planId">
|
||||
<el-select v-model="form.planId" placeholder="加速计划" clearable>
|
||||
<el-option v-for="plan in planList" :key="plan.id" :label="plan.planName" :value="plan.id" />
|
||||
|
|
|
|||
|
|
@ -131,6 +131,77 @@
|
|||
<el-table-column v-if="columns[21].visible" label="SNI伪装域名" align="center" prop="sni" />
|
||||
<el-table-column v-if="columns[22].visible" label="ws路径" align="center" prop="path" />
|
||||
<el-table-column v-if="columns[23].visible" label="grpc名称" align="center" prop="serviceName" />
|
||||
<el-table-column v-if="columns[24].visible" label="CPU" align="center" min-width="120">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.cpuUsageRate != null">
|
||||
<el-progress
|
||||
:percentage="scope.row.cpuUsageRate"
|
||||
:color="getProgressColor(scope.row.cpuUsageRate)"
|
||||
:stroke-width="18"
|
||||
:text-inside="true"
|
||||
/>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[25].visible" label="内存" align="center" min-width="150">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.memTotal != null && scope.row.memUsed != null">
|
||||
<el-progress
|
||||
:percentage="calcUsagePercent(scope.row.memUsed, scope.row.memTotal)"
|
||||
:color="getProgressColor(calcUsagePercent(scope.row.memUsed, scope.row.memTotal))"
|
||||
:stroke-width="18"
|
||||
:text-inside="true"
|
||||
/>
|
||||
<div class="text-xs text-gray-500 mt-1">
|
||||
{{ formatSize(scope.row.memUsed) }} / {{ formatSize(scope.row.memTotal) }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[26].visible" label="交换区" align="center" min-width="150">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.swapTotal != null && scope.row.swapUsed != null">
|
||||
<el-progress
|
||||
:percentage="calcUsagePercent(scope.row.swapUsed, scope.row.swapTotal)"
|
||||
:color="getProgressColor(calcUsagePercent(scope.row.swapUsed, scope.row.swapTotal))"
|
||||
:stroke-width="18"
|
||||
:text-inside="true"
|
||||
/>
|
||||
<div class="text-xs text-gray-500 mt-1">
|
||||
{{ formatSize(scope.row.swapUsed) }} / {{ formatSize(scope.row.swapTotal) }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[27].visible" label="硬盘" align="center" min-width="150">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.diskTotal != null && scope.row.diskUsed != null">
|
||||
<el-progress
|
||||
:percentage="calcUsagePercent(scope.row.diskUsed, scope.row.diskTotal)"
|
||||
:color="getProgressColor(calcUsagePercent(scope.row.diskUsed, scope.row.diskTotal))"
|
||||
:stroke-width="18"
|
||||
:text-inside="true"
|
||||
/>
|
||||
<div class="text-xs text-gray-500 mt-1">
|
||||
{{ formatSize(scope.row.diskUsed) }} / {{ formatSize(scope.row.diskTotal) }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[28].visible" label="运行时间" align="center" min-width="140">
|
||||
<template #default="scope">
|
||||
{{ formatUptime(scope.row.uptime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[29].visible" label="在线人数" align="center" prop="userUsed" min-width="90">
|
||||
<template #default="scope">
|
||||
{{ scope.row.userUsed ?? '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
|
|
@ -181,16 +252,6 @@
|
|||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="UDP支持" prop="udpFlag">
|
||||
<el-select v-model="form.udpFlag" placeholder="请选择UDP支持">
|
||||
<el-option
|
||||
v-for="dict in net_true_false"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="开启状态" prop="enableFlag">
|
||||
<el-radio-group v-model="form.enableFlag">
|
||||
<el-radio
|
||||
|
|
@ -213,7 +274,27 @@
|
|||
<el-form-item label="带宽(Mb)" prop="bandWidth">
|
||||
<el-input v-model="form.bandWidth" placeholder="请输入带宽(Mb)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="网络协议" prop="streamType">
|
||||
<el-form-item label="加密算法" prop="encAlg" v-if="form.protocolType=='shadowsocks'">
|
||||
<el-select v-model="form.encAlg" placeholder="请选择加密算法">
|
||||
<el-option
|
||||
v-for="dict in net_enc_alg"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="UDP支持" prop="udpFlag" v-if="form.protocolType=='vless'">
|
||||
<el-select v-model="form.udpFlag" placeholder="请选择UDP支持">
|
||||
<el-option
|
||||
v-for="dict in net_true_false"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="网络协议" prop="streamType" v-if="form.protocolType=='vless'">
|
||||
<el-select v-model="form.streamType" placeholder="请选择网络协议">
|
||||
<el-option
|
||||
v-for="dict in net_stream_type"
|
||||
|
|
@ -223,7 +304,7 @@
|
|||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="加密方式" prop="tlsType">
|
||||
<el-form-item label="加密方式" prop="tlsType" v-if="form.protocolType=='vless'">
|
||||
<el-select v-model="form.tlsType" placeholder="请选择加密方式">
|
||||
<el-option
|
||||
v-for="dict in net_tls_type"
|
||||
|
|
@ -270,9 +351,6 @@
|
|||
<el-form-item label="grpc名称" prop="serviceName" v-if="form.streamType=='grpc'">
|
||||
<el-input v-model="form.serviceName" placeholder="请输入grpc服务名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="加密算法" prop="encAlg" v-if="false">
|
||||
<el-input v-model="form.encAlg" placeholder="请输入加密算法" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
|
|
@ -291,7 +369,7 @@ import { listAll } from '@/api/net/serverRoute';
|
|||
import { ServerRouteVO } from '@/api/net/serverRoute/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { net_tls_type, net_stream_type, net_enable_flag, net_true_false, net_flow, net_protocol_type, net_flow_type } = toRefs<any>(proxy?.useDict('net_tls_type', 'net_stream_type', 'net_enable_flag', 'net_true_false', 'net_flow', 'net_protocol_type', 'net_flow_type'));
|
||||
const { net_tls_type, net_stream_type, net_enable_flag, net_true_false, net_flow, net_protocol_type, net_flow_type, net_enc_alg } = toRefs<any>(proxy?.useDict('net_tls_type', 'net_stream_type', 'net_enable_flag', 'net_true_false', 'net_flow', 'net_protocol_type', 'net_flow_type', 'net_enc_alg'));
|
||||
|
||||
const nodeList = ref<NodeVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
|
|
@ -332,8 +410,58 @@ const columns = ref<FieldOption[]>([
|
|||
{ key: 21, label: `加密标识`, visible: false, children: [] },
|
||||
{ key: 22, label: `ws路径`, visible: false, children: [] },
|
||||
{ key: 23, label: `grpc名称`, visible: false, children: [] },
|
||||
{ key: 24, label: `CPU`, visible: true, children: [] },
|
||||
{ key: 25, label: `内存`, visible: true, children: [] },
|
||||
{ key: 26, label: `交换区`, visible: false, children: [] },
|
||||
{ key: 27, label: `硬盘`, visible: false, children: [] },
|
||||
{ key: 28, label: `运行时间`, visible: true, children: [] },
|
||||
{ key: 29, label: `在线人数`, visible: true, children: [] },
|
||||
]);
|
||||
|
||||
/** 格式化运行时间(秒转换为x天x时x分x秒) */
|
||||
const formatUptime = (seconds: number | null | undefined): string => {
|
||||
if (seconds == null) return '-';
|
||||
|
||||
const units = [
|
||||
{ label: '天', value: 24 * 60 * 60 },
|
||||
{ label: '时', value: 60 * 60 },
|
||||
{ label: '分', value: 60 },
|
||||
{ label: '秒', value: 1 },
|
||||
];
|
||||
|
||||
let remaining = seconds;
|
||||
const parts: string[] = [];
|
||||
|
||||
for (const unit of units) {
|
||||
if (remaining >= unit.value) {
|
||||
const count = Math.floor(remaining / unit.value);
|
||||
parts.push(`${count}${unit.label}`);
|
||||
remaining %= unit.value;
|
||||
}
|
||||
}
|
||||
|
||||
return parts.length > 0 ? parts.join('') : '0秒';
|
||||
};
|
||||
|
||||
/** 计算使用率百分比 */
|
||||
const calcUsagePercent = (used: number | null | undefined, total: number | null | undefined): number => {
|
||||
if (used == null || total == null || total === 0) return 0;
|
||||
return Math.round((used / total) * 100);
|
||||
};
|
||||
|
||||
/** 格式化容量(字节转换为GB) */
|
||||
const formatSize = (bytes: number | null | undefined): string => {
|
||||
if (bytes == null) return '-';
|
||||
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
|
||||
};
|
||||
|
||||
/** 获取进度条颜色 */
|
||||
const getProgressColor = (percent: number): string => {
|
||||
if (percent >= 80) return '#F56C6C';
|
||||
if (percent >= 60) return '#E6A23C';
|
||||
return '#67C23A';
|
||||
};
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
|
|
@ -403,9 +531,6 @@ const data = reactive<PageData<NodeForm, NodeQuery>>({
|
|||
protocolType: [
|
||||
{ required: true, message: "加速协议不能为空", trigger: "change" }
|
||||
],
|
||||
udpFlag: [
|
||||
{ required: true, message: "UDP支持不能为空", trigger: "change" }
|
||||
],
|
||||
enableFlag: [
|
||||
{ required: true, message: "开启状态不能为空", trigger: "change" }
|
||||
],
|
||||
|
|
|
|||
|
|
@ -18,31 +18,86 @@
|
|||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="panel" style="margin-top: 20px;">
|
||||
<h4 class="panel-title">clash配置模板(https://clash.wiki/configuration/introduction.html)</h4>
|
||||
<el-form :model="planInfo">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="24">
|
||||
<div ref="editorContainer" style="height: 600px; border: 1px solid #ddd;"></div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PlanRule" lang="ts">
|
||||
import { getPlan } from '@/api/net/plan';
|
||||
import { PlanVO, PlanQuery, PlanForm } from '@/api/net/plan/types';
|
||||
import { getPlan, configVm } from '@/api/net/plan';
|
||||
import { PlanVO } from '@/api/net/plan/types';
|
||||
import * as monaco from 'monaco-editor';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const route = useRoute();
|
||||
|
||||
let planIdParam = "";
|
||||
let editor: monaco.editor.IStandaloneCodeEditor | null = null;
|
||||
const editorContainer = ref<HTMLElement>();
|
||||
|
||||
const planInfo = ref<PlanVO>({
|
||||
id: ''
|
||||
});
|
||||
|
||||
const initEditor = () => {
|
||||
if (editorContainer.value && !editor) {
|
||||
editor = monaco.editor.create(editorContainer.value, {
|
||||
value: planInfo.value.configVm || '',
|
||||
language: 'yaml',
|
||||
theme: 'vs-light',
|
||||
automaticLayout: true,
|
||||
minimap: { enabled: false },
|
||||
scrollBeyondLastLine: false,
|
||||
});
|
||||
|
||||
editor.onDidChangeModelContent(() => {
|
||||
planInfo.value.configVm = editor?.getValue() || '';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const getPlanInfo = async () => {
|
||||
const planId = route.params && route.params.planId;
|
||||
if (planId) {
|
||||
const res = await getPlan(planId as string);
|
||||
planInfo.value = res.data;
|
||||
|
||||
nextTick(() => {
|
||||
initEditor();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const saveClick = async () => {
|
||||
if (!planInfo.value.id) {
|
||||
proxy?.$modal.msgError('计划ID不能为空');
|
||||
return;
|
||||
}
|
||||
|
||||
await configVm({
|
||||
id: planInfo.value.id,
|
||||
configVm: planInfo.value.configVm
|
||||
});
|
||||
proxy?.$modal.msgSuccess('保存成功');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getPlanInfo();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (editor) {
|
||||
editor.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue