@jx3box/jx3box-ui 2.0.6 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <WikiPanel class="c-wiki-revisions" scene="detail">
3
+ <template #head-title>
4
+ <i class="el-icon-time"></i>
5
+ <span>历史版本</span>
6
+ </template>
7
+ <template #body>
8
+ <div class="m-revisions-panel">
9
+ <div class="u-empty" v-if="!versions || !versions.length">
10
+ <span v-if="versions === null">🎉 数据加载中...</span>
11
+ <span v-if="versions === false">⚠️ 数据加载异常</span>
12
+ <span v-if="versions && !versions.length">💧 暂无数据</span>
13
+ </div>
14
+ <table v-if="versions && versions.length" class="m-histories">
15
+ <thead>
16
+ <tr>
17
+ <th>版本</th>
18
+ <th>更新时间</th>
19
+ <th>贡献者</th>
20
+ <th>修订说明</th>
21
+ </tr>
22
+ </thead>
23
+ <tr class="history" v-for="(ver, key) in versions" :key="key">
24
+ <td>
25
+ <a
26
+ :href="link(type, `${ver.source_id}/${ver.id}`)"
27
+ v-text="'v' + (versions.length - key)"
28
+ @click="redirectRevision(ver, $event)"
29
+ ></a>
30
+ </td>
31
+ <td v-text="ts2str(ver.updated)"></td>
32
+ <td>
33
+ <a :href="ver.user_id ? author_url(ver.user_id) : null" v-text="ver.user_nickname"></a>
34
+ </td>
35
+ <td v-text="ver.remark"></td>
36
+ </tr>
37
+ </table>
38
+ </div>
39
+ </template>
40
+ </WikiPanel>
41
+ </template>
42
+
43
+ <script>
44
+ import WikiPanel from "./WikiPanel";
45
+ import { wiki } from "@jx3box/jx3box-common/js/wiki";
46
+ import { getLink, authorLink, ts2str } from "@jx3box/jx3box-common/js/utils";
47
+ import jx3box from "@jx3box/jx3box-common/data/jx3box.json";
48
+ const { __Root, __OriginRoot } = jx3box;
49
+
50
+ export default {
51
+ name: "WikiRevisions",
52
+ props: {
53
+ type: {
54
+ type: String,
55
+ default: "",
56
+ },
57
+ sourceId: {
58
+ type: [String, Number],
59
+ default: "",
60
+ },
61
+ isGame: {
62
+ type: [Boolean, Number],
63
+ default: false,
64
+ },
65
+ },
66
+ data: function () {
67
+ return {
68
+ versions: [],
69
+ };
70
+ },
71
+ computed: {
72
+ client: function () {
73
+ return location.href.includes("classic") || location.href.includes("origin") ? "origin" : "std";
74
+ },
75
+ baseUrl: function () {
76
+ return this.client == "origin" ? __OriginRoot : __Root;
77
+ },
78
+ prefix: function () {
79
+ if (this.isGame) {
80
+ return this.baseUrl.slice(0, -1);
81
+ } else {
82
+ return "";
83
+ }
84
+ },
85
+ },
86
+ methods: {
87
+ link: function (type, id) {
88
+ return this.prefix + getLink(type, id);
89
+ },
90
+ author_url: function (uid) {
91
+ return this.prefix + authorLink(uid);
92
+ },
93
+ ts2str,
94
+ redirectRevision: function (ver, e) {
95
+ if (!this.isGame && this.$router) {
96
+ e.preventDefault();
97
+ this.$router.replace({ path: `/view/${ver.source_id}/${ver.id}` });
98
+ }
99
+ },
100
+ },
101
+ components: {
102
+ WikiPanel,
103
+ },
104
+ watch: {
105
+ sourceId: {
106
+ immediate: true,
107
+ handler() {
108
+ if (this.sourceId) {
109
+ wiki.versions({ type: this.type, id: this.sourceId }, { client: this.client }).then(
110
+ (res) => {
111
+ res = res.data;
112
+ this.versions = res.data || [];
113
+ },
114
+ () => {
115
+ this.versions = [];
116
+ }
117
+ );
118
+ }
119
+ },
120
+ },
121
+ },
122
+ };
123
+ </script>
124
+
125
+ <style lang="less">
126
+ @import "../../assets/css/wiki/wiki-revisions.less";
127
+ </style>