@jx3box/jx3box-ui 0.0.1
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.
- package/.env +6 -0
- package/README.md +4 -0
- package/assets/css/bread/admin.less +131 -0
- package/assets/css/bread/breadcrumb.less +163 -0
- package/assets/css/bread/crumb.less +17 -0
- package/assets/css/comment/quick-reply.less +56 -0
- package/assets/css/common/bottom.less +21 -0
- package/assets/css/common/footer.less +78 -0
- package/assets/css/common/left-sidebar.less +137 -0
- package/assets/css/common/main.less +75 -0
- package/assets/css/common/right-sidebar.less +193 -0
- package/assets/css/common/suspend-common.less +343 -0
- package/assets/css/editor/article.less +36 -0
- package/assets/css/editor/combo.less +311 -0
- package/assets/css/editor/resource.less +335 -0
- package/assets/css/editor/tinymce.less +80 -0
- package/assets/css/editor/upload.less +111 -0
- package/assets/css/filters/client-by.less +33 -0
- package/assets/css/header/box.less +181 -0
- package/assets/css/interact/like2.less +20 -0
- package/assets/css/interact/share2.less +101 -0
- package/assets/css/mixin.less +64 -0
- package/assets/css/module/author.less +190 -0
- package/assets/css/module/buff.less +78 -0
- package/assets/css/module/directory.less +143 -0
- package/assets/css/module/icon.less +21 -0
- package/assets/css/module/item.less +229 -0
- package/assets/css/module/item_simple.less +51 -0
- package/assets/css/module/jx3_element.less +4 -0
- package/assets/css/module/macro.less +72 -0
- package/assets/css/module/npc.less +220 -0
- package/assets/css/module/resource.less +80 -0
- package/assets/css/module/skill.less +65 -0
- package/assets/css/module/talent.less +424 -0
- package/assets/css/single/author.less +101 -0
- package/assets/css/single/cms-single.less +55 -0
- package/assets/css/single/thx.less +230 -0
- package/assets/css/tinymce/_.less +28 -0
- package/assets/css/tinymce/a.less +29 -0
- package/assets/css/tinymce/code.less +159 -0
- package/assets/css/tinymce/combo.less +86 -0
- package/assets/css/tinymce/fold.less +70 -0
- package/assets/css/tinymce/h.less +58 -0
- package/assets/css/tinymce/hr.less +9 -0
- package/assets/css/tinymce/img.less +16 -0
- package/assets/css/tinymce/imgpreview.less +14 -0
- package/assets/css/tinymce/latex.less +43 -0
- package/assets/css/tinymce/list.less +65 -0
- package/assets/css/tinymce/macro.less +40 -0
- package/assets/css/tinymce/nextpage.less +65 -0
- package/assets/css/tinymce/p.less +8 -0
- package/assets/css/tinymce/plugin.less +3 -0
- package/assets/css/tinymce/pz.less +39 -0
- package/assets/css/tinymce/qixue.less +39 -0
- package/assets/css/tinymce/quote.less +12 -0
- package/assets/css/tinymce/table.less +59 -0
- package/assets/css/tinymce/video.less +61 -0
- package/assets/css/var.less +1 -0
- package/assets/data/box.json +184 -0
- package/assets/data/box2.json +606 -0
- package/assets/data/detach_type.json +29 -0
- package/assets/data/game_font.json +242 -0
- package/assets/data/nav.json +12 -0
- package/assets/data/panel.json +27 -0
- package/assets/data/reply_template.json +6 -0
- package/assets/data/weapon_type.json +20 -0
- package/assets/data/zlp.json +5 -0
- package/assets/img/author/bilibili.png +0 -0
- package/assets/img/author/bilibili.svg +1 -0
- package/assets/img/author/chat.png +0 -0
- package/assets/img/author/douyu.png +0 -0
- package/assets/img/author/douyu.svg +1 -0
- package/assets/img/author/github.svg +1 -0
- package/assets/img/author/huya.png +0 -0
- package/assets/img/author/huya.svg +1 -0
- package/assets/img/author/msg.svg +55 -0
- package/assets/img/author/tuilan.png +0 -0
- package/assets/img/author/weibo.svg +70 -0
- package/assets/img/bread/menu.svg +1 -0
- package/assets/img/comment/comment.svg +1 -0
- package/assets/img/comment/heart_1.svg +1 -0
- package/assets/img/comment/heart_2.svg +1 -0
- package/assets/img/comment/hide.svg +1 -0
- package/assets/img/common/add.svg +1 -0
- package/assets/img/common/android.svg +1 -0
- package/assets/img/common/bell.svg +1 -0
- package/assets/img/common/bilibili-black.svg +1 -0
- package/assets/img/common/bilibili.svg +1 -0
- package/assets/img/common/check.svg +1 -0
- package/assets/img/common/coin.svg +1 -0
- package/assets/img/common/coupon.svg +56 -0
- package/assets/img/common/douyin.svg +1 -0
- package/assets/img/common/edit.svg +1 -0
- package/assets/img/common/followus.svg +18 -0
- package/assets/img/common/gift.svg +1 -0
- package/assets/img/common/harmony.svg +1 -0
- package/assets/img/common/ios.svg +1 -0
- package/assets/img/common/jx3-origin.svg +15 -0
- package/assets/img/common/jx3-www.svg +9 -0
- package/assets/img/common/lang.svg +6 -0
- package/assets/img/common/logo.svg +5 -0
- package/assets/img/common/manage.svg +1 -0
- package/assets/img/common/miniprogram.jpg +0 -0
- package/assets/img/common/miniprogram.svg +1 -0
- package/assets/img/common/mp.jpg +0 -0
- package/assets/img/common/msg.svg +1 -0
- package/assets/img/common/news.svg +20 -0
- package/assets/img/common/qqbot.svg +7 -0
- package/assets/img/common/qrcode.svg +1 -0
- package/assets/img/common/search-key-slash.svg +5 -0
- package/assets/img/common/send.svg +56 -0
- package/assets/img/common/setting.svg +1 -0
- package/assets/img/common/vip.svg +1 -0
- package/assets/img/common/wechat.svg +48 -0
- package/assets/img/common/weibo.svg +70 -0
- package/assets/img/editor/buff.svg +1 -0
- package/assets/img/editor/file.svg +51 -0
- package/assets/img/editor/icons.svg +15 -0
- package/assets/img/editor/item.svg +46 -0
- package/assets/img/editor/jx3.svg +11 -0
- package/assets/img/editor/jx3box.svg +5 -0
- package/assets/img/editor/skill.svg +53 -0
- package/assets/img/editor/view.svg +1 -0
- package/assets/img/footer/android.svg +1 -0
- package/assets/img/footer/china.svg +1 -0
- package/assets/img/footer/harmony.svg +1 -0
- package/assets/img/footer/ios.svg +1 -0
- package/assets/img/footer/logo.svg +5 -0
- package/assets/img/footer/miniprogram.svg +1 -0
- package/assets/img/footer/qqbot.svg +7 -0
- package/assets/img/header/add.svg +1 -0
- package/assets/img/header/bell.svg +1 -0
- package/assets/img/header/check.svg +1 -0
- package/assets/img/header/coin.svg +1 -0
- package/assets/img/header/edit.svg +1 -0
- package/assets/img/header/gift.svg +1 -0
- package/assets/img/header/logo.svg +5 -0
- package/assets/img/header/manage.svg +1 -0
- package/assets/img/header/msg.svg +1 -0
- package/assets/img/header/search-key-slash.svg +5 -0
- package/assets/img/header/send.svg +56 -0
- package/assets/img/header/setting.svg +1 -0
- package/assets/img/header/translator.svg +1 -0
- package/assets/img/header/vip.svg +1 -0
- package/assets/img/leftsidebar/arrow.svg +64 -0
- package/assets/img/leftsidebar/close.svg +49 -0
- package/assets/img/leftsidebar/fans.svg +1 -0
- package/assets/img/leftsidebar/medal.svg +1 -0
- package/assets/img/leftsidebar/more.svg +50 -0
- package/assets/img/leftsidebar/open.svg +51 -0
- package/assets/img/leftsidebar/post.svg +46 -0
- package/assets/img/leftsidebar/team.svg +1 -0
- package/assets/img/leftsidebar/united.svg +1 -0
- package/assets/img/list/post.svg +1 -0
- package/assets/img/mobile/miniprogram.jpg +0 -0
- package/assets/img/mobile/mp.jpg +0 -0
- package/assets/img/npc/attack.svg +69 -0
- package/assets/img/npc/buff.svg +20 -0
- package/assets/img/npc/energy.svg +1 -0
- package/assets/img/npc/miss.svg +1 -0
- package/assets/img/npc/npc.svg +1 -0
- package/assets/img/npc/radar.svg +45 -0
- package/assets/img/npc/shield.svg +1 -0
- package/assets/img/npc/sight.svg +1 -0
- package/assets/img/npc/skull.svg +15 -0
- package/assets/img/npc/target.svg +55 -0
- package/assets/img/price/jin.png +0 -0
- package/assets/img/price/tong.png +0 -0
- package/assets/img/price/yin.png +0 -0
- package/assets/img/price/zhuan.png +0 -0
- package/assets/img/rightsidebar/ac.svg +1 -0
- package/assets/img/rightsidebar/github.svg +1 -0
- package/assets/img/rightsidebar/repo.svg +1 -0
- package/assets/img/rightsidebar/topic_bg.svg +1 -0
- package/assets/img/rightsidebar/topic_bg_bps.svg +113 -0
- package/assets/img/single/author.svg +1 -0
- package/assets/img/single/directory-header.svg +1 -0
- package/assets/img/single/lock.svg +1 -0
- package/assets/img/single/modate.svg +24 -0
- package/assets/img/single/podate.svg +23 -0
- package/assets/img/single/ticket.svg +1 -0
- package/assets/img/suspend/ArrowsLeftRight.svg +1 -0
- package/assets/img/suspend/circle.svg +7 -0
- package/assets/img/suspend/collect.svg +1 -0
- package/assets/img/suspend/collect_slash.svg +1 -0
- package/assets/img/suspend/collect_slash_touchbar.svg +1 -0
- package/assets/img/suspend/collect_slash_touchbar_100.svg +1 -0
- package/assets/img/suspend/collect_touchbar.svg +1 -0
- package/assets/img/suspend/collect_touchbar_100.svg +1 -0
- package/assets/img/suspend/lafter_touchbar.svg +1 -0
- package/assets/img/suspend/later-on.svg +1 -0
- package/assets/img/suspend/line.svg +3 -0
- package/assets/img/suspend/more.svg +1 -0
- package/assets/img/suspend/pin_slash_24.svg +1 -0
- package/assets/img/suspend/pin_slash_touchbar.svg +1 -0
- package/assets/img/suspend/pin_slash_touchbar_24.svg +1 -0
- package/assets/img/suspend/pin_slash_touchbar_40.svg +1 -0
- package/assets/img/suspend/pin_touchbar.svg +1 -0
- package/assets/img/suspend/pin_touchbar_100.svg +1 -0
- package/assets/img/suspend/pin_touchbar_24.svg +1 -0
- package/assets/img/suspend/report_100.svg +1 -0
- package/assets/img/suspend/rss_touchbar.svg +1 -0
- package/assets/img/suspend/rss_touchbar_100.svg +1 -0
- package/assets/img/suspend/search.svg +3 -0
- package/assets/img/suspend/search_touchbar.svg +1 -0
- package/assets/img/widget/admin_gift.svg +10 -0
- package/assets/img/widget/gift.svg +1 -0
- package/assets/img/widget/heart.svg +17 -0
- package/assets/img/widget/heart1.svg +1 -0
- package/assets/img/widget/heart2.svg +11 -0
- package/assets/img/widget/heart3.svg +37 -0
- package/assets/img/widget/like.svg +1 -0
- package/assets/img/widget/like2.svg +1 -0
- package/assets/img/widget/like3.svg +14 -0
- package/assets/img/widget/like4.png +0 -0
- package/assets/img/widget/like4ing.gif +0 -0
- package/assets/img/widget/qq.svg +1 -0
- package/assets/img/widget/qr-code.svg +1 -0
- package/assets/img/widget/qzone.svg +1 -0
- package/assets/img/widget/records.svg +1 -0
- package/assets/img/widget/share-link.png +0 -0
- package/assets/img/widget/share.svg +13 -0
- package/assets/img/widget/share2.svg +19 -0
- package/assets/img/widget/star.svg +9 -0
- package/assets/img/widget/tieba.svg +1 -0
- package/assets/img/widget/unstar.svg +21 -0
- package/assets/img/widget/web_heart_animation.png +0 -0
- package/assets/img/widget/weibo.svg +1 -0
- package/assets/img/widget/weixin.svg +1 -0
- package/assets/js/a.js +46 -0
- package/assets/js/app.js +7 -0
- package/assets/js/code.js +13 -0
- package/assets/js/combo.js +40 -0
- package/assets/js/directory.js +114 -0
- package/assets/js/filter2.js +186 -0
- package/assets/js/fold.js +11 -0
- package/assets/js/gallery.js +14 -0
- package/assets/js/hljs_languages.js +177 -0
- package/assets/js/iframe.js +38 -0
- package/assets/js/img.js +23 -0
- package/assets/js/item/attribute_percent.js +88 -0
- package/assets/js/item/bind.js +18 -0
- package/assets/js/item/border.js +19 -0
- package/assets/js/item/border_quest.js +12 -0
- package/assets/js/item/color.js +25 -0
- package/assets/js/item/hljs_languages.js +177 -0
- package/assets/js/item/icon_url.js +15 -0
- package/assets/js/item/second_format.js +19 -0
- package/assets/js/jx3_element.js +73 -0
- package/assets/js/katex.js +181 -0
- package/assets/js/macro.js +16 -0
- package/assets/js/nextpage.js +4 -0
- package/assets/js/pswp.js +67 -0
- package/assets/js/pswp_template.js +66 -0
- package/assets/js/pz_iframe.js +30 -0
- package/assets/js/qixue.js +28 -0
- package/assets/js/renderImgPreview.js +18 -0
- package/assets/js/script.js +6 -0
- package/assets/js/stat.js +107 -0
- package/assets/js/talent2.js +21 -0
- package/assets/js/tex-mml-chtml.js +36310 -0
- package/assets/js/voice.js +238 -0
- package/assets/js/xss.js +130 -0
- package/babel.config.js +3 -0
- package/docs/README.md +78 -0
- package/i18n/index.js +134 -0
- package/i18n/messages/en-US.js +124 -0
- package/i18n/messages/vi.js +124 -0
- package/i18n/messages/zh-CN.js +124 -0
- package/i18n/messages/zh-TW.js +124 -0
- package/i18n/mixin.js +23 -0
- package/index.js +73 -0
- package/package.json +97 -0
- package/postcss.config.js +3 -0
- package/service/admin.js +20 -0
- package/service/author.js +94 -0
- package/service/breadcrumb.js +13 -0
- package/service/cms.js +137 -0
- package/service/comment.js +187 -0
- package/service/database.js +115 -0
- package/service/design.js +13 -0
- package/service/enum/CollectionPublic.js +13 -0
- package/service/enum/EquipPosition.js +48 -0
- package/service/enum/EquipType.js +33 -0
- package/service/fav.js +27 -0
- package/service/follow.js +55 -0
- package/service/github.js +15 -0
- package/service/header.js +42 -0
- package/service/item.js +22 -0
- package/service/resource.js +31 -0
- package/service/suspend.js +81 -0
- package/service/thx.js +60 -0
- package/src/App.vue +212 -0
- package/src/Bottom.vue +23 -0
- package/src/Box.vue +149 -0
- package/src/Breadcrumb.vue +141 -0
- package/src/CommonFooter.vue +69 -0
- package/src/CommonHeader.vue +270 -0
- package/src/Footer.vue +45 -0
- package/src/LeftSideToggle.vue +64 -0
- package/src/LeftSidebar.vue +123 -0
- package/src/Main.vue +48 -0
- package/src/RightSidebar.vue +61 -0
- package/src/SuspendCommon.vue +705 -0
- package/src/author/AuthorFans.vue +170 -0
- package/src/author/AuthorFollow.vue +205 -0
- package/src/author/AuthorGift.vue +286 -0
- package/src/author/AuthorHonor.vue +128 -0
- package/src/author/AuthorInfo.vue +245 -0
- package/src/author/AuthorLink.vue +113 -0
- package/src/author/AuthorMedals.vue +87 -0
- package/src/author/AuthorMsg.vue +25 -0
- package/src/author/AuthorPosts.vue +114 -0
- package/src/author/AuthorRss.vue +160 -0
- package/src/author/AuthorTeams.vue +106 -0
- package/src/author/Avatar.vue +168 -0
- package/src/author/UserPop.vue +198 -0
- package/src/bread/Admin.vue +400 -0
- package/src/bread/AdminButton.vue +31 -0
- package/src/bread/AdminDirectMessage.vue +73 -0
- package/src/bread/AdminDrop.vue +155 -0
- package/src/bread/Crumb.vue +27 -0
- package/src/bread/DesignTask.vue +194 -0
- package/src/comment/Avatar.vue +124 -0
- package/src/comment/CommentContent.vue +486 -0
- package/src/comment/CommentContentSimple.vue +240 -0
- package/src/comment/CommentInputForm.vue +182 -0
- package/src/comment/CommentWithReply.vue +261 -0
- package/src/comment/QuickReply.vue +64 -0
- package/src/comment/ReplyForReply.vue +127 -0
- package/src/comment/ReplyItem.vue +92 -0
- package/src/comment/ReplyList.vue +126 -0
- package/src/comment/Upload.vue +108 -0
- package/src/editor/Article.vue +230 -0
- package/src/editor/BoxResource.vue +441 -0
- package/src/editor/Resource.vue +623 -0
- package/src/editor/Tinymce.vue +204 -0
- package/src/editor/Upload.vue +277 -0
- package/src/editor/UploadAlum.vue +176 -0
- package/src/editor/UploadBanner.vue +156 -0
- package/src/editor/components/Author.vue +322 -0
- package/src/editor/components/Avatar.vue +95 -0
- package/src/editor/components/Buff.vue +80 -0
- package/src/editor/components/Combo.vue +259 -0
- package/src/editor/components/Equip.vue +299 -0
- package/src/editor/components/GameText.vue +242 -0
- package/src/editor/components/Item.vue +325 -0
- package/src/editor/components/ItemSimple.vue +134 -0
- package/src/editor/components/Medal.vue +43 -0
- package/src/editor/components/Npc.vue +215 -0
- package/src/editor/components/PostAuthor.vue +102 -0
- package/src/editor/components/Skill.vue +71 -0
- package/src/filters/clientBy.vue +96 -0
- package/src/filters/markBy.vue +177 -0
- package/src/filters/menuBy.vue +63 -0
- package/src/filters/orderBy.vue +170 -0
- package/src/filters/tagBy.vue +171 -0
- package/src/filters/topicBy.vue +151 -0
- package/src/filters/versionBy.vue +49 -0
- package/src/filters/zlpBy.vue +70 -0
- package/src/footer/copyright.vue +59 -0
- package/src/footer/links.vue +79 -0
- package/src/footer/official.vue +142 -0
- package/src/footer/resource.vue +146 -0
- package/src/header/alternate.vue +299 -0
- package/src/header/asset.vue +180 -0
- package/src/header/box.vue +161 -0
- package/src/header/box2.vue +479 -0
- package/src/header/bus.js +9 -0
- package/src/header/client.vue +183 -0
- package/src/header/lang.vue +136 -0
- package/src/header/logo.vue +95 -0
- package/src/header/manage.vue +200 -0
- package/src/header/message.vue +93 -0
- package/src/header/nav.vue +356 -0
- package/src/header/publish.vue +38 -0
- package/src/header/search.vue +120 -0
- package/src/header/search_map.json +3 -0
- package/src/header/shop.vue +121 -0
- package/src/header/user.vue +250 -0
- package/src/header/userInfo.vue +621 -0
- package/src/header/utils.js +126 -0
- package/src/header/vip.vue +120 -0
- package/src/interact/BoxcoinAdmin.vue +185 -0
- package/src/interact/BoxcoinRecords.vue +153 -0
- package/src/interact/BoxcoinUser.vue +194 -0
- package/src/interact/Contributors.vue +111 -0
- package/src/interact/Fav.vue +95 -0
- package/src/interact/Like.vue +61 -0
- package/src/interact/Rss.vue +163 -0
- package/src/interact/Share.vue +166 -0
- package/src/interact/WatchLater.vue +108 -0
- package/src/main.js +72 -0
- package/src/single/Author.vue +72 -0
- package/src/single/Collection.vue +176 -0
- package/src/single/Comment.vue +454 -0
- package/src/single/Creators.vue +214 -0
- package/src/single/PostDirectory.vue +147 -0
- package/src/single/PostHeader.vue +397 -0
- package/src/single/PostTopic.vue +127 -0
- package/src/single/SimpleThx.vue +217 -0
- package/src/single/Thx.vue +260 -0
- package/src/single/cms-single.vue +235 -0
- package/tailwind.config.js +13 -0
- package/utils/bus.js +5 -0
- package/utils/emotion.js +21 -0
- package/utils/index.js +36 -0
- package/vue.config.js +158 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import $ from "jquery";
|
|
2
|
+
import { showAvatar } from "@jx3box/jx3box-common/js/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 渲染音频组件
|
|
6
|
+
* 将 e-audio 转换为实际的音频播放器
|
|
7
|
+
* @param {string} selector - 选择器,默认为 ".w-audio, .e-audio"
|
|
8
|
+
*/
|
|
9
|
+
function renderVoice(selector = ".w-audio, .e-audio") {
|
|
10
|
+
try {
|
|
11
|
+
$(selector).each(function (i, ele) {
|
|
12
|
+
const $audio = $(this);
|
|
13
|
+
const content = $audio.text().trim();
|
|
14
|
+
|
|
15
|
+
// 解析内容:name:xxx;author:xxx;user_id:xxx;src:xxx
|
|
16
|
+
const params = {};
|
|
17
|
+
content.split(";").forEach((item) => {
|
|
18
|
+
const [key, value] = item.split("|");
|
|
19
|
+
if (key && value !== undefined) {
|
|
20
|
+
params[key.trim()] = value.trim();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// 提取参数
|
|
25
|
+
const { name = "未命名音频", author = "未知", user_id = "", src = "" } = params;
|
|
26
|
+
|
|
27
|
+
if (!src) {
|
|
28
|
+
console.warn("音频源地址为空", content);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 生成唯一ID
|
|
33
|
+
const playerId = `audio-player-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
34
|
+
|
|
35
|
+
// 获取用户头像,如果没有则使用默认图片
|
|
36
|
+
const avatar = showAvatar(params.avatar, 240);
|
|
37
|
+
|
|
38
|
+
// 渲染音频播放器 - 使用项目中定义的样式结构
|
|
39
|
+
const html = `
|
|
40
|
+
<div class="w-audio-player" id="${playerId}" data-user-id="${user_id}">
|
|
41
|
+
<div class="m-item">
|
|
42
|
+
<div class="u-title">
|
|
43
|
+
<div class="clip">
|
|
44
|
+
<div class="marquee-wrapper">
|
|
45
|
+
<span class="marquee-text">${name}</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="u-author">
|
|
50
|
+
练习生:<a href="https://www.jx3box.com/author/${user_id}" target="_blank">${author}</a>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div class="m-record">
|
|
54
|
+
<img class="u-needle" src="https://cdn.jx3box.com/design/event/jx3cxk/web/item/needle.svg" />
|
|
55
|
+
<a href="https://www.jx3box.com/author/${user_id}" target="_blank" class="u-record">
|
|
56
|
+
<img class="u-avatar" src="${avatar}" />
|
|
57
|
+
</a>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div class="m-progress">
|
|
61
|
+
<div class="u-progress-bar">
|
|
62
|
+
<div class="u-progress-fill"></div>
|
|
63
|
+
<div class="u-progress-handle"></div>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div class="m-play">
|
|
68
|
+
<div class="u-play-button">
|
|
69
|
+
<img class="u-icon" src="https://cdn.jx3box.com/design/event/jx3cxk/web/item/left.svg" />
|
|
70
|
+
<img class="u-icon u-play" src="https://cdn.jx3box.com/design/event/jx3cxk/web/item/play.svg" data-play-icon="https://cdn.jx3box.com/design/event/jx3cxk/web/item/play.svg" data-stop-icon="https://cdn.jx3box.com/design/event/jx3cxk/web/item/stop.svg" />
|
|
71
|
+
<img class="u-icon" src="https://cdn.jx3box.com/design/event/jx3cxk/web/item/right.svg" />
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<audio preload="metadata" src="${src}"></audio>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
$audio.replaceWith(html);
|
|
80
|
+
|
|
81
|
+
// 初始化播放器功能
|
|
82
|
+
initAudioPlayer(playerId);
|
|
83
|
+
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.error("音频渲染错误:", e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 初始化音频播放器功能
|
|
91
|
+
* @param {string} playerId - 播放器ID
|
|
92
|
+
*/
|
|
93
|
+
function initAudioPlayer(playerId) {
|
|
94
|
+
const $player = $(`#${playerId}`);
|
|
95
|
+
const audio = $player.find("audio")[0];
|
|
96
|
+
const $playBtn = $player.find(".u-play");
|
|
97
|
+
const $needle = $player.find(".u-needle");
|
|
98
|
+
const $avatar = $player.find(".u-avatar");
|
|
99
|
+
const $progressBar = $player.find(".u-progress-bar");
|
|
100
|
+
const $progressFill = $player.find(".u-progress-fill");
|
|
101
|
+
const $progressHandle = $player.find(".u-progress-handle");
|
|
102
|
+
|
|
103
|
+
if (!audio) {
|
|
104
|
+
console.warn("音频元素未找到", playerId);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let isPlaying = false;
|
|
109
|
+
let isDragging = false;
|
|
110
|
+
|
|
111
|
+
// 播放/暂停切换
|
|
112
|
+
$playBtn.on("click", function () {
|
|
113
|
+
const playIcon = $(this).data("play-icon");
|
|
114
|
+
const stopIcon = $(this).data("stop-icon");
|
|
115
|
+
|
|
116
|
+
if (isPlaying) {
|
|
117
|
+
audio.pause();
|
|
118
|
+
$(this).attr("src", playIcon);
|
|
119
|
+
$needle.removeClass("isPlaying");
|
|
120
|
+
$avatar.addClass("isPaused");
|
|
121
|
+
$player.removeClass("play");
|
|
122
|
+
} else {
|
|
123
|
+
audio.play();
|
|
124
|
+
$(this).attr("src", stopIcon);
|
|
125
|
+
$needle.addClass("isPlaying");
|
|
126
|
+
$avatar.removeClass("isPaused").addClass("isRotate");
|
|
127
|
+
$player.addClass("play");
|
|
128
|
+
}
|
|
129
|
+
isPlaying = !isPlaying;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// 音频播放状态改变
|
|
133
|
+
audio.addEventListener("play", function () {
|
|
134
|
+
isPlaying = true;
|
|
135
|
+
$playBtn.attr("src", $playBtn.data("stop-icon"));
|
|
136
|
+
$needle.addClass("isPlaying");
|
|
137
|
+
$avatar.removeClass("isPaused").addClass("isRotate");
|
|
138
|
+
$player.addClass("play");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
audio.addEventListener("pause", function () {
|
|
142
|
+
isPlaying = false;
|
|
143
|
+
$playBtn.attr("src", $playBtn.data("play-icon"));
|
|
144
|
+
$needle.removeClass("isPlaying");
|
|
145
|
+
$avatar.addClass("isPaused");
|
|
146
|
+
$player.removeClass("play");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// 更新进度条
|
|
150
|
+
audio.addEventListener("timeupdate", function () {
|
|
151
|
+
if (!isDragging && audio.duration) {
|
|
152
|
+
const progress = (audio.currentTime / audio.duration) * 100;
|
|
153
|
+
$progressFill.css("width", progress + "%");
|
|
154
|
+
$progressHandle.css("left", progress + "%");
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// 进度条拖拽和点击
|
|
159
|
+
function updateProgress(e) {
|
|
160
|
+
const rect = $progressBar[0].getBoundingClientRect();
|
|
161
|
+
const offsetX = e.clientX - rect.left;
|
|
162
|
+
const progress = Math.max(0, Math.min(1, offsetX / rect.width));
|
|
163
|
+
const newTime = progress * audio.duration;
|
|
164
|
+
|
|
165
|
+
$progressFill.css("width", progress * 100 + "%");
|
|
166
|
+
$progressHandle.css("left", progress * 100 + "%");
|
|
167
|
+
|
|
168
|
+
if (isDragging || e.type === "click") {
|
|
169
|
+
audio.currentTime = newTime;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
$progressBar.on("mousedown", function (e) {
|
|
174
|
+
isDragging = true;
|
|
175
|
+
updateProgress(e);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
$(document).on("mousemove", function (e) {
|
|
179
|
+
if (isDragging) {
|
|
180
|
+
updateProgress(e);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
$(document).on("mouseup", function (e) {
|
|
185
|
+
if (isDragging) {
|
|
186
|
+
updateProgress(e);
|
|
187
|
+
isDragging = false;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
$progressBar.on("click", function (e) {
|
|
192
|
+
updateProgress(e);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// 音频结束
|
|
196
|
+
audio.addEventListener("ended", function () {
|
|
197
|
+
isPlaying = false;
|
|
198
|
+
audio.currentTime = 0;
|
|
199
|
+
$playBtn.attr("src", $playBtn.data("play-icon"));
|
|
200
|
+
$needle.removeClass("isPlaying");
|
|
201
|
+
$avatar.removeClass("isRotate isPaused");
|
|
202
|
+
$player.removeClass("play");
|
|
203
|
+
$progressFill.css("width", "0%");
|
|
204
|
+
$progressHandle.css("left", "0%");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// 检查标题是否需要滚动
|
|
208
|
+
checkTextWidth($player);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 检查文本宽度,决定是否需要滚动动画
|
|
213
|
+
* @param {jQuery} $player - 播放器元素
|
|
214
|
+
*/
|
|
215
|
+
function checkTextWidth($player) {
|
|
216
|
+
const $wrapper = $player.find(".marquee-wrapper");
|
|
217
|
+
const $text = $player.find(".marquee-text");
|
|
218
|
+
|
|
219
|
+
if (!$text.length || !$wrapper.length) return;
|
|
220
|
+
|
|
221
|
+
const textWidth = $text[0].offsetWidth;
|
|
222
|
+
const containerWidth = $wrapper.parent()[0].clientWidth;
|
|
223
|
+
|
|
224
|
+
if (textWidth > containerWidth) {
|
|
225
|
+
$wrapper.addClass("marquee-active");
|
|
226
|
+
// 添加复制的文本用于无缝滚动
|
|
227
|
+
const copyText = $text.clone().addClass("copy");
|
|
228
|
+
$wrapper.append(copyText);
|
|
229
|
+
|
|
230
|
+
// 计算动画时长
|
|
231
|
+
const totalWidth = textWidth * 2 + 180; // 180px 是间距
|
|
232
|
+
const duration = totalWidth / 30; // 30px/s
|
|
233
|
+
$wrapper.css("animation-duration", `${duration}s`);
|
|
234
|
+
$wrapper.addClass("marquee-animate");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default renderVoice;
|
package/assets/js/xss.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import sanitizeHtml from "sanitize-html";
|
|
2
|
+
import * as cheerio from "cheerio";
|
|
3
|
+
import postcss from "postcss";
|
|
4
|
+
import safeParser from "postcss-safe-parser";
|
|
5
|
+
|
|
6
|
+
const FORBID = new Set(["script", "object", "embed", "applet", "base", "meta", "link"]);
|
|
7
|
+
|
|
8
|
+
const EXTRA_TAGS = [
|
|
9
|
+
"img",
|
|
10
|
+
"h1", "h2", "h3", "h4", "h5", "h6",
|
|
11
|
+
"table", "thead", "tbody", "tr", "th", "td",
|
|
12
|
+
"blockquote", "pre", "code", "hr",
|
|
13
|
+
"video", "source",
|
|
14
|
+
"iframe", "style",
|
|
15
|
+
"colgroup", "col",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
// 必须顶层的 at-rule(你说不需要动画,但 keyframes 也可能被编辑器/作者写进来,留着更稳)
|
|
19
|
+
const TOP_LEVEL_AT = new Set(["keyframes", "-webkit-keyframes", "font-face"]);
|
|
20
|
+
|
|
21
|
+
function stripDangerousCss(css) {
|
|
22
|
+
if (!css) return css;
|
|
23
|
+
return css
|
|
24
|
+
.replace(/@import\s+[^;]+;?/gi, "")
|
|
25
|
+
.replace(/url\s*\(\s*[^)]+\s*\)/gi, "")
|
|
26
|
+
.replace(/expression\s*\([^)]*\)/gi, "");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 暴力把 style 内容 nest 到 .c-article
|
|
30
|
+
function nestCssBrutally(cssText, scope = ".c-article") {
|
|
31
|
+
let css = stripDangerousCss(cssText || "");
|
|
32
|
+
if (!css.trim()) return css;
|
|
33
|
+
|
|
34
|
+
const root = postcss.parse(css, { parser: safeParser });
|
|
35
|
+
|
|
36
|
+
const top = [];
|
|
37
|
+
const rest = [];
|
|
38
|
+
|
|
39
|
+
(root.nodes || []).forEach((node) => {
|
|
40
|
+
if (node.type === "atrule" && TOP_LEVEL_AT.has(String(node.name).toLowerCase())) {
|
|
41
|
+
top.push(node.toString());
|
|
42
|
+
} else {
|
|
43
|
+
rest.push(node.toString());
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const restCss = rest.join("\n").trim();
|
|
48
|
+
if (!restCss) return top.join("\n").trim();
|
|
49
|
+
|
|
50
|
+
return `${top.join("\n")}\n${scope}{\n${restCss}\n}`.trim();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function nestAllStyleTags(html, scope = ".c-article") {
|
|
54
|
+
const $ = cheerio.load(html, { decodeEntities: false });
|
|
55
|
+
|
|
56
|
+
$("style").each((_, el) => {
|
|
57
|
+
const oldCss = $(el).html() || "";
|
|
58
|
+
const newCss = nestCssBrutally(oldCss, scope);
|
|
59
|
+
$(el).text(newCss);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return $.html();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default function sanitizeRichText(html) {
|
|
66
|
+
if (!html) return html;
|
|
67
|
+
|
|
68
|
+
// 先把 <style> 内容暴力 nest 到 .c-article
|
|
69
|
+
html = nestAllStyleTags(html, ".c-article");
|
|
70
|
+
|
|
71
|
+
const allowedTags = sanitizeHtml.defaults.allowedTags
|
|
72
|
+
.concat(EXTRA_TAGS)
|
|
73
|
+
.filter((t, i, arr) => arr.indexOf(t) === i)
|
|
74
|
+
.filter((t) => !FORBID.has(t));
|
|
75
|
+
|
|
76
|
+
return sanitizeHtml(html, {
|
|
77
|
+
disallowedTagsMode: "discard",
|
|
78
|
+
allowedTags,
|
|
79
|
+
|
|
80
|
+
allowedAttributes: {
|
|
81
|
+
"*": ["class", "style", "title", "id", "data-*"],
|
|
82
|
+
a: ["href", "target", "rel", "title", "class", "style"],
|
|
83
|
+
img: ["src", "alt", "title", "width", "height", "class", "style", "loading", "decoding"],
|
|
84
|
+
video: ["controls", "width", "height", "class", "style"],
|
|
85
|
+
source: ["src", "type"],
|
|
86
|
+
iframe: ["src", "width", "height", "frameborder", "scrolling", "allowfullscreen", "sandbox", "referrerpolicy", "class", "style"],
|
|
87
|
+
td: ["colspan", "rowspan", "align", "valign", "class", "style"],
|
|
88
|
+
th: ["colspan", "rowspan", "align", "valign", "class", "style"],
|
|
89
|
+
col: ["span", "width", "class", "style"],
|
|
90
|
+
style: ["type", "media"],
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
allowedSchemes: ["http", "https", "mailto", "tel"],
|
|
94
|
+
allowProtocolRelative: true,
|
|
95
|
+
allowedSchemesByTag: { img: ["http", "https", "data"], iframe: ["http", "https"] },
|
|
96
|
+
|
|
97
|
+
transformTags: {
|
|
98
|
+
"*": (tagName, attribs) => {
|
|
99
|
+
const out = { ...attribs };
|
|
100
|
+
|
|
101
|
+
// 移除 on*
|
|
102
|
+
for (const k of Object.keys(out)) if (/^on/i.test(k)) delete out[k];
|
|
103
|
+
|
|
104
|
+
// style 属性:禁 @import / url(
|
|
105
|
+
if (typeof out.style === "string" && out.style) {
|
|
106
|
+
let s = out.style;
|
|
107
|
+
s = s.replace(/@import\s+[^;]+;?/gi, "");
|
|
108
|
+
s = s.replace(/url\s*\(\s*[^)]+\s*\)/gi, "");
|
|
109
|
+
s = s.replace(/;;+/g, ";").trim();
|
|
110
|
+
if (!s) delete out.style;
|
|
111
|
+
else out.style = s;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 兜底禁 javascript:
|
|
115
|
+
for (const key of ["href", "src"]) {
|
|
116
|
+
if (out[key] && /^\s*javascript:/i.test(out[key])) out[key] = "";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 仅允许 data:image/*
|
|
120
|
+
if (tagName === "img" && typeof out.src === "string" && out.src.startsWith("data:")) {
|
|
121
|
+
if (!/^data:image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml);/i.test(out.src)) {
|
|
122
|
+
out.src = "";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return { tagName, attribs: out };
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
package/babel.config.js
ADDED
package/docs/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# jx3box-vue3-ui
|
|
2
|
+
|
|
3
|
+
这是一个基于 `vue-cli + webpack5 + vue3` 的公共组件库,供其它业务项目按需引入各种 `.vue` 组件模块(如公共头部等)。
|
|
4
|
+
|
|
5
|
+
## i18n(多语言)接入
|
|
6
|
+
|
|
7
|
+
本库内置 `vue-i18n@9` 的接入方式,并提供一个可选的 Vue 插件用于:
|
|
8
|
+
|
|
9
|
+
- 宿主项目已使用 `vue-i18n`:合并本库词条到宿主 i18n
|
|
10
|
+
- 宿主项目未使用 `vue-i18n`:由本库创建并安装 i18n(仅用于本库组件文案)
|
|
11
|
+
|
|
12
|
+
词条命名空间固定为:`jx3boxUi`(避免与业务方 key 冲突)。
|
|
13
|
+
|
|
14
|
+
### 1)宿主项目已使用 vue-i18n(推荐)
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { createApp } from "vue";
|
|
18
|
+
import { createI18n } from "vue-i18n";
|
|
19
|
+
import App from "./App.vue";
|
|
20
|
+
|
|
21
|
+
import { install, Jx3boxUiI18n } from "@jx3box/jx3box-vue3-ui";
|
|
22
|
+
|
|
23
|
+
const app = createApp(App);
|
|
24
|
+
|
|
25
|
+
const i18n = createI18n({
|
|
26
|
+
legacy: false,
|
|
27
|
+
globalInjection: true,
|
|
28
|
+
locale: "zh-CN",
|
|
29
|
+
fallbackLocale: "zh-CN",
|
|
30
|
+
messages: {
|
|
31
|
+
"zh-CN": {
|
|
32
|
+
// 业务自己的词条...
|
|
33
|
+
},
|
|
34
|
+
"en-US": {
|
|
35
|
+
// 业务自己的词条...
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
app.use(i18n);
|
|
41
|
+
app.use(Jx3boxUiI18n, { i18n }); // 合并本库词条
|
|
42
|
+
install(app); // 注册组件
|
|
43
|
+
|
|
44
|
+
app.mount("#app");
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2)宿主项目未使用 vue-i18n(快速接入)
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { createApp } from "vue";
|
|
51
|
+
import App from "./App.vue";
|
|
52
|
+
import { install, Jx3boxUiI18n } from "@jx3box/jx3box-vue3-ui";
|
|
53
|
+
|
|
54
|
+
const app = createApp(App);
|
|
55
|
+
|
|
56
|
+
app.use(Jx3boxUiI18n, { locale: "zh-CN" });
|
|
57
|
+
install(app);
|
|
58
|
+
|
|
59
|
+
app.mount("#app");
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3)覆盖/扩展本库词条
|
|
63
|
+
|
|
64
|
+
在宿主 i18n 中覆盖同名 key 即可(以 `jx3boxUi` 为根):
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
i18n.global.mergeLocaleMessage("en-US", {
|
|
68
|
+
jx3boxUi: {
|
|
69
|
+
header: {
|
|
70
|
+
vipCenter: "Membership",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 说明
|
|
77
|
+
|
|
78
|
+
- 目前优先对 `Header` 相关组件与少量通用提示文案做了 i18n 化;其它组件可按同样方式逐步迁移。
|
package/i18n/index.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { createI18n } from "vue-i18n";
|
|
2
|
+
|
|
3
|
+
import zhCN from "./messages/zh-CN";
|
|
4
|
+
import enUS from "./messages/en-US";
|
|
5
|
+
import zhTW from "./messages/zh-TW";
|
|
6
|
+
import vi from "./messages/vi";
|
|
7
|
+
|
|
8
|
+
const NAMESPACE = "jx3boxUi";
|
|
9
|
+
|
|
10
|
+
const rawMessages = {
|
|
11
|
+
"zh-CN": zhCN,
|
|
12
|
+
"en-US": enUS,
|
|
13
|
+
"zh-TW": zhTW,
|
|
14
|
+
vi,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function buildNamespacedMessages(messages) {
|
|
18
|
+
const out = {};
|
|
19
|
+
Object.entries(messages).forEach(([locale, message]) => {
|
|
20
|
+
out[locale] = {
|
|
21
|
+
[NAMESPACE]: message,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const namespacedMessages = buildNamespacedMessages(rawMessages);
|
|
28
|
+
|
|
29
|
+
let activeI18n = null;
|
|
30
|
+
|
|
31
|
+
export function setJx3boxUiI18n(i18n) {
|
|
32
|
+
activeI18n = i18n || null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getJx3boxUiI18n() {
|
|
36
|
+
return activeI18n;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getJx3boxUiMessages() {
|
|
40
|
+
return rawMessages;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function mergeJx3boxUiMessages(i18n) {
|
|
44
|
+
if (!i18n || !i18n.global || typeof i18n.global.mergeLocaleMessage !== "function") return;
|
|
45
|
+
|
|
46
|
+
Object.entries(namespacedMessages).forEach(([locale, message]) => {
|
|
47
|
+
i18n.global.mergeLocaleMessage(locale, message);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function createJx3boxUiI18n(options = {}) {
|
|
52
|
+
const {
|
|
53
|
+
locale = "zh-CN",
|
|
54
|
+
fallbackLocale = "zh-CN",
|
|
55
|
+
legacy = false,
|
|
56
|
+
globalInjection = true,
|
|
57
|
+
...rest
|
|
58
|
+
} = options;
|
|
59
|
+
|
|
60
|
+
const i18n = createI18n({
|
|
61
|
+
legacy,
|
|
62
|
+
globalInjection,
|
|
63
|
+
locale,
|
|
64
|
+
fallbackLocale,
|
|
65
|
+
messages: namespacedMessages,
|
|
66
|
+
...rest,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
setJx3boxUiI18n(i18n);
|
|
70
|
+
return i18n;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function tGlobal(key, values, fallback) {
|
|
74
|
+
try {
|
|
75
|
+
const i18n = getJx3boxUiI18n();
|
|
76
|
+
if (i18n && i18n.global && typeof i18n.global.t === "function") {
|
|
77
|
+
return i18n.global.t(key, values);
|
|
78
|
+
}
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// ignore
|
|
81
|
+
}
|
|
82
|
+
return fallback ?? key;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getJx3boxUiAvailableLocales() {
|
|
86
|
+
return Object.keys(rawMessages);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function setJx3boxUiLocale(locale) {
|
|
90
|
+
const i18n = getJx3boxUiI18n();
|
|
91
|
+
if (!i18n || !i18n.global) return false;
|
|
92
|
+
|
|
93
|
+
const global = i18n.global;
|
|
94
|
+
|
|
95
|
+
if (global.locale && typeof global.locale === "object" && "value" in global.locale) {
|
|
96
|
+
global.locale.value = locale;
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof global.locale === "string") {
|
|
101
|
+
global.locale = locale;
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (global.locale && typeof global.locale === "function") {
|
|
106
|
+
try {
|
|
107
|
+
global.locale(locale);
|
|
108
|
+
return true;
|
|
109
|
+
} catch (e) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Vue plugin:
|
|
118
|
+
// 1) 宿主已创建 i18n:传入 { i18n },我们只 merge 词条并记录全局引用
|
|
119
|
+
// 2) 宿主未使用 i18n:直接 app.use(Jx3boxUiI18n, { locale: "zh-CN" }) 即可
|
|
120
|
+
export const Jx3boxUiI18n = {
|
|
121
|
+
install(app, options = {}) {
|
|
122
|
+
const { i18n, ...rest } = options || {};
|
|
123
|
+
|
|
124
|
+
if (i18n) {
|
|
125
|
+
mergeJx3boxUiMessages(i18n);
|
|
126
|
+
setJx3boxUiI18n(i18n);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const created = createJx3boxUiI18n(rest);
|
|
131
|
+
app.use(created);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|