mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-02 15:30:25 +08:00
refactor: 代码小优化
This commit is contained in:
@@ -74,8 +74,8 @@ function build() {
|
||||
# fi
|
||||
|
||||
if [ "${copyDocScript}" == "1" ] ; then
|
||||
echo_green "拷贝脚本等资源文件[config.yml、mayfly-go.sql、readme.txt、startup.sh、shutdown.sh]"
|
||||
cp ${server_folder}/config.yml ${toFolder}
|
||||
echo_green "拷贝脚本等资源文件[config.yml.example、mayfly-go.sql、readme.txt、startup.sh、shutdown.sh]"
|
||||
cp ${server_folder}/config.yml.example ${toFolder}
|
||||
cp ${server_folder}/mayfly-go.sql ${toFolder}
|
||||
cp ${server_folder}/readme.txt ${toFolder}
|
||||
cp ${server_folder}/startup.sh ${toFolder}
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
"@element-plus/icons-vue": "^2.1.0",
|
||||
"asciinema-player": "^3.5.0",
|
||||
"axios": "^1.4.0",
|
||||
"countup.js": "^2.0.7",
|
||||
"countup.js": "^2.7.0",
|
||||
"cropperjs": "^1.5.11",
|
||||
"echarts": "^5.4.0",
|
||||
"element-plus": "^2.3.8",
|
||||
"jsencrypt": "^3.3.1",
|
||||
"lodash": "^4.17.21",
|
||||
"mitt": "^3.0.1",
|
||||
"monaco-editor": "^0.40.0",
|
||||
"monaco-editor": "^0.41.0",
|
||||
"monaco-sql-languages": "^0.11.0",
|
||||
"monaco-themes": "^0.4.4",
|
||||
"nprogress": "^0.2.0",
|
||||
@@ -50,7 +50,7 @@
|
||||
"sass": "^1.62.0",
|
||||
"sass-loader": "^13.2.0",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.4.7",
|
||||
"vite": "^4.4.9",
|
||||
"vue-eslint-parser": "^9.1.1"
|
||||
},
|
||||
"browserslist": [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import router from '../router';
|
||||
import Axios from 'axios';
|
||||
import { ResultEnum } from './enums';
|
||||
import config from './config';
|
||||
import { getSession } from './utils/storage';
|
||||
import { templateResolve } from './utils/string';
|
||||
@@ -21,6 +20,14 @@ export interface Result {
|
||||
data?: any;
|
||||
}
|
||||
|
||||
enum ResultEnum {
|
||||
SUCCESS = 200,
|
||||
ERROR = 400,
|
||||
PARAM_ERROR = 405,
|
||||
SERVER_ERROR = 500,
|
||||
NO_PERMISSION = 501,
|
||||
}
|
||||
|
||||
const baseUrl: string = config.baseApiUrl;
|
||||
const baseWsUrl: string = config.baseWsUrl;
|
||||
|
||||
@@ -60,34 +67,46 @@ service.interceptors.response.use(
|
||||
(response) => {
|
||||
// 获取请求返回结果
|
||||
const data: Result = response.data;
|
||||
if (data.code === ResultEnum.SUCCESS) {
|
||||
return data.data;
|
||||
}
|
||||
// 如果提示没有权限,则移除token,使其重新登录
|
||||
if (data.code === ResultEnum.NO_PERMISSION) {
|
||||
router.push({
|
||||
path: '/401',
|
||||
});
|
||||
}
|
||||
if (data.code === ResultEnum.SUCCESS) {
|
||||
return data.data;
|
||||
} else {
|
||||
return Promise.reject(data);
|
||||
}
|
||||
return Promise.reject(data);
|
||||
},
|
||||
(e: any) => {
|
||||
const rejectPromise = Promise.reject(e);
|
||||
|
||||
const statusCode = e.response?.status;
|
||||
if (statusCode == 500) {
|
||||
notifyErrorMsg('服务器未知异常');
|
||||
return rejectPromise;
|
||||
}
|
||||
|
||||
if (statusCode == 404) {
|
||||
notifyErrorMsg('请求接口未找到');
|
||||
return rejectPromise;
|
||||
}
|
||||
|
||||
if (e.message) {
|
||||
// 对响应错误做点什么
|
||||
if (e.message.indexOf('timeout') != -1) {
|
||||
notifyErrorMsg('网络超时');
|
||||
} else if (e.message == 'Network Error') {
|
||||
notifyErrorMsg('网络请求超时');
|
||||
return rejectPromise;
|
||||
}
|
||||
|
||||
if (e.message == 'Network Error') {
|
||||
notifyErrorMsg('网络连接错误');
|
||||
} else if (e.message.indexOf('404')) {
|
||||
notifyErrorMsg('请求接口找不到');
|
||||
} else {
|
||||
if (e.response.data) ElMessage.error(e.response.statusText);
|
||||
else notifyErrorMsg('接口路径找不到');
|
||||
return rejectPromise;
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(e);
|
||||
notifyErrorMsg('网络请求错误');
|
||||
return rejectPromise;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -12,13 +12,15 @@ const props = defineProps({
|
||||
required: true,
|
||||
},
|
||||
value: {
|
||||
type: Object,
|
||||
type: [Object, String, Number],
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const defaultType = 'primary';
|
||||
|
||||
const state = reactive({
|
||||
type: 'primary',
|
||||
type: defaultType,
|
||||
color: '',
|
||||
enumLabel: '',
|
||||
});
|
||||
@@ -50,6 +52,8 @@ const convert = (value: any) => {
|
||||
if (enumValue.tag) {
|
||||
state.color = enumValue.tag.color;
|
||||
state.type = enumValue.tag.type;
|
||||
} else {
|
||||
state.type = defaultType;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -314,8 +314,16 @@ onMounted(() => {
|
||||
} else {
|
||||
state.inputWidth = props.inputWidth;
|
||||
}
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
calcuTableHeight();
|
||||
});
|
||||
})
|
||||
|
||||
const calcuTableHeight = () => {
|
||||
state.tableMaxHeight = window.innerHeight - 240 + 'px';
|
||||
}
|
||||
|
||||
const formatText = (data: any)=> {
|
||||
state.formatVal = '';
|
||||
try {
|
||||
@@ -362,7 +370,7 @@ const reset = () => {
|
||||
for (let qi of props.query) {
|
||||
state.queryForm[qi.prop] = null;
|
||||
}
|
||||
console.log(state.queryForm);
|
||||
|
||||
changePageNum(1);
|
||||
emit('update:queryForm', state.queryForm);
|
||||
execQuery();
|
||||
|
||||
@@ -18,7 +18,7 @@ import { useKeepALiveNames } from '@/store/keepAliveNames';
|
||||
* @method import.meta.glob
|
||||
* @link 参考:https://cn.vitejs.dev/guide/features.html#json
|
||||
*/
|
||||
const viewsModules: any = import.meta.glob('../views/**/*.{vue,tsx}');
|
||||
const viewsModules: any = import.meta.glob(['../views/**/*.{vue,tsx}', '!../views/layout/**/*.{vue,tsx}']);
|
||||
const dynamicViewsModules: Record<string, Function> = Object.assign({}, { ...viewsModules });
|
||||
|
||||
// 添加静态路由
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="cron" label="cron表达式">
|
||||
<el-input v-model="form.cron" placeholder="请输入cron表达式"></el-input>
|
||||
<el-input v-model="form.cron" placeholder="只支持5位表达式,不支持秒级.如 0/2 * * * * 表示每两分钟执行"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="status" label="状态">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch, toRefs, onMounted } from 'vue';
|
||||
import { ref, reactive, toRefs, onMounted } from 'vue';
|
||||
import { redisApi } from './api';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { notEmpty } from '@/common/assert';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div>
|
||||
<span style="font-size: 14px"> <SvgIcon name="info-filled" />红色、橙色字体表示禁用状态 </span>
|
||||
</div>
|
||||
<el-button v-auth="'resource:add'" type="primary" icon="plus" @click="addResource(false)">添加</el-button>
|
||||
<el-button v-auth="perms.addResource" type="primary" icon="plus" @click="addResource(false)">添加</el-button>
|
||||
</div>
|
||||
<el-tree
|
||||
class="none-select"
|
||||
@@ -37,10 +37,10 @@
|
||||
|
||||
<el-link @click.prevent="info(data)" style="margin-left: 25px" icon="view" type="info" :underline="false" />
|
||||
|
||||
<el-link v-auth="'resource:update'" @click.prevent="editResource(data)" class="ml5" type="primary" icon="edit" :underline="false" />
|
||||
<el-link v-auth="perms.updateResource" @click.prevent="editResource(data)" class="ml5" type="primary" icon="edit" :underline="false" />
|
||||
|
||||
<el-link
|
||||
v-auth="'resource:add'"
|
||||
v-auth="perms.addResource"
|
||||
@click.prevent="addResource(data)"
|
||||
v-if="data.type === menuTypeValue"
|
||||
icon="circle-plus"
|
||||
@@ -50,7 +50,7 @@
|
||||
/>
|
||||
|
||||
<el-link
|
||||
v-auth="'resource:changeStatus'"
|
||||
v-auth="perms.changeStatus"
|
||||
@click.prevent="changeStatus(data, -1)"
|
||||
v-if="data.status === 1"
|
||||
icon="circle-close"
|
||||
@@ -60,7 +60,7 @@
|
||||
/>
|
||||
|
||||
<el-link
|
||||
v-auth="'resource:changeStatus'"
|
||||
v-auth="perms.changeStatus"
|
||||
@click.prevent="changeStatus(data, 1)"
|
||||
v-if="data.status === -1"
|
||||
type="success"
|
||||
@@ -70,7 +70,7 @@
|
||||
class="ml5"
|
||||
/>
|
||||
|
||||
<el-link v-auth="'resource:delete'" @click.prevent="deleteMenu(data)" type="danger" icon="delete" :underline="false" plain class="ml5" />
|
||||
<el-link v-auth="perms.delResource" @click.prevent="deleteMenu(data)" type="danger" icon="delete" :underline="false" plain class="ml5" />
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
@@ -138,6 +138,13 @@ import EnumValue from '@/common/Enum';
|
||||
const menuTypeValue = ResourceTypeEnum.Menu.value;
|
||||
const permissionTypeValue = ResourceTypeEnum.Permission.value;
|
||||
|
||||
const perms = {
|
||||
addResource: 'resource:add',
|
||||
delResource: 'resource:delete',
|
||||
updateResource: 'resource:update',
|
||||
changeStatus: 'resource:changeStatus',
|
||||
};
|
||||
|
||||
const props = {
|
||||
label: 'name',
|
||||
children: 'children',
|
||||
|
||||
Reference in New Issue
Block a user