This commit is contained in:
cxc
2023-02-13 17:04:42 +08:00
parent 221c466bdb
commit 730a93c4d3
7 changed files with 67 additions and 42 deletions

8
.env.development Normal file
View File

@ -0,0 +1,8 @@
# 页面标题
#VITE_APP_TITLE = 楚桓会议系统
# 开发环境配置
VITE_APP_ENV = 'development'
# 若依管理系统/开发环境
VITE_APP_BASE_API = '/dev-api'

11
.env.production Normal file
View File

@ -0,0 +1,11 @@
# 页面标题
#VITE_APP_TITLE = 楚桓会议系统
# 生产环境配置
VITE_APP_ENV = 'production'
# 若依管理系统/生产环境
# VITE_APP_BASE_API = '/prod-api'
# VITE_APP_BASE_API = 'http://120.26.107.74:1618'
VITE_APP_BASE_API = '/api'

View File

@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>生成短链接</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -6,20 +6,20 @@ export const listShortLink = (params: { pageNum: number; pageSize: number }) =>
request({
method: "get",
url: "/shortLink/list",
params
params,
});
export const addShortLink = (data: ShortLink) =>
request({
method: "post",
url: "/shortLink",
data
data,
});
export const updateShortLink = (data: ShortLink) =>
request({
method: "put",
url: "/shortLink",
data
data,
});
export const getDetailById = (id: number) =>
request({ method: "get", url: `/shortLink/getInfo/${id}` });
@ -27,12 +27,12 @@ export const getDetailById = (id: number) =>
export const deleteShortLink = (ids: string) =>
request({
url: `/shortLink/${ids}`,
method: "delete"
method: "delete",
});
export const listLogList = (params: LogListParams) =>
request({
url: `/shortLink/getShortLinkLogList`,
method: "get",
params
params,
});

View File

@ -5,9 +5,9 @@ import { errorCode } from "@/utils/errorCode";
const service = axios.create({
// axios中请求配置有baseURL选项表示请求URL公共部分
// baseURL: import.meta.env.VITE_APP_BASE_API,
baseURL: import.meta.env.VITE_APP_BASE_API,
// 超时
baseURL: "/dev-api",
// baseURL: "/dev-api",
timeout: 100000,
});

View File

@ -3,7 +3,7 @@
<el-row :gutter="10">
<el-col :span="1.5">
<el-button @click="handleAdd" type="primary" size="small" icon="plus"
>新增
>新增
</el-button>
</el-col>
<el-col :span="1.5">
@ -13,7 +13,7 @@
type="danger"
size="small"
:disabled="multiple"
>批量删除
>批量删除
</el-button>
</el-col>
</el-row>
@ -37,7 +37,7 @@
<div>
<a
class="short-link"
:href="`//${row.urlPrefix}/dlj/${row.urlSuffix}`"
:href="`${row.urlPrefix}/dlj/${row.urlSuffix}`"
>
{{ row.urlPrefix }}/dlj/{{ row.urlSuffix }}
</a>
@ -60,7 +60,7 @@
:style="{
cursor: 'pointer',
}"
@click="copyToClipboard(row.jumpUrl)"
@click="copyToClipboard(row)"
>
<CopyDocument />
</el-icon>
@ -96,21 +96,21 @@
link
size="small"
type="warning"
>编辑
>编辑
</el-button>
<el-button
@click="handleDelete(row.id)"
link
size="small"
type="danger"
>删除
>删除
</el-button>
<el-button
@click="goLogList(row.urlSuffix)"
link
size="small"
type="primary"
>访问记录
>访问记录
</el-button>
</template>
</el-table-column>
@ -174,14 +174,20 @@
width: '100%',
marginTop: '10px',
}"
>下载二维码
>下载二维码
</el-button>
</el-dialog>
</div>
</template>
<script setup lang="ts" name="GenShortLink">
import { addShortLink, deleteShortLink, getDetailById, listShortLink, updateShortLink } from "@/api/shortlink";
import {
addShortLink,
deleteShortLink,
getDetailById,
listShortLink,
updateShortLink,
} from "@/api/shortlink";
import { reactive, ref, toRefs } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import type { ShortLink } from "@/models/shortLink";
@ -204,7 +210,7 @@ const data = reactive<{
}>({
queryParams: {
pageNum: 1,
pageSize: 10
pageSize: 10,
},
form: {},
rules: {
@ -212,31 +218,31 @@ const data = reactive<{
{
required: true,
message: "请输入短链接名称",
trigger: "blur"
}
trigger: "blur",
},
],
jumpUrl: [
{
required: true,
message: "请输入短链接",
trigger: "blur"
}
trigger: "blur",
},
],
urlPrefix: [
{
required: true,
message: "请输入URL前缀",
trigger: "blur"
}
trigger: "blur",
},
],
validityTime: [
{
required: true,
message: "请选择过期时间",
trigger: "change"
}
]
}
trigger: "change",
},
],
},
});
const { form, queryParams, rules } = toRefs(data);
const total = ref<number>(0);
@ -253,7 +259,7 @@ const handleShowQrCode = (data: ShortLink) => {
};
const goLogList = (suffix: string) => {
router.push({
path: `/log-list/${suffix}`
path: `/log-list/${suffix}`,
});
};
const reset = () => {
@ -286,8 +292,8 @@ const handleSelectionChange = (selection: ShortLink[]) => {
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const copyToClipboard = (data: string) => {
navigator.clipboard.writeText(data);
const copyToClipboard = (data: ShortLink) => {
navigator.clipboard.writeText(`${data.urlPrefix}/dlj/${data.urlSuffix}`);
ElMessage.success("短链接已拷贝到剪贴板");
};
const handleAdd = () => {
@ -310,7 +316,7 @@ const handleDelete = (id?: string) => {
ids = linkIds.value.join(",");
}
ElMessageBox.confirm("确认删除该短链接吗", "删除短链接", {
type: "warning"
type: "warning",
}).then(async () => {
await deleteShortLink(ids);
ElMessage.success("删除短链接成功");
@ -377,7 +383,7 @@ getList();
margin-top: 20px;
margin-right: 10px;
display: flex;
justify-content: end;
justify-content: flex-end;
}
}
</style>