2021-10-22 18:51:49 +08:00
|
|
|
<template>
|
2022-06-14 09:05:00 +08:00
|
|
|
<a
|
|
|
|
class="one-edit-link"
|
|
|
|
:class="
|
|
|
|
variant
|
|
|
|
? {
|
|
|
|
[`one-edit-link-${variant}`]: true,
|
|
|
|
}
|
|
|
|
: {}
|
|
|
|
"
|
|
|
|
:href="href"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener"
|
|
|
|
>
|
|
|
|
<slot :label="t('editOnGitHub')">
|
|
|
|
<span class="full">{{ t("editOnGitHub", { item: t(type) }) }}</span>
|
|
|
|
<span class="short">{{ t("edit") }}</span>
|
|
|
|
<veui-icon class="icon" name="external-link" />
|
|
|
|
</slot>
|
|
|
|
</a>
|
2021-10-22 18:51:49 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-06-14 09:05:00 +08:00
|
|
|
import { Icon } from "veui";
|
|
|
|
import i18n from "veui/mixins/i18n";
|
|
|
|
import "veui-theme-dls-icons/external-link";
|
|
|
|
import Config from "./../env";
|
2021-10-22 18:51:49 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
const BASE_URL = Config.github_repo;
|
2021-10-22 18:51:49 +08:00
|
|
|
|
|
|
|
export default {
|
2022-06-14 09:05:00 +08:00
|
|
|
name: "one-edit-link",
|
2021-10-22 18:51:49 +08:00
|
|
|
components: {
|
2022-06-14 09:05:00 +08:00
|
|
|
"veui-icon": Icon,
|
2021-10-22 18:51:49 +08:00
|
|
|
},
|
|
|
|
mixins: [i18n],
|
|
|
|
props: {
|
2021-10-25 20:18:05 +08:00
|
|
|
variant: {
|
|
|
|
type: String,
|
2022-06-14 09:05:00 +08:00
|
|
|
default: "default",
|
2021-10-25 20:18:05 +08:00
|
|
|
},
|
2022-02-23 20:19:58 +08:00
|
|
|
path: String,
|
|
|
|
type: {
|
|
|
|
type: String,
|
2022-06-14 09:05:00 +08:00
|
|
|
default: "page",
|
|
|
|
},
|
2021-10-22 18:51:49 +08:00
|
|
|
},
|
|
|
|
computed: {
|
2022-06-14 09:05:00 +08:00
|
|
|
href() {
|
|
|
|
return `${BASE_URL}${this.path}`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2021-10-22 18:51:49 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2022-06-14 09:05:00 +08:00
|
|
|
.one-edit-link {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
text-decoration: none;
|
|
|
|
transition: background 0.2s, color 0.2s, border-color 0.2s;
|
2021-10-25 20:18:05 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
.icon {
|
|
|
|
margin-left: 4px;
|
|
|
|
}
|
2021-10-28 15:30:35 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
&-default {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 4px 6px;
|
|
|
|
border-radius: 4px;
|
|
|
|
background-color: #fff;
|
|
|
|
color: #848b99;
|
|
|
|
border: 1px solid #e2e6f0;
|
2021-10-25 20:18:05 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
&:hover, &[data-focus-visible-added] {
|
|
|
|
background-color: #f6f7fa;
|
|
|
|
color: #282c33;
|
|
|
|
border-color: #d3d9e6;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
background-color: #e2e6f0;
|
|
|
|
color: #000;
|
|
|
|
border-color: #d3d9e6;
|
|
|
|
}
|
|
|
|
}
|
2021-10-25 20:18:05 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
&-quiet {
|
|
|
|
color: #282c33;
|
2021-10-25 20:18:05 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
&:hover, &[data-focus-visible-added] {
|
|
|
|
color: #545b66;
|
|
|
|
}
|
2021-10-22 18:51:49 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
&:active {
|
|
|
|
color: #000;
|
|
|
|
}
|
2021-10-22 18:51:49 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
.full {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
}
|
2021-10-28 15:30:35 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
.short {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2021-11-22 15:57:07 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
@media (max-width: 480px) {
|
|
|
|
.one-edit-link-quiet {
|
|
|
|
.full {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-10-28 15:30:35 +08:00
|
|
|
|
2022-06-14 09:05:00 +08:00
|
|
|
.short {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-22 18:51:49 +08:00
|
|
|
</style>
|