Skip to content

Commit

Permalink
Merge pull request #5 from matevip/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
matevip authored Sep 27, 2021
2 parents 66b3bdb + fcccd98 commit 896a2c8
Show file tree
Hide file tree
Showing 21 changed files with 383 additions and 57 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ admin | matecloud123 | 不能执行增删改请求,如需全部权限加微信
- 获取项目代码

```bash
git clone https://github.com/anncwb/vue-vben-admin.git
git clone https://gitee.com/matevip/artemis.git
```

- 安装依赖

```bash
cd vue-vben-admin
cd artemis

yarn install

Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "artemis-admin",
"version": "4.0.8-M3",
"version": "4.0.8-M4",
"author": {
"name": "matevip",
"email": "7333791@qq.com",
Expand Down Expand Up @@ -37,9 +37,9 @@
"@iconify/iconify": "^2.0.4",
"@logicflow/core": "^0.6.15",
"@logicflow/extension": "^0.6.15",
"@vueuse/core": "^6.0.0",
"@vueuse/core": "^6.4.1",
"@zxcvbn-ts/core": "^1.0.0-beta.0",
"ant-design-vue": "2.2.6",
"ant-design-vue": "2.2.8",
"axios": "^0.21.3",
"codemirror": "^5.62.3",
"cropperjs": "^1.5.12",
Expand All @@ -59,17 +59,17 @@
"sortablejs": "^1.14.0",
"tinymce": "^5.9.1",
"vditor": "^3.8.6",
"vue": "3.2.9",
"vue-i18n": "9.1.7",
"vue": "^3.2.12",
"vue-i18n": "^9.1.7",
"vue-json-pretty": "^2.0.4",
"vue-router": "^4.0.11",
"vue-types": "^4.0.3",
"xlsx": "^0.17.1"
"xlsx": "^0.17.2"
},
"devDependencies": {
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@iconify/json": "^1.1.397",
"@iconify/json": "^1.1.403",
"@purge-icons/generated": "^0.7.0",
"@types/codemirror": "^5.60.2",
"@types/crypto-js": "^4.0.2",
Expand All @@ -80,16 +80,16 @@
"@types/js-md5": "^0.4.3",
"@types/lodash-es": "^4.17.4",
"@types/mockjs": "^1.0.4",
"@types/node": "^16.7.10",
"@types/node": "^16.9.2",
"@types/nprogress": "^0.2.0",
"@types/qrcode": "^1.4.1",
"@types/qs": "^6.9.7",
"@types/sortablejs": "^1.10.7",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"@vitejs/plugin-legacy": "^1.5.2",
"@vitejs/plugin-vue": "^1.6.0",
"@vitejs/plugin-vue-jsx": "^1.1.7",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@vitejs/plugin-legacy": "^1.5.3",
"@vitejs/plugin-vue": "^1.6.2",
"@vitejs/plugin-vue-jsx": "^1.1.8",
"@vue/compiler-sfc": "3.2.9",
"@vue/test-utils": "^2.0.0-rc.13",
"autoprefixer": "^10.3.4",
Expand Down Expand Up @@ -125,18 +125,18 @@
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "4.4.2",
"vite": "2.5.3",
"vite": "^2.5.8",
"vite-plugin-compression": "^0.3.5",
"vite-plugin-html": "^2.1.0",
"vite-plugin-imagemin": "^0.4.5",
"vite-plugin-mock": "^2.9.6",
"vite-plugin-purge-icons": "^0.7.0",
"vite-plugin-pwa": "^0.11.0",
"vite-plugin-pwa": "^0.11.2",
"vite-plugin-style-import": "^1.2.1",
"vite-plugin-svg-icons": "^1.0.4",
"vite-plugin-theme": "^0.8.1",
"vite-plugin-vue-setup-extend": "^0.1.0",
"vite-plugin-windicss": "^1.3.0",
"vite-plugin-windicss": "^1.4.3",
"vue-eslint-parser": "^7.11.0",
"vue-tsc": "^0.3.0"
},
Expand Down
18 changes: 18 additions & 0 deletions src/api/content/attachment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AttachmentVO, AttachmentDTO, Attachment } from './model/attachmentModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
Page = '/mate-component/attachment/page',
Set = '/mate-component/attachment/set',
Del = '/mate-component/attachment/del',
}

// 分页查询
export const page = (params: AttachmentVO) => defHttp.get<AttachmentDTO>({ url: Api.Page, params });

// 保存
export const set = (params: Attachment) => defHttp.post<Attachment>({ url: Api.Set, params });

// 删除
export const del = (params: { ids: String }) =>
defHttp.post<boolean>({ url: Api.Del + `?ids=${params.ids}` });
26 changes: 26 additions & 0 deletions src/api/content/model/attachmentModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 引入基础包
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';

// 定义查询参数
export type AttachmentVO = BasicPageParams & {
keyword?: string;
startDate?: string;
endDate?: string;
};

// 定义路由对象
export interface Attachment {
id: string;
storageId: string;
attachmentGroupId: string;
name: string;
size: string;
url: string;
fileName: string;
thumbUrl: string;
type: number;
createTime: string;
}

// 根据字典对象生成响应模型
export type AttachmentDTO = BasicFetchResult<AttachmentVO>;
7 changes: 1 addition & 6 deletions src/components/Form/src/components/ApiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@
},
inheritAttrs: false,
props: {
value: propTypes.oneOfType([
propTypes.object,
propTypes.number,
propTypes.string,
propTypes.array,
]),
value: [Array, Object, String, Number],
numberToString: propTypes.bool,
api: {
type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>,
Expand Down
1 change: 1 addition & 0 deletions src/components/Modal/src/hooks/useModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function useModal(): UseModalReturnType {
if (unref(loaded) && isProdMode() && modalMethod === unref(modal)) return;

modal.value = modalMethod;
loaded.value = true;
modalMethod.emitVisible = (visible: boolean, uid: number) => {
visibleData[uid] = visible;
};
Expand Down
12 changes: 6 additions & 6 deletions src/components/Table/src/BasicTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,6 @@
}
}
&--inset {
.ant-table-wrapper {
padding: 0;
}
}
.ant-tag {
margin-right: 0;
}
Expand Down Expand Up @@ -415,6 +409,12 @@
td {
padding: 12px 8px;
}
&--inset {
.ant-table-wrapper {
padding: 0;
}
}
}
}
</style>
6 changes: 1 addition & 5 deletions src/components/Table/src/components/TableAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
<Divider
type="vertical"
class="action-divider"
v-if="
divider &&
index < getActions.length - (dropDownActions ? 0 : 1) &&
getDropdownList.length > 0
"
v-if="divider && index < getActions.length - 1"
/>
</template>
<Dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
if (!record) return false;
const { key, dataIndex } = column;
const value = unref(currentValueRef);
if (!key || !dataIndex) return;
if (!key && !dataIndex) return;
const dataKey = (dataIndex || key) as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<ScrollContainer>
<CheckboxGroup v-model:value="checkedList" @change="onChange" ref="columnListRef">
<template v-for="item in plainOptions" :key="item.value">
<div :class="`${prefixCls}__check-item`">
<div :class="`${prefixCls}__check-item`" v-if="!('ifShow' in item && !item.ifShow)">
<DragOutlined class="table-coulmn-drag-icon" />
<Checkbox :value="item.value">
{{ item.label }}
Expand Down
8 changes: 8 additions & 0 deletions src/components/Table/src/hooks/useCustomRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export function useCustomRow(

const isCheckbox = rowSelection.type === 'checkbox';
if (isCheckbox) {
// 找到tr
const tr: HTMLElement = (e as MouseEvent)
.composedPath?.()
.find((dom: HTMLElement) => dom.tagName === 'TR') as HTMLElement;
if (!tr) return;
// 找到Checkbox,检查是否为disabled
const checkBox = tr.querySelector('input[type=checkbox]');
if (!checkBox || checkBox.hasAttribute('disabled')) return;
if (!keys.includes(key)) {
setSelectedRowKeys([...keys, key]);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/settings/siteSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const GITHUB_URL = 'https://github.com/matevip/artemis';
export const DOC_URL = 'http://doc.mate.vip/';

// site url
export const SITE_URL = 'http://www.mate.vip/';
export const SITE_URL = 'https://cloud.mate.vip/';
30 changes: 30 additions & 0 deletions src/utils/file/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,33 @@ export function downloadByUrl({
openWindow(url, { target });
return true;
}

/**
* 计算附件大小
*
*/
export function getFileSize(limit) {
// 传参limit为初始值
let size = '';
if (limit < 0.1 * 1024) {
//如果小于0.1KB转化成B
size = limit.toFixed(2) + 'B';
} else if (limit < 0.1 * 1024 * 1024) {
//如果小于0.1MB转化成KB
size = (limit / 1024).toFixed(2) + 'KB';
} else if (limit < 0.1 * 1024 * 1024 * 1024) {
//如果小于0.1GB转化成MB
size = (limit / (1024 * 1024)).toFixed(2) + 'MB';
} else {
//其他转化成GB
size = (limit / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
}
const sizestr = size + '';
const len = sizestr.indexOf('.');
const dec = sizestr.substr(len + 1, 2);
if (dec == '00') {
//当小数点后为00时 去掉小数部分
return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
}
return sizestr;
}
13 changes: 8 additions & 5 deletions src/utils/http/axios/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ const transform: AxiosTransform = {
errorLogStore.addAjaxErrorInfo(error);
const { response, code, message, config } = error || {};
const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none';
const msg: string = response?.data?.error?.message ?? '';
const err: string = error?.toString?.() ?? '';
let errMessage = '';
const msg: string = response?.data?.error?.data.msg ?? '';
const err: string = response.data.msg?.toString?.() ?? '';
let errMessage = err;

try {
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
Expand All @@ -175,19 +175,22 @@ const transform: AxiosTransform = {
if (err?.includes('Network Error')) {
errMessage = t('sys.api.networkExceptionMsg');
}
if (response.data.code === 401) {
checkStatus(error?.response?.status, msg, errorMessageMode);
return Promise.reject(error);
}

if (errMessage) {
if (errorMessageMode === 'modal') {
createErrorModal({ title: t('sys.api.errorTip'), content: errMessage });
} else if (errorMessageMode === 'message') {
createMessage.error(errMessage);
}
return Promise.reject(error);
return Promise.reject(err);
}
} catch (error) {
throw new Error(error);
}

checkStatus(error?.response?.status, msg, errorMessageMode);
return Promise.reject(error);
},
Expand Down
55 changes: 55 additions & 0 deletions src/views/content/attachment/AttachmentDrawer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<BasicDrawer
v-bind="$attrs"
@register="registerDrawer"
showFooter
:title="getTitle"
width="500px"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" />
</BasicDrawer>
</template>
<script lang="ts" setup>
import { ref, computed, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './attachment.data';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { set } from '/@/api/gateway/route';
const emit = defineEmits(['success', 'register']);
const isUpdate = ref(true);
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
resetFields();
setDrawerProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
setFieldsValue({
...data.record,
});
}
});
const getTitle = computed(() => (!unref(isUpdate) ? '新增微服务' : '编辑微服务'));
async function handleSubmit() {
try {
const values = await validate();
setDrawerProps({ confirmLoading: true });
await set(values);
closeDrawer();
emit('success');
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>
Loading

0 comments on commit 896a2c8

Please sign in to comment.