@jx3box/jx3box-editor 2.0.3 → 2.0.5

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.
@@ -1,480 +1,408 @@
1
1
  <template>
2
- <div class="c-resource c-resource__jx3box">
3
- <!-- 上传触发按钮 -->
4
- <el-button
5
- class="u-switch"
6
- type="primary"
7
- @click="openDialog"
8
- :disabled="!enable"
9
- >
10
- <img class="u-icon" svg-inline :src="boxIcon" />魔盒资源
11
- </el-button>
2
+ <div class="c-resource c-resource__jx3box">
3
+ <!-- 上传触发按钮 -->
4
+ <el-button class="u-switch" type="primary" @click="openDialog" :disabled="!enable"> <img class="u-icon" svg-inline :src="boxIcon" />魔盒资源 </el-button>
12
5
 
13
- <!-- 弹出界面 -->
14
- <el-dialog
15
- v-draggable
16
- class="c-large-dialog"
17
- title="魔盒资源库"
18
- :visible.sync="dialogVisible"
19
- >
20
- <div class="c-resource-content" v-loading="loading">
21
- <div class="m-database-search">
22
- <el-radio-group
23
- class="u-client"
24
- v-model="comboClient"
25
- @change="search"
26
- v-if="type === 'combo'"
27
- >
28
- <el-radio-button label="std">重制</el-radio-button>
29
- <el-radio-button label="origin">缘起</el-radio-button>
30
- </el-radio-group>
31
- <el-input
32
- class="u-input"
33
- :placeholder="placeholderText"
34
- v-model="query"
35
- @change="search"
36
- @keyup.enter.native="search"
37
- >
38
- <template slot="prepend">关键词</template>
39
- <template slot="append">
40
- <el-switch v-model="strict" active-text="精确匹配"></el-switch>
41
- </template>
42
- </el-input>
43
- </div>
6
+ <!-- 弹出界面 -->
7
+ <el-dialog v-draggable class="c-large-dialog" title="魔盒资源库" :visible.sync="dialogVisible">
8
+ <div class="c-resource-content" v-loading="loading">
9
+ <div class="m-database-search">
10
+ <el-radio-group class="u-client" v-model="comboClient" @change="search" v-if="type === 'combo'">
11
+ <el-radio-button label="std">重制</el-radio-button>
12
+ <el-radio-button label="origin">缘起</el-radio-button>
13
+ </el-radio-group>
14
+ <el-input class="u-input" :placeholder="placeholderText" v-model="query" @change="search" @keyup.enter.native="search">
15
+ <template slot="prepend">关键词</template>
16
+ <template slot="append">
17
+ <el-switch v-model="strict" active-text="精确匹配"></el-switch>
18
+ </template>
19
+ </el-input>
20
+ </div>
44
21
 
45
- <el-tabs
46
- class="m-database-tabs"
47
- v-model="type"
48
- type="card"
49
- @tab-click="changeType"
50
- >
51
- <el-tab-pane label="魔盒用户" name="authors">
52
- <span slot="label" class="u-tab-label">
53
- <i
54
- class="el-icon-s-custom"
55
- style="margin-right: 5px"
56
- ></i>
57
- <b>用户</b>
58
- <i class="u-lv-box">Lv2+</i>
59
- </span>
60
- <p v-if="total && done" class="m-resource-count">
61
- <i class="el-icon-s-data"></i> 共找到
62
- <b>{{ total }}</b> 条记录
63
- </p>
64
- <ul class="m-resource-list">
65
- <li
66
- v-for="(o, i) in authors"
67
- class="u-item"
68
- :key="i"
69
- :class="{ on: !!o.isSelected }"
70
- @click="selectAuthor(o, i)"
71
- ref="author"
72
- >
73
- <span class="u-id">ID:{{ o.ID }}</span>
74
- <img
75
- class="u-pic"
76
- :title="'AuthorID:' + o.display_name"
77
- :src="userAvatar(o.user_avatar)"
78
- />
79
- <span class="u-primary">
80
- <span class="u-name">
81
- {{ o.display_name }}
82
- </span>
83
- <div class="u-remark">
84
- {{ o.user_bio }}
85
- </div>
86
- </span>
87
- </li>
88
- </ul>
89
- <el-alert
90
- v-if="!authors.length && done"
91
- title="没有找到相关条目"
92
- type="info"
93
- show-icon
94
- ></el-alert>
95
- </el-tab-pane>
96
- <el-tab-pane label="剑三趣图" name="emotions">
97
- <span slot="label" class="u-tab-label">
98
- <i
99
- class="el-icon-sugar"
100
- style="margin-right: 5px"
101
- ></i>
102
- <b>趣图</b>
103
- </span>
104
- <p v-if="total && done" class="m-resource-count">
105
- <i class="el-icon-s-data"></i> 共找到
106
- <b>{{ total }}</b> 条记录
107
- </p>
108
- <ul class="m-resource-emotion">
109
- <li
110
- v-for="o in emotions"
111
- class="u-item"
112
- :key="o.id"
113
- :class="{ on: !!o.isSelected }"
114
- @click="selectEmotion(o)"
115
- ref="emotion"
116
- >
117
- <img
118
- class="e-jx3-emotion"
119
- :src="resolveImagePath(o.url)"
120
- :alt="query"
121
- />
122
- </li>
123
- </ul>
124
- <el-alert
125
- v-if="!emotions.length && done"
126
- title="没有找到相关条目"
127
- type="info"
128
- show-icon
129
- ></el-alert>
130
- </el-tab-pane>
131
- <el-tab-pane label="连招" name="combo">
132
- <span slot="label" class="u-tab-label">
133
- <i
134
- class="el-icon-lollipop"
135
- style="margin-right: 5px"
136
- ></i>
137
- <b>连招</b>
138
- </span>
139
- <ComboVue :query="query" ref="combo" :client="comboClient" :strict="strict"></ComboVue>
140
- </el-tab-pane>
141
- </el-tabs>
22
+ <el-tabs class="m-database-tabs" v-model="type" type="card" @tab-click="changeType">
23
+ <el-tab-pane label="魔盒用户" name="authors">
24
+ <span slot="label" class="u-tab-label">
25
+ <i class="el-icon-s-custom" style="margin-right: 5px"></i>
26
+ <b>用户</b>
27
+ <i class="u-lv-box">Lv2+</i>
28
+ </span>
29
+ <p v-if="total && done" class="m-resource-count">
30
+ <i class="el-icon-s-data"></i> 共找到 <b>{{ total }}</b> 条记录
31
+ </p>
32
+ <ul class="m-resource-list">
33
+ <li v-for="(o, i) in authors" class="u-item" :key="i" :class="{ on: !!o.isSelected }" @click="selectAuthor(o, i)" ref="author">
34
+ <span class="u-id">ID:{{ o.ID }}</span>
35
+ <img class="u-pic" :title="'AuthorID:' + o.display_name" :src="userAvatar(o.user_avatar)" />
36
+ <span class="u-primary">
37
+ <span class="u-name">
38
+ {{ o.display_name }}
39
+ </span>
40
+ <div class="u-remark">
41
+ {{ o.user_bio }}
42
+ </div>
43
+ </span>
44
+ </li>
45
+ </ul>
46
+ <el-alert v-if="!authors.length && done" title="没有找到相关条目" type="info" show-icon></el-alert>
47
+ </el-tab-pane>
48
+ <el-tab-pane label="剑三趣图" name="emotions">
49
+ <span slot="label" class="u-tab-label">
50
+ <i class="el-icon-sugar" style="margin-right: 5px"></i>
51
+ <b>趣图</b>
52
+ </span>
53
+ <p v-if="total && done" class="m-resource-count">
54
+ <i class="el-icon-s-data"></i> 共找到 <b>{{ total }}</b> 条记录
55
+ </p>
56
+ <ul class="m-resource-emotion">
57
+ <li v-for="o in emotions" class="u-item" :key="o.id" :class="{ on: !!o.isSelected }" @click="selectEmotion(o)" ref="emotion">
58
+ <img class="e-jx3-emotion" :src="resolveImagePath(o.url)" :alt="query" />
59
+ </li>
60
+ </ul>
61
+ <el-alert v-if="!emotions.length && done" title="没有找到相关条目" type="info" show-icon></el-alert>
62
+ </el-tab-pane>
63
+ <el-tab-pane label="连招" name="combo">
64
+ <span slot="label" class="u-tab-label">
65
+ <i class="el-icon-lollipop" style="margin-right: 5px"></i>
66
+ <b>连招</b>
67
+ </span>
68
+ <ComboVue :query="query" ref="combo" :client="comboClient" :strict="strict"></ComboVue>
69
+ </el-tab-pane>
70
+ <el-tab-pane label="信纸" name="letter">
71
+ <span slot="label" class="u-tab-label">
72
+ <i class="el-icon-coffee-cup" style="margin-right: 5px"></i>
73
+ <b>信纸</b>
74
+ </span>
75
+ <div class="m-letter-list">
76
+ <div class="m-letter" :class="{ active: !!o.isSelected }" v-for="o in filterLetter" :key="o.id" @click="selectLetter(o)">
77
+ <LetterPaper :data="o" />
78
+ </div>
79
+ </div>
80
+ <el-alert v-if="!letter.length && done" title="没有找到相关条目" type="info" show-icon></el-alert>
81
+ </el-tab-pane>
82
+ </el-tabs>
142
83
 
143
- <template v-if="multipage && type !== 'combo'">
144
- {{ multipage && type !== "combo" }}
145
- <!-- 下一页 -->
146
- <el-button
147
- class="m-archive-more"
148
- :class="{ show: hasNextPage }"
149
- type="primary"
150
- icon="el-icon-arrow-down"
151
- @click="appendPage"
152
- >加载更多</el-button
153
- >
154
- <!-- 分页 -->
155
- <el-pagination
156
- class="m-archive-pages"
157
- background
158
- layout="total, prev, pager, next,jumper"
159
- :hide-on-single-page="true"
160
- :page-size="per"
161
- :total="total"
162
- :current-page.sync="page"
163
- @current-change="changePage"
164
- ></el-pagination>
165
- </template>
84
+ <template v-if="multipage && type !== 'combo'"> </template>
166
85
 
167
- <div class="m-database-tip" v-show="isBlank && type !== 'combo'">
168
- ❤ 请输入搜索条件查询
169
- </div>
170
- </div>
86
+ <div class="m-database-tip" v-show="isBlank && type !== 'combo'">❤ 请输入搜索条件查询</div>
87
+ </div>
171
88
 
172
- <!-- 插入按钮 -->
173
- <span slot="footer" class="dialog-footer">
174
- <el-button @click="dialogVisible = false">取 消</el-button>
175
- <el-button type="primary" @click="insert">
176
- {{ buttonTXT }}
177
- </el-button>
178
- </span>
179
- </el-dialog>
180
- </div>
89
+ <!-- 插入按钮 -->
90
+ <span slot="footer" class="dialog-footer">
91
+ <el-button @click="dialogVisible = false">取 消</el-button>
92
+ <el-button type="primary" @click="insert">
93
+ {{ buttonTXT }}
94
+ </el-button>
95
+ </span>
96
+ </el-dialog>
97
+ </div>
181
98
  </template>
182
99
 
183
100
  <script>
184
101
  import { loadStat } from "../service/database";
185
- import { loadAuthors, loadEmotions } from "../service/cms";
102
+ import { loadAuthors, loadEmotions, getLetterPaper } from "../service/cms";
186
103
  import { getUserInfo } from "../service/author";
187
- import {
188
- __iconPath,
189
- __Root,
190
- __OriginRoot,
191
- __imgPath,
192
- } from "@jx3box/jx3box-common/data/jx3box.json";
193
- import {
194
- getLink,
195
- showAvatar,
196
- resolveImagePath,
197
- } from "@jx3box/jx3box-common/js/utils";
104
+ import { __iconPath, __Root, __OriginRoot, __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
105
+ import { getLink, showAvatar, resolveImagePath } from "@jx3box/jx3box-common/js/utils";
198
106
  import User from "@jx3box/jx3box-common/js/user";
199
107
 
200
108
  import ComboVue from "./components/Combo.vue";
109
+ import LetterPaper from "./components/Letter.vue";
201
110
  export default {
202
- name: "BoxResource",
203
- components: {
204
- ComboVue,
205
- },
206
- props: {
207
- enable: {
208
- type: Boolean,
209
- default: true,
210
- },
211
- },
212
- data: function () {
213
- return {
214
- dialogVisible: false,
215
- actived: false,
216
- userInfo: {},
111
+ name: "BoxResource",
112
+ components: {
113
+ ComboVue,
114
+ LetterPaper,
115
+ },
116
+ props: {
117
+ enable: {
118
+ type: Boolean,
119
+ default: true,
120
+ },
121
+ },
122
+ data: function () {
123
+ return {
124
+ dialogVisible: false,
125
+ actived: false,
126
+ userInfo: {},
217
127
 
218
- type: "authors",
219
- query: "",
220
- strict: false,
221
- client: location.hostname.includes("origin") ? "origin" : "std",
222
- comboClient: "std",
128
+ type: "authors",
129
+ query: "",
130
+ strict: false,
131
+ client: location.hostname.includes("origin") ? "origin" : "std",
132
+ comboClient: "std",
223
133
 
224
- skill: [],
225
- buff: [],
226
- item: [],
227
- icon: [],
228
- npc: [],
229
- authors: [],
230
- selectedAuthor: {},
231
- emotions: [],
134
+ skill: [],
135
+ buff: [],
136
+ item: [],
137
+ icon: [],
138
+ npc: [],
139
+ authors: [],
140
+ selectedAuthor: {},
141
+ emotions: [],
142
+ letter: [],
232
143
 
233
- done: false,
234
- loading: false,
144
+ done: false,
145
+ loading: false,
235
146
 
236
- isSuper: false,
147
+ isSuper: false,
237
148
 
238
- html: "",
149
+ html: "",
239
150
 
240
- per: 10,
241
- page: 1,
242
- total: 1,
243
- pages: 1,
151
+ per: 10,
152
+ page: 1,
153
+ total: 1,
154
+ pages: 1,
244
155
 
245
- placeholderTexts: {
246
- authors: "请输入 ID 或 名称",
247
- },
248
- };
249
- },
250
- computed: {
251
- placeholderText: function () {
252
- return this.placeholderTexts[this.type];
253
- },
254
- buttonTXT: function () {
255
- return this.selectedCount ? "插 入" : "确 定";
256
- },
257
- isBlank: function () {
258
- return !this.query && !this[this.type]?.["length"];
259
- },
260
- selectedCount: function () {
261
- return !!this.html;
262
- },
263
- isNumber: function () {
264
- return !isNaN(this.query);
265
- },
266
- hasNextPage: function () {
267
- return this.total > 1 && this.page < this.pages;
268
- },
269
- multipage: function () {
270
- return this.type !== "icon" && this.done && this.pages > 1;
271
- },
272
- iconDir: function () {
273
- return this.client === "origin" ? "origin_icon" : "icon";
274
- },
275
- userStatus: function () {
276
- return User.getInfo().status;
277
- },
278
- uid: function () {
279
- return User.getInfo().uid;
280
- },
281
- canInsertAuthor: function () {
282
- return (
283
- User.getLevel(this.userInfo && this.userInfo.experience) >= 2
284
- );
285
- },
286
- boxIcon: function () {
287
- return __imgPath + "image/common/jx3box_white.svg";
288
- },
289
- },
290
- watch: {
291
- html: function (newval) {
292
- this.$emit("update", newval);
293
- },
294
- },
295
- methods: {
296
- getData: function (page = 1, append = false) {
297
- this.loading = true;
298
- this.per = 10;
299
- this.done = false;
300
- let query = this.query;
301
- let params = {
302
- strict: ~~this.strict,
303
- per: this.per,
304
- page: page,
305
- client: this.client,
306
- };
156
+ placeholderTexts: {
157
+ authors: "请输入 ID 或 名称",
158
+ },
159
+ };
160
+ },
161
+ computed: {
162
+ placeholderText: function () {
163
+ return this.placeholderTexts[this.type];
164
+ },
165
+ buttonTXT: function () {
166
+ return this.selectedCount ? "插 入" : "确 定";
167
+ },
168
+ isBlank: function () {
169
+ return !this.query && !this[this.type]?.["length"];
170
+ },
171
+ selectedCount: function () {
172
+ return !!this.html;
173
+ },
174
+ isNumber: function () {
175
+ return !isNaN(this.query);
176
+ },
177
+ hasNextPage: function () {
178
+ return this.total > 1 && this.page < this.pages;
179
+ },
180
+ multipage: function () {
181
+ return this.type !== "icon" && this.done && this.pages > 1;
182
+ },
183
+ iconDir: function () {
184
+ return this.client === "origin" ? "origin_icon" : "icon";
185
+ },
186
+ userStatus: function () {
187
+ return User.getInfo().status;
188
+ },
189
+ uid: function () {
190
+ return User.getInfo().uid;
191
+ },
192
+ canInsertAuthor: function () {
193
+ return User.getLevel(this.userInfo && this.userInfo.experience) >= 2;
194
+ },
195
+ boxIcon: function () {
196
+ return __imgPath + "image/common/jx3box_white.svg";
197
+ },
198
+ filterLetter() {
199
+ return this.letter;
200
+ },
201
+ },
202
+ watch: {
203
+ html: function (newval) {
204
+ this.$emit("update", newval);
205
+ },
206
+ },
207
+ methods: {
208
+ getData: function (page = 1, append = false) {
209
+ this.loading = true;
210
+ this.per = 10;
211
+ this.done = false;
212
+ let query = this.query;
213
+ let params = {
214
+ strict: ~~this.strict,
215
+ per: this.per,
216
+ page: page,
217
+ client: this.client,
218
+ };
307
219
 
308
- // 图标
309
- if (this.type === "authors") {
310
- if (!this.query) {
311
- this.loading = false;
312
- return;
313
- }
220
+ // 图标
221
+ if (this.type === "authors") {
222
+ if (!this.query) {
223
+ this.loading = false;
224
+ return;
225
+ }
314
226
 
315
- params = {
316
- ...params,
317
- name: query,
318
- };
319
- loadAuthors(params)
320
- .then((res) => {
321
- if (!append) this.authors = [];
322
- let list = this.transformData(res.data.data.list);
323
- this.authors = this.authors.concat(list);
324
- this.pages = res.data.data.pages;
325
- this.total = res.data.data.total;
326
- })
327
- .finally(() => {
328
- this.done = true;
329
- this.loading = false;
330
- });
331
- } else if (this.type === "emotions") {
332
- this.per = 24;
333
- params = {
334
- per: this.per,
335
- page: page,
336
- search: query,
337
- };
338
- loadEmotions(params)
339
- .then((res) => {
340
- if (!append) this.emotions = [];
341
- let list = this.transformData(res.data.data.list);
342
- this.emotions = this.emotions.concat(list);
343
- this.pages = res.data.data.pages;
344
- this.total = res.data.data.total;
345
- })
346
- .finally(() => {
347
- this.done = true;
348
- this.loading = false;
349
- });
350
- }
351
- },
352
- search: function () {
353
- if (this.type === "combo") {
354
- this.$refs.combo?.search();
355
- } else {
356
- this.page = 1;
357
- this.getData();
358
- }
359
- },
360
- appendPage: function () {
361
- this.getData(++this.page, true);
362
- },
363
- changePage: function (i) {
364
- this.getData(i);
365
- },
366
- changeType: function () {
367
- this.page = 1;
368
- if (this.type === "combo") {
369
- this.done = false;
370
- return;
371
- }
372
- this.getData();
373
- },
374
- setAuthors: function () {
375
- try {
376
- let author = sessionStorage.getItem("atAuthor");
377
- if (author) {
378
- author = JSON.parse(author);
379
- author = author.split(",") || [];
380
- if (
381
- this.selectedAuthor.ID &&
382
- !author.includes(String(this.selectedAuthor.ID))
383
- ) {
384
- author.push(this.selectedAuthor.ID);
385
- }
386
- sessionStorage.setItem(
387
- "atAuthor",
388
- JSON.stringify(author.join(","))
389
- );
390
- } else {
391
- sessionStorage.setItem(
392
- "atAuthor",
393
- JSON.stringify(String(this.selectedAuthor.ID))
394
- );
395
- }
396
- } catch (error) {
397
- console.log(error);
398
- }
399
- },
400
- insert: function () {
401
- if (this.type === "authors") {
402
- if (this.userStatus == 0 && this.canInsertAuthor) {
403
- if (this.selectedAuthor.ID) {
404
- this.setAuthors();
405
- this.$emit("insert", this.html);
406
- this.dialogVisible = false;
407
- this.selectedAuthor = {};
408
- } else {
409
- this.$message.warning("请选择一个用户");
410
- }
411
- } else {
412
- this.$alert("您的等级不足或无权限(Lv2以上可用)", "消息");
413
- }
414
- } else {
415
- if (this.type === 'combo') {
416
- const html = this.$refs.combo.renderVal();
417
- this.$emit("insert", html);
418
- } else {
419
- this.$emit("insert", this.html);
420
- }
421
- this.dialogVisible = false;
422
- }
423
- },
424
- transformData: function (data) {
425
- data.forEach((item) => {
426
- item.isSelected = false;
427
- });
428
- return data;
429
- },
430
- selectAuthor: function (o) {
431
- this.resetItems();
432
- this.selectedAuthor = o;
433
- o.isSelected = true;
434
- this.html = `<a data-type="author" class="e-jx3-author w-jx3-element" data-mode="" data-id="${o.ID}" target="_blank" href="/author/${o.ID}">@${o.display_name}</a>`;
435
- },
436
- selectEmotion: function (o) {
437
- this.resetItems();
438
- o.isSelected = true;
439
- this.html = `<a data-type="emotion" class="e-jx3-emotion w-jx3-element" data-id="${o.id}" target="_blank" href="/emotion/${o.id}"><img class="e-jx3-emotion-img" data-type="emotion" data-id="${o.id}" style="width:180px;" src="${o.url}" alt="${o.id}"/></a>`;
440
- },
441
- resetItems: function () {
442
- let data = this[this.type];
443
- data.forEach((item) => {
444
- item.isSelected = false;
445
- });
446
- this.html = "";
447
- },
448
- getLink: function (type, id) {
449
- let domain = this.client == "origin" ? __OriginRoot : __Root;
450
- return domain + getLink(type, id).slice(1);
451
- },
452
- userAvatar: function (url) {
453
- return showAvatar(url, "m");
454
- },
455
- loadUserInfo: function () {
456
- if (!this.uid) return;
457
- getUserInfo(this.uid).then((res) => {
458
- this.userInfo = res;
459
- });
460
- },
227
+ params = {
228
+ ...params,
229
+ name: query,
230
+ };
231
+ loadAuthors(params)
232
+ .then((res) => {
233
+ if (!append) this.authors = [];
234
+ let list = this.transformData(res.data.data.list);
235
+ this.authors = this.authors.concat(list);
236
+ this.pages = res.data.data.pages;
237
+ this.total = res.data.data.total;
238
+ })
239
+ .finally(() => {
240
+ this.done = true;
241
+ this.loading = false;
242
+ });
243
+ } else if (this.type === "emotions") {
244
+ this.per = 24;
245
+ params = {
246
+ per: this.per,
247
+ page: page,
248
+ search: query,
249
+ };
250
+ loadEmotions(params)
251
+ .then((res) => {
252
+ if (!append) this.emotions = [];
253
+ let list = this.transformData(res.data.data.list);
254
+ this.emotions = this.emotions.concat(list);
255
+ this.pages = res.data.data.pages;
256
+ this.total = res.data.data.total;
257
+ })
258
+ .finally(() => {
259
+ this.done = true;
260
+ this.loading = false;
261
+ });
262
+ } else if (this.type === "letter") {
263
+ const { per, page } = params;
264
+ const _params = { per, page };
265
+ if (this.query) _params._search = this.query;
266
+ getLetterPaper(_params)
267
+ .then((res) => {
268
+ if (!append) this.letter = [];
269
+ let list = this.transformData(res.data.data.list);
270
+ this.letter = this.letter.concat(list);
271
+ this.pages = res.data.data.pages;
272
+ this.total = res.data.data.total;
273
+ })
274
+ .finally(() => {
275
+ this.done = true;
276
+ this.loading = false;
277
+ });
278
+ }
279
+ },
280
+ search: function () {
281
+ if (this.type === "combo") {
282
+ this.$refs.combo?.search();
283
+ } else {
284
+ this.page = 1;
285
+ this.getData();
286
+ }
287
+ },
288
+ appendPage: function () {
289
+ this.getData(++this.page, true);
290
+ },
291
+ changePage: function (i) {
292
+ this.getData(i);
293
+ },
294
+ changeType: function () {
295
+ this.page = 1;
296
+ if (this.type === "combo") {
297
+ this.done = false;
298
+ return;
299
+ }
300
+ this.getData();
301
+ },
302
+ setAuthors: function () {
303
+ try {
304
+ let author = sessionStorage.getItem("atAuthor");
305
+ if (author) {
306
+ author = JSON.parse(author);
307
+ author = author.split(",") || [];
308
+ if (this.selectedAuthor.ID && !author.includes(String(this.selectedAuthor.ID))) {
309
+ author.push(this.selectedAuthor.ID);
310
+ }
311
+ sessionStorage.setItem("atAuthor", JSON.stringify(author.join(",")));
312
+ } else {
313
+ sessionStorage.setItem("atAuthor", JSON.stringify(String(this.selectedAuthor.ID)));
314
+ }
315
+ } catch (error) {
316
+ console.log(error);
317
+ }
318
+ },
319
+ insert: function () {
320
+ if (this.type === "authors") {
321
+ if (this.userStatus == 0 && this.canInsertAuthor) {
322
+ if (this.selectedAuthor.ID) {
323
+ this.setAuthors();
324
+ this.$emit("insert", this.html);
325
+ this.dialogVisible = false;
326
+ this.selectedAuthor = {};
327
+ } else {
328
+ this.$message.warning("请选择一个用户");
329
+ }
330
+ } else {
331
+ this.$alert("您的等级不足或无权限(Lv2以上可用)", "消息");
332
+ }
333
+ } else {
334
+ if (this.type === "combo") {
335
+ const html = this.$refs.combo.renderVal();
336
+ this.$emit("insert", html);
337
+ } else {
338
+ this.$emit("insert", this.html);
339
+ }
340
+ this.dialogVisible = false;
341
+ }
342
+ },
343
+ transformData: function (data) {
344
+ data.forEach((item) => {
345
+ item.isSelected = false;
346
+ });
347
+ return data;
348
+ },
349
+ selectAuthor: function (o) {
350
+ this.resetItems();
351
+ this.selectedAuthor = o;
352
+ o.isSelected = true;
353
+ this.html = `<a data-type="author" class="e-jx3-author w-jx3-element" data-mode="" data-id="${o.ID}" target="_blank" href="/author/${o.ID}">@${o.display_name}</a>`;
354
+ },
355
+ selectEmotion: function (o) {
356
+ this.resetItems();
357
+ o.isSelected = true;
358
+ this.html = `<a data-type="emotion" class="e-jx3-emotion w-jx3-element" data-id="${o.id}" target="_blank" href="/emotion/${o.id}"><img class="e-jx3-emotion-img" data-type="emotion" data-id="${o.id}" style="width:180px;" src="${o.url}" alt="${o.id}"/></a>`;
359
+ },
360
+ // 信纸
361
+ selectLetter(o) {
362
+ this.resetItems();
363
+ o.isSelected = true;
364
+ const { slug, style } = o;
365
+ const titleHtml = `<div class="e-letter-title letter-title--${slug}">我是标题</div>`;
366
+ const contentHtml = `<div class="e-letter-content letter-header--${slug}"><div class="u-letter-content--header letter-footer--${slug}"><div class="u-letter-content--footer letter-body--${slug}"><p>明月几时有,把酒问青天。</p></div></div></div>`;
367
+ this.html = `<div class="e-letter letter--${slug}">${titleHtml}<br/> ${contentHtml}</div></div><style>${style}</style>`;
368
+ },
369
+ resetItems: function () {
370
+ let data = this[this.type];
371
+ data.forEach((item) => {
372
+ item.isSelected = false;
373
+ });
374
+ this.html = "";
375
+ },
376
+ getLink: function (type, id) {
377
+ let domain = this.client == "origin" ? __OriginRoot : __Root;
378
+ return domain + getLink(type, id).slice(1);
379
+ },
380
+ userAvatar: function (url) {
381
+ return showAvatar(url, "m");
382
+ },
383
+ loadUserInfo: function () {
384
+ if (!this.uid) return;
385
+ getUserInfo(this.uid).then((res) => {
386
+ this.userInfo = res;
387
+ });
388
+ },
461
389
 
462
- // 杂项
463
- // ==============================
464
- openDialog: function () {
465
- this.dialogVisible = true;
466
- if (!this.actived) {
467
- loadStat().then((data) => {
468
- this.stat = data;
469
- this.actived = true;
470
- });
471
- }
472
- },
473
- resolveImagePath,
474
- },
475
- created: function () {
476
- this.loadUserInfo();
477
- },
390
+ // 杂项
391
+ // ==============================
392
+ openDialog: function () {
393
+ this.dialogVisible = true;
394
+ if (!this.actived) {
395
+ loadStat().then((data) => {
396
+ this.stat = data;
397
+ this.actived = true;
398
+ });
399
+ }
400
+ },
401
+ resolveImagePath,
402
+ },
403
+ created: function () {
404
+ this.loadUserInfo();
405
+ },
478
406
  };
479
407
  </script>
480
408
 
@@ -482,8 +410,40 @@ export default {
482
410
  @import "../assets/css/resource.less";
483
411
 
484
412
  .m-item-pop {
485
- padding: 0 !important;
486
- background: none !important;
487
- border: none;
413
+ padding: 0 !important;
414
+ background: none !important;
415
+ border: none;
416
+ }
417
+ .m-database-tabs .m-letter-list {
418
+ .flex;
419
+ flex-wrap: wrap;
420
+ gap: 20px;
421
+ .m-letter {
422
+ .pointer;
423
+ .pr;
424
+ box-sizing: border-box;
425
+ border: 3px solid transparent;
426
+ &::after {
427
+ content: "";
428
+ display: block;
429
+ .full;
430
+ .pa;
431
+ .lt(0);
432
+ .z(1);
433
+ .tm(0.3);
434
+ .r(3px);
435
+ background: #000;
436
+ }
437
+ &.active {
438
+ .r(5px);
439
+ border: 3px solid #409eff;
440
+ &::after {
441
+ .none;
442
+ }
443
+ }
444
+ .e-letter {
445
+ zoom: 0.7;
446
+ }
447
+ }
488
448
  }
489
449
  </style>