@nocobase/plugin-notification-in-app-message 1.4.0-beta.6 → 1.4.0-beta.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.
package/dist/client/index.js
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
(function(){"use strict";try{if(typeof document!="undefined"){var a=document.createElement("style");a.id="@nocobase/plugin-notification-in-app-message",a.appendChild(document.createTextNode(':root{--adm-radius-s: 4px;--adm-radius-m: 8px;--adm-radius-l: 12px;--adm-font-size-1: 9px;--adm-font-size-2: 10px;--adm-font-size-3: 11px;--adm-font-size-4: 12px;--adm-font-size-5: 13px;--adm-font-size-6: 14px;--adm-font-size-7: 15px;--adm-font-size-8: 16px;--adm-font-size-9: 17px;--adm-font-size-10: 18px;--adm-color-primary: #1677ff;--adm-color-success: #00b578;--adm-color-warning: #ff8f1f;--adm-color-danger: #ff3141;--adm-color-yellow: #ff9f18;--adm-color-orange: #ff6430;--adm-color-wathet: #e7f1ff;--adm-color-text: #333333;--adm-color-text-secondary: #666666;--adm-color-weak: #999999;--adm-color-light: #cccccc;--adm-color-border: #eeeeee;--adm-color-background: #ffffff;--adm-color-highlight: var(--adm-color-danger);--adm-color-white: #ffffff;--adm-color-box: #f5f5f5;--adm-color-text-light-solid: var(--adm-color-white);--adm-color-text-dark-solid: #000000;--adm-color-fill-content: var(--adm-color-box);--adm-font-size-main: var(--adm-font-size-5);--adm-font-family: -apple-system, blinkmacsystemfont, "Helvetica Neue", helvetica, segoe ui, arial, roboto, "PingFang SC", "miui", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;--adm-border-color: var(--adm-color-border)}html[data-prefers-color-scheme=dark]{--adm-color-primary: #3086ff;--adm-color-success: #34b368;--adm-color-warning: #ffa930;--adm-color-danger: #ff4a58;--adm-color-yellow: #ffa930;--adm-color-orange: #e65a2b;--adm-color-wathet: #0d2543;--adm-color-text: #e6e6e6;--adm-color-text-secondary: #b3b3b3;--adm-color-weak: #808080;--adm-color-light: #4d4d4d;--adm-color-border: #2b2b2b;--adm-color-box: #0a0a0a;--adm-color-background: #1a1a1a;--adm-color-background-body: var(--adm-color-background);--adm-border-color: var(--adm-color-border)}:root{-webkit-tap-highlight-color:rgba(0,0,0,0)}html{background-color:var(--adm-color-background-body)}body{color:var(--adm-color-text);font-size:var(--adm-font-size-main);font-family:var(--adm-font-family)}a,button{cursor:pointer}a{color:var(--adm-color-primary);transition:opacity ease-in-out .2s}a:active{opacity:.8}.adm-plain-anchor{color:unset;transition:none}.adm-plain-anchor:active{opacity:unset}body.adm-overflow-hidden{overflow:hidden!important}div.adm-px-tester{--size: 1;height:calc(var(--size) / 2 * 2px);width:0;position:fixed;left:-100vw;top:-100vh;-webkit-user-select:none;user-select:none;pointer-events:none}.adm-mask{--z-index: var(--adm-mask-z-index, 1000);position:fixed;top:0;left:0;z-index:var(--z-index);display:block;width:100%;height:100%}.adm-mask-aria-button{position:absolute;top:0;left:0;z-index:0;width:100%;height:100%;pointer-events:none}.adm-mask-content{z-index:1}.adm-auto-center{display:flex;justify-content:center}.adm-auto-center-content{flex:0 1 auto}.adm-badge-wrapper{display:inline-block;position:relative}.adm-badge{display:inline-flex;vertical-align:middle;box-sizing:content-box;border-radius:100px;background-color:var(--color);--right: 0;--top: 0;--color: var(--adm-badge-color, var(--adm-color-highlight))}.adm-badge-content{color:var(--adm-color-text-light-solid);box-sizing:border-box;min-width:8px;padding:1px 4px;font-size:var(--adm-font-size-1);line-height:12px;white-space:nowrap;font-weight:400;text-align:center}.adm-badge-fixed{position:absolute;right:var(--right);top:var(--top);transform:translate(50%,-50%)}.adm-badge-dot{min-width:10px;width:10px;height:10px;border-radius:5px}.adm-badge-bordered{border:solid 1px var(--adm-color-text-light-solid)}.adm-dot-loading{display:inline-block}.adm-spin-loading{--color: var(--adm-color-weak);--size: 32px;width:var(--size);height:var(--size)}.adm-spin-loading-svg{width:100%;height:100%;animation:adm-spin-loading-rotate .8s infinite linear}.adm-spin-loading-svg>.adm-spin-loading-fill{stroke:var(--color)}@keyframes adm-spin-loading-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.adm-tabs{--title-font-size: var(--adm-font-size-9);--content-padding: 12px;--active-line-height: 2px;--active-line-border-radius: var(--active-line-height);--active-line-color: var(--adm-color-primary);--active-title-color: var(--adm-color-primary);position:relative;min-width:0}.adm-tabs-header{position:relative;border-bottom:solid 1px var(--adm-color-border)}.adm-tabs-tab-list{display:flex;flex-wrap:nowrap;justify-content:flex-start;align-items:center;position:relative;overflow-x:scroll;scrollbar-width:none}.adm-tabs-tab-list::-webkit-scrollbar{display:none}.adm-tabs-tab-wrapper{padding:0 12px}.adm-tabs-tab-wrapper-stretch{flex:auto}.adm-tabs-tab{white-space:nowrap;padding:8px 0 10px;width:-webkit-min-content;width:min-content;margin:0 auto;font-size:var(--title-font-size);position:relative;cursor:pointer}.adm-tabs-tab-active{color:var(--active-title-color)}.adm-tabs-tab-disabled{opacity:.5;cursor:not-allowed}.adm-tabs-tab-line{position:absolute;bottom:0;height:var(--active-line-height);background:var(--active-line-color);border-radius:var(--active-line-border-radius)}.adm-tabs-content{padding:var(--content-padding)}.adm-tabs-header-mask{position:absolute;top:0;bottom:0;z-index:1;width:30px;height:100%;pointer-events:none}.adm-tabs-header-mask-left{left:0;background:linear-gradient(to right,var(--adm-color-background),rgba(255,255,255,0))}.adm-tabs-header-mask-right{right:0;background:linear-gradient(to left,var(--adm-color-background),rgba(255,255,255,0))}.adm-list{--header-font-size: var(--adm-font-size-7);--prefix-width: "auto";--prefix-padding-right: 12px;--align-items: center;--active-background-color: var(--adm-color-border);--border-inner: solid 1px var(--adm-color-border);--border-top: solid 1px var(--adm-color-border);--border-bottom: solid 1px var(--adm-color-border);--padding-left: 12px;--padding-right: 12px;--font-size: var(--adm-font-size-9);--extra-max-width: 70%}.adm-list-header{color:var(--adm-color-weak);font-size:var(--header-font-size);padding:8px var(--padding-right) 8px var(--padding-left)}.adm-list-body{background-color:var(--adm-color-background);overflow:hidden;font-size:var(--font-size)}.adm-list-body-inner{margin-top:-1px}.adm-list-default .adm-list-body{border-top:var(--border-top);border-bottom:var(--border-bottom)}.adm-list-card{margin:12px}.adm-list-card .adm-list-body{border-radius:8px}.adm-list-card .adm-list-header{padding-left:0}.adm-list-item{display:block;padding-left:var(--padding-left);position:relative;background-color:var(--adm-color-background);line-height:1.5}.adm-list-item-title,.adm-list-item-description{color:var(--adm-color-weak);font-size:var(--adm-font-size-main)}.adm-list-item-content{display:flex;align-items:var(--align-items);justify-content:flex-start;border-top:var(--border-inner);padding-right:var(--padding-right)}.adm-list-item-content-prefix{width:var(--prefix-width);flex:none;padding-right:var(--prefix-padding-right)}.adm-list-item-content-main{flex:auto;padding:12px 0}.adm-list-item-content-extra{flex:none;padding-left:12px;font-size:var(--adm-font-size-7);color:var(--adm-color-weak);max-width:var(--extra-max-width)}.adm-list-item-content-arrow{flex:none;display:flex;align-items:center;margin-left:4px;color:var(--adm-color-light);font-size:19px}.adm-list-item-disabled{cursor:not-allowed}.adm-list-item-disabled.adm-list-item-disabled>.adm-list-item-content>*{opacity:.4;pointer-events:none}a.adm-list-item:active:not(.adm-list-item-disabled){background-color:var(--active-background-color)}a.adm-list-item:active:not(.adm-list-item-disabled):after{content:" ";display:block;position:absolute;width:100%;bottom:-1px;left:0;border-bottom:var(--border-inner)}.adm-infinite-scroll{color:var(--adm-color-weak);padding:18px;display:flex;justify-content:center;align-items:center;font-size:var(--adm-font-size-main)}.adm-infinite-scroll-failed-text{display:inline-block;margin-right:8px}.adm-nav-bar{--height: 45px;--border-bottom: none;display:flex;align-items:center;height:var(--height);border-bottom:var(--border-bottom);padding:0 12px;white-space:nowrap}.adm-nav-bar-left,.adm-nav-bar-right{flex:1}.adm-nav-bar-title{flex:auto;text-align:center;overflow:hidden;text-overflow:ellipsis}.adm-nav-bar-back{display:flex;align-items:center;margin-right:16px;padding:6px 0;cursor:pointer}.adm-nav-bar-back-arrow{font-size:24px;margin-right:4px}.adm-nav-bar-left{font-size:var(--adm-font-size-7);display:flex;justify-content:flex-start;align-items:center}.adm-nav-bar-title{justify-content:center;white-space:nowrap;font-size:var(--adm-font-size-10);padding:0 12px}.adm-nav-bar-right{text-align:right}.adm-toast-mask .adm-toast-wrap{position:fixed;top:0;left:0;width:100%;height:100%;text-align:center}.adm-toast-mask .adm-toast-main{display:inline-block;position:relative;top:50%;transform:translateY(-50%);width:auto;max-width:204px;max-height:70%;overflow:auto;color:#fff;word-break:break-all;background-color:#000000b3;border-radius:8px;pointer-events:all;font-size:var(--adm-font-size-7);line-height:1.5;box-sizing:border-box;text-align:initial}.adm-toast-mask .adm-toast-main-text{padding:12px;min-width:0}.adm-toast-mask .adm-toast-main-icon{padding:35px 12px;min-width:150px}.adm-toast-mask .adm-toast-main-icon .adm-toast-icon{text-align:center;margin-bottom:8px;font-size:36px;line-height:1}.adm-toast-loading{--size: 48px;margin:0 auto 8px}')),document.head.appendChild(a)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
11
11
|
(function(A,j){typeof exports=="object"&&typeof module!="undefined"?j(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@formily/reactive"),require("antd"),require("@ant-design/icons"),require("antd-style"),require("@formily/reactive-react"),require("@emotion/css"),require("@nocobase/utils/client"),require("react-i18next"),require("react-router-dom"),require("@nocobase/plugin-notification-manager/client"),require("@nocobase/plugin-mobile/client"),require("@nocobase/plugin-workflow/client"),require("@formily/react"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@formily/reactive","antd","@ant-design/icons","antd-style","@formily/reactive-react","@emotion/css","@nocobase/utils/client","react-i18next","react-router-dom","@nocobase/plugin-notification-manager/client","@nocobase/plugin-mobile/client","@nocobase/plugin-workflow/client","@formily/react","@formily/shared"],j):(A=typeof globalThis!="undefined"?globalThis:A||self,j(A["@nocobase/plugin-notification-in-app-message"]={},A["@nocobase/client"],A.jsxRuntime,A.react,A["@formily/reactive"],A.antd,A["@ant-design/icons"],A["antd-style"],A["@formily/reactive-react"],A["@emotion/css"],A["@nocobase/utils"],A["react-i18next"],A["react-router-dom"],A["@nocobase/plugin-notification-manager"],A["@nocobase/plugin-mobile"],A["@nocobase/plugin-workflow"],A["@formily/react"],A["@formily/shared"]))})(this,function(A,j,S,v,W,$,Fi,gr,ve,yr,be,Kh,In,qh,ct,Uo,qa,Yh){"use strict";var Dw=Object.defineProperty,Uw=Object.defineProperties;var Vw=Object.getOwnPropertyDescriptors;var Hh=Object.getOwnPropertySymbols;var Bw=Object.prototype.hasOwnProperty,bw=Object.prototype.propertyIsEnumerable;var Rh=(A,j,S)=>j in A?Dw(A,j,{enumerable:!0,configurable:!0,writable:!0,value:S}):A[j]=S,an=(A,j)=>{for(var S in j||(j={}))Bw.call(j,S)&&Rh(A,S,j[S]);if(Hh)for(var S of Hh(j))bw.call(j,S)&&Rh(A,S,j[S]);return A},Ka=(A,j)=>Uw(A,Vw(j));var fe=(A,j,S)=>new Promise((v,W)=>{var $=ve=>{try{gr(S.next(ve))}catch(yr){W(yr)}},Fi=ve=>{try{gr(S.throw(ve))}catch(yr){W(yr)}},gr=ve=>ve.done?v(ve.value):Promise.resolve(ve.value).then($,Fi);gr((S=S.apply(A,j)).next())});function Gh(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}function Xh(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(r,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const Y=Gh(v),Ya="notification-in-app-message";function Ze(){return Kh.useTranslation([Ya,"client"],{nsMode:"fallback"})}let Ga;const Zh=e=>{Ga=e},wr=()=>Ga,kr=W.observable({value:null}),cn=W.observable({value:{}}),$i=W.observable({value:!1}),Xa=W.observable({value:0}),ge=W.observable({value:"all"}),Je=W.observable.computed(()=>Object.values(cn.value).filter(t=>{var n;return t.userId==String((n=kr.value)!=null?n:"")}).filter(t=>ge.value==="read"?t.totalMsgCnt-t.unreadMsgCnt>0:ge.value==="unread"?t.unreadMsgCnt>0:!0).sort((t,n)=>t.latestMsgReceiveTimestamp>n.latestMsgReceiveTimestamp?-1:1)),Vo=W.observable.computed(()=>Je.value.length<Xa.value),te=W.observable({value:null}),Jh=W.observable.computed(()=>te.value&&cn.value&&cn.value[te.value]?cn.value[te.value]:null),Ft=e=>fe(this,null,function*(){var l,o,s;const t=wr();$i.value=!0;const n=yield t.request({url:"myInAppChannels:list",method:"get",params:be.merge({filter:{status:ge.value}},e!=null?e:{})}),r=(l=n.data)==null?void 0:l.data;Array.isArray(r)&&r.forEach(u=>{cn.value[u.name]=u});const i=(s=(o=n.data)==null?void 0:o.meta)==null?void 0:s.count;i>=0&&(Xa.value=i),$i.value=!1});W.autorun(()=>{var e;!te.value&&((e=Je.value[0])!=null&&e.name)?te.value=Je.value[0].name:(Je.value.length===0||Je.value.length>0&&!Je.value.find(t=>t.name===te.value))&&(te.value=null)}),W.reaction(()=>ge.value,()=>{var e;(e=Je.value[0])!=null&&e.name&&(te.value=Je.value[0].name)},{fireImmediately:!0});const em={name:"notificationInAppMessages",fieldNameMap:{id:"id",channelName:"channelName",userId:"userId",content:"content",status:"status",title:"title",receiveTimestamp:"receiveTimestamp",options:"options"}},Ln=W.observable({value:{}}),Ai=W.observable({value:!1}),tm=W.observable.computed(()=>Object.values(Ln.value).sort((e,t)=>e.receiveTimestamp>t.receiveTimestamp?-1:1)),nm=e=>ge.value==="read"?e.status==="read":ge.value==="unread"?e.status==="unread":!0,rm=e=>{var t;return e.userId==String((t=kr.value)!=null?t:"")},ji=W.observable.computed(()=>te.value?tm.value.filter(t=>t.channelName===te.value&&nm(t)&&rm):[]),Bo=(...t)=>fe(this,[...t],function*(e={limit:30}){var l,o;Ai.value=!0,ge.value!=="all"&&(e.filter=be.merge((l=e.filter)!=null?l:{},{status:ge.value}));const r=yield wr().request({url:"myInAppMessages:list",method:"get",params:e}),i=(o=r==null?void 0:r.data)==null?void 0:o.data.messages;Array.isArray(i)&&i.forEach(s=>{Ln.value[s.id]=s}),Ai.value=!1}),bo=e=>fe(this,null,function*(){yield wr().request({resource:em.name,action:"update",method:"post",params:e});const n=Ln.value[e.filterByTk];Ln.value[e.filterByTk]=an(an({},n),e.values),Di()});W.autorun(()=>{te.value&&Bo({filter:{channelName:te.value}})});const Sr=W.observable({value:null}),Di=()=>fe(this,null,function*(){var n;const t=yield wr().request({url:"myInAppMessages:count",method:"get",params:{filter:{status:"unread"}}});Sr.value=(n=t==null?void 0:t.data)==null?void 0:n.data.count}),Wo=W.observable.computed(()=>{const e=te.value;if(!e)return!1;const t=cn.value[e],n=ji.value;if({read:t.totalMsgCnt-t.unreadMsgCnt>n.length,unread:t.unreadMsgCnt>n.length,all:t.totalMsgCnt>n.length}[ge.value]&&n.length>0)return!0}),Qo=W.observable({value:null});W.reaction(()=>Qo.value,e=>{if(e&&["message:created","message:updated"].includes(e.type)){const{data:t}=e;Ln.value[t.id]=t,Ft({filter:{name:t.channelName}}),Di()}});const Ho=()=>{let e=0;const t=new AbortController;let n=!1;const r=()=>{n=!0,t.abort()},i=be.uid(),l=s=>fe(this,null,function*(){const f=(yield wr().silent().request({url:"myInAppMessages:sse",method:"get",signal:t.signal,headers:{Accept:"text/event-stream"},params:{id:s},responseType:"stream",adapter:"fetch"})).data.pipeThrough(new TextDecoderStream).getReader();for(e=0;;){const{value:p,done:g}=yield f.read();if(g)break;const y=p.split(`
|
|
12
12
|
|
|
13
|
-
`).filter(Boolean);for(const k of y){const E=JSON.parse(k.replace(/^data:\s*/,"").trim());Qo.value=E}}}),o=()=>fe(this,null,function*(){try{yield l(i)}catch(s){console.error("Error during stream:",s.message);const u=e<6?1e3*Math.pow(2,e):6e4;return e++,setTimeout(()=>{n||o()},u),{error:s}}});return o(),r},xr=W.observable({value:!1}),im=ve.observer(()=>{const{t:e}=Ze(),t=In.useNavigate(),{token:n}=$.theme.useToken(),[r,i]=v.useState(null),l=te.value,o=Ai.value,s=ji.value,u={read:e("Read"),unread:e("Unread")};if(!l)return null;const a=f=>{var p;if(bo({filterByTk:f.id,values:{status:"read"}}),(p=f.options)!=null&&p.url){xr.value=!1;const g=f.options.url;g.startsWith("/")?t(g):window.location.href=g}},h=v.useCallback(()=>{const f={},p=s[s.length-1];p&&(f.receiveTimestamp={$lt:p.receiveTimestamp}),l&&(f.channelName=l),Bo({filter:f,limit:30})},[s,l]);return S.jsxs($.ConfigProvider,{theme:{components:{Badge:{dotSize:8}}},children:[S.jsx($.Typography.Title,{level:4,style:{marginBottom:n.marginLG},children:cn.value[l].title}),s.length===0&&Ai.value?S.jsx($.Spin,{style:{width:"100%",marginTop:n.marginXXL}}):s.map((f,p)=>{var g,y,k,E;return S.jsx(S.Fragment,{children:S.jsx($.Card,{size:"small",bordered:!1,style:{marginBottom:n.marginMD},onMouseEnter:()=>{i(f.id)},onMouseLeave:()=>{i(null)},title:S.jsx($.Tooltip,{title:f.title,mouseEnterDelay:.5,children:S.jsx("div",{onClick:()=>{a(f)},style:{fontWeight:f.status==="unread"?"bold":"normal",cursor:"pointer",
|
|
13
|
+
`).filter(Boolean);for(const k of y){const E=JSON.parse(k.replace(/^data:\s*/,"").trim());Qo.value=E}}}),o=()=>fe(this,null,function*(){try{yield l(i)}catch(s){console.error("Error during stream:",s.message);const u=e<6?1e3*Math.pow(2,e):6e4;return e++,setTimeout(()=>{n||o()},u),{error:s}}});return o(),r},xr=W.observable({value:!1}),im=ve.observer(()=>{const{t:e}=Ze(),t=In.useNavigate(),{token:n}=$.theme.useToken(),[r,i]=v.useState(null),l=te.value,o=Ai.value,s=ji.value,u={read:e("Read"),unread:e("Unread")};if(!l)return null;const a=f=>{var p;if(bo({filterByTk:f.id,values:{status:"read"}}),(p=f.options)!=null&&p.url){xr.value=!1;const g=f.options.url;g.startsWith("/")?t(g):window.location.href=g}},h=v.useCallback(()=>{const f={},p=s[s.length-1];p&&(f.receiveTimestamp={$lt:p.receiveTimestamp}),l&&(f.channelName=l),Bo({filter:f,limit:30})},[s,l]);return S.jsxs($.ConfigProvider,{theme:{components:{Badge:{dotSize:8}}},children:[S.jsx($.Typography.Title,{level:4,style:{marginBottom:n.marginLG},children:cn.value[l].title}),s.length===0&&Ai.value?S.jsx($.Spin,{style:{width:"100%",marginTop:n.marginXXL}}):s.map((f,p)=>{var g,y,k,E;return S.jsx(S.Fragment,{children:S.jsx($.Card,{size:"small",bordered:!1,style:{marginBottom:n.marginMD},onMouseEnter:()=>{i(f.id)},onMouseLeave:()=>{i(null)},title:S.jsx($.Tooltip,{title:f.title,mouseEnterDelay:.5,children:S.jsx("div",{onClick:()=>{a(f)},style:{fontWeight:f.status==="unread"?"bold":"normal",cursor:"pointer",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:f.title})}),extra:(g=f.options)!=null&&g.url?S.jsx($.Button,{type:"link",onClick:d=>{d.stopPropagation(),a(f)},children:e("View")}):null,children:S.jsxs($.Descriptions,{column:1,children:[S.jsxs($.Descriptions.Item,{label:e("Content"),children:[" ",S.jsxs($.Tooltip,{title:((y=f.content)==null?void 0:y.length)>100?f.content:"",mouseEnterDelay:.5,children:[((k=f.content)==null?void 0:k.slice(0,100))+(((E=f.content)==null?void 0:E.length)>100?"...":"")," "]})]}),S.jsx($.Descriptions.Item,{label:e("Datetime"),children:be.dayjs(f.receiveTimestamp).fromNow()}),S.jsx($.Descriptions.Item,{label:e("Status"),children:S.jsx("div",{style:{height:n.controlHeight},children:r===f.id&&f.status==="unread"?S.jsx($.Button,{type:"link",size:"small",style:{fontSize:n.fontSizeSM},onClick:()=>{bo({filterByTk:f.id,values:{status:"read"}})},children:e("Mark as read")}):S.jsx($.Tag,{color:f.status==="unread"?"red":"green",children:u[f.status]})})})]},p)},f.id)})}),Wo.value&&S.jsx("div",{style:{width:"100%",display:"flex",justifyContent:"center"},children:S.jsx($.Button,{onClick:h,loading:o,children:e("Loading more")})})]})}),lm=()=>{const{t:e}=Ze(),t=[{label:e("All"),key:"all"},{label:e("Unread"),key:"unread"},{label:e("Read"),key:"read"}];return S.jsx($.ConfigProvider,{theme:{components:{Tabs:{horizontalItemMargin:"20px"}}},children:S.jsx($.Tabs,{activeKey:ge.value,items:t,onChange:n=>{ge.value=n,Ft({})}})})},om=ve.observer(lm),sm=()=>{const{token:e}=$.theme.useToken(),{t}=Ze(),n=Je.value;ji.value;const r=te.value,i=()=>{const o={},s=n[n.length-1];s!=null&&s.latestMsgReceiveTimestamp&&(o.latestMsgReceiveTimestamp={$lt:s.latestMsgReceiveTimestamp}),Ft({filter:o,limit:30})},l=Vo.value?S.jsx("div",{style:{textAlign:"center",marginTop:12,height:32,lineHeight:"32px"},children:S.jsx($.Button,{loading:$i.value,onClick:i,children:t("Loading more")})}):null;return S.jsxs($.Layout,{style:{height:"100%"},children:[S.jsxs($.Layout.Sider,{width:350,style:{height:"100%",overflowY:"auto",background:e.colorBgContainer,padding:"0 15px",border:"none"},children:[S.jsx(om,{}),S.jsx($.List,{itemLayout:"horizontal",dataSource:n,loadMore:l,style:{paddingBottom:"20px"},loading:n.length===0&&$i.value,renderItem:o=>{const s=r===o.name?e.colorPrimaryText:e.colorText,u=r===o.name?e.colorPrimaryText:e.colorTextTertiary;return S.jsxs($.List.Item,{className:yr.css`
|
|
14
14
|
&:hover {
|
|
15
15
|
background-color: ${e.colorBgTextHover}};
|
|
16
16
|
}
|
|
17
|
-
`,style:Ka(an({padding:"10px 10px",color:s},r===o.name?{backgroundColor:e.colorPrimaryBg}:{}),{cursor:"pointer",marginTop:"10px",border:"none",borderRadius:"10px",display:"flex",flexDirection:"column",justifyContent:"space-between"}),onClick:()=>{te.value=o.name},children:[S.jsxs($.Flex,{justify:"space-between",style:{width:"100%"},children:[S.jsx("div",{style:{width:"150px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",fontWeight:"bold"},children:o.title}),S.jsx("div",{style:{width:"120px",fontWeight:400,textAlign:"right",fontFamily:"monospace",color:u},children:be.dayjs(o.latestMsgReceiveTimestamp).fromNow()})]}),S.jsxs($.Flex,{justify:"space-between",style:{width:"100%",marginTop:e.margin},children:[S.jsxs("div",{style:{width:"80%",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:u},children:[" ",o.latestMsgTitle]}),ge.value!=="read"?S.jsx($.Badge,{style:{border:"none"},count:o.unreadMsgCnt}):null]})]})}})]}),S.jsx($.Layout.Content,{style:{padding:e.paddingLG,height:"100%",overflowY:"auto"},children:r?S.jsx(im,{}):null})]})},um=ve.observer(sm),am=gr.createStyles(({token:e})=>({button:{color:e.colorTextHeaderMenu+" !important"}})),cm=e=>{var u,a;const{t}=Ze(),{styles:n}=am(),i=(a=(u=j.useCurrentUserContext().data)==null?void 0:u.data)==null?void 0:a.id;v.useEffect(()=>{Di()},[]),v.useEffect(()=>{kr.value=i!=null?i:null},[i]);const l=v.useCallback(()=>{xr.value=!0,Ft({})},[]);v.useEffect(()=>{const h=[];h.push(Ho());const f=()=>{for(;h.length>0;){const g=h.pop();g&&g()}},p=()=>{document.visibilityState==="visible"?h.push(Ho()):f()};return document.addEventListener("visibilitychange",p),()=>{f(),document.removeEventListener("visibilitychange",p)}},[]);const o=S.jsx("div",{style:{padding:"0"},children:t("Message")}),s=S.jsx("div",{style:{marginLeft:"15px"},children:S.jsx(Fi.CloseOutlined,{})});return v.useEffect(()=>W.reaction(()=>Qo.value,f=>{if(f&&["message:created","message:updated"].includes(f.type)){const{data:p}=f;Ln.value[p.id]=p,f.type==="message:created"&&$.notification.info({message:S.jsx("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:p.title}),description:p.content.slice(0,100)+(p.content.length>100?"...":""),onClick:()=>{xr.value=!0,te.value=p.channelName,$.notification.destroy()}})}}),[]),S.jsxs($.ConfigProvider,{theme:{components:{Drawer:{paddingLG:0}}},children:[S.jsx($.Tooltip,{title:t("Message"),children:S.jsx($.Badge,{count:Sr.value,size:"small",offset:[-12,14],children:S.jsx($.Button,{className:n.button,title:t("Message"),icon:S.jsx(j.Icon,{type:"BellOutlined"}),onClick:l})})}),S.jsx($.Drawer,{title:o,open:xr.value,closeIcon:s,width:900,onClose:()=>{xr.value=!1},children:S.jsx(um,{})})]})},fm=ve.observer(cm),dm=e=>S.jsx(j.PinnedPluginListProvider,{items:{inbox:{order:301,component:"Inbox",pin:!0,snippet:"*"}},children:S.jsx(j.SchemaComponentOptions,{components:{Inbox:fm},children:e.children})});function pm(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function hm(e){return typeof e.value==="object"&&e.value?S.jsx(vm,an({},e)):S.jsx(mm,an({},e))}function mm({value:e,onChange:t}){const n=Uo.useWorkflowVariableOptions({types:[pm]});return S.jsx(j.Variable.Input,{scope:n,value:e,onChange:t,children:S.jsx(j.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})}function vm(e){const t=qa.useField(),n=j.useCollectionFilterOptions("users"),{token:r}=j.useToken();return S.jsx("div",{style:{border:`1px dashed ${r.colorBorder}`,padding:r.paddingSM},children:S.jsx(j.SchemaComponent,{basePath:t.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:n,dynamicComponent:Uo.FilterDynamicComponent}}}}})})}function gm(){const e=Uo.useWorkflowExecuted(),[t,n]=v.useState(!1),{t:r}=Ze(),i=qa.useField(),{receivers:l}=i.form.values,o=v.useCallback(()=>{l.push(""),n(!1)},[l]),s=v.useCallback(()=>{l.push({filter:{}}),n(!1)},[l]),u=S.jsx($.Button,{icon:S.jsx(Fi.PlusOutlined,{}),type:"dashed",block:!0,disabled:e,className:"ant-formily-array-base-addition",children:r("Add user")});return e?u:S.jsx($.Popover,{open:t,onOpenChange:n,content:S.jsxs($.Space,{direction:"vertical",size:"small",children:[S.jsx($.Button,{type:"text",onClick:o,children:r("Select users")}),S.jsx($.Button,{type:"text",onClick:s,children:r("Query users")})]}),children:u})}const ym=({variableOptions:e})=>{const{t}=Ze();return S.jsx(j.SchemaComponent,{scope:{t},components:{UsersSelect:hm,UsersAddition:gm},schema:{type:"void",properties:{receivers:{type:"array",title:'{{t("Receivers")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:j.css`
|
|
17
|
+
`,style:Ka(an({padding:"10px 10px",color:s},r===o.name?{backgroundColor:e.colorPrimaryBg}:{}),{cursor:"pointer",marginTop:"10px",border:"none",borderRadius:"10px",display:"flex",flexDirection:"column",justifyContent:"space-between"}),onClick:()=>{te.value=o.name},children:[S.jsxs($.Flex,{justify:"space-between",style:{width:"100%"},children:[S.jsx("div",{style:{width:"150px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",fontWeight:"bold"},children:o.title}),S.jsx("div",{style:{width:"120px",fontWeight:400,textAlign:"right",fontFamily:"monospace",color:u},children:be.dayjs(o.latestMsgReceiveTimestamp).fromNow()})]}),S.jsxs($.Flex,{justify:"space-between",style:{width:"100%",marginTop:e.margin},children:[S.jsxs("div",{style:{width:"80%",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",color:u},children:[" ",o.latestMsgTitle]}),ge.value!=="read"?S.jsx($.Badge,{style:{border:"none"},count:o.unreadMsgCnt}):null]})]})}})]}),S.jsx($.Layout.Content,{style:{padding:e.paddingLG,height:"100%",overflowY:"auto"},children:r?S.jsx(im,{}):null})]})},um=ve.observer(sm),am=gr.createStyles(({token:e})=>({button:{color:e.colorTextHeaderMenu+" !important"}})),cm=e=>{var u,a;const{t}=Ze(),{styles:n}=am(),i=(a=(u=j.useCurrentUserContext().data)==null?void 0:u.data)==null?void 0:a.id;v.useEffect(()=>{Di()},[]),v.useEffect(()=>{kr.value=i!=null?i:null},[i]);const l=v.useCallback(()=>{xr.value=!0,Ft({})},[]);v.useEffect(()=>{const h=[];h.push(Ho());const f=()=>{for(;h.length>0;){const g=h.pop();g&&g()}},p=()=>{document.visibilityState==="visible"?h.push(Ho()):f()};return document.addEventListener("visibilitychange",p),()=>{f(),document.removeEventListener("visibilitychange",p)}},[]);const o=S.jsx("div",{style:{padding:"0"},children:t("Message")}),s=S.jsx("div",{style:{marginLeft:"15px"},children:S.jsx(Fi.CloseOutlined,{})});return v.useEffect(()=>W.reaction(()=>Qo.value,f=>{if(f&&["message:created","message:updated"].includes(f.type)){const{data:p}=f;Ln.value[p.id]=p,f.type==="message:created"&&$.notification.info({message:S.jsx("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:p.title}),description:p.content.slice(0,100)+(p.content.length>100?"...":""),onClick:()=>{xr.value=!0,te.value=p.channelName,$.notification.destroy()}})}}),[]),S.jsxs($.ConfigProvider,{theme:{components:{Drawer:{paddingLG:0}}},children:[S.jsx($.Tooltip,{title:t("Message"),children:S.jsx($.Badge,{count:Sr.value,size:"small",offset:[-12,14],children:S.jsx($.Button,{className:n.button,title:t("Message"),icon:S.jsx(j.Icon,{type:"BellOutlined"}),onClick:l})})}),S.jsx($.Drawer,{title:o,open:xr.value,closeIcon:s,width:900,onClose:()=>{xr.value=!1},children:S.jsx(um,{})})]})},fm=ve.observer(cm),dm=e=>S.jsx(j.PinnedPluginListProvider,{items:{inbox:{order:301,component:"Inbox",pin:!0,snippet:"*"}},children:S.jsx(j.SchemaComponentOptions,{components:{Inbox:fm},children:e.children})});function pm(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function hm(e){return typeof e.value==="object"&&e.value?S.jsx(vm,an({},e)):S.jsx(mm,an({},e))}function mm({value:e,onChange:t}){const n=Uo.useWorkflowVariableOptions({types:[pm]});return S.jsx(j.Variable.Input,{scope:n,value:e,onChange:t,children:S.jsx(j.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users",defaultParams:e?{filter:{id:e}}:void 0},manual:!1,value:e,onChange:t})})}function vm(e){const t=qa.useField(),n=j.useCollectionFilterOptions("users"),{token:r}=j.useToken();return S.jsx("div",{style:{border:`1px dashed ${r.colorBorder}`,padding:r.paddingSM},children:S.jsx(j.SchemaComponent,{basePath:t.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:n,dynamicComponent:Uo.FilterDynamicComponent}}}}})})}function gm(){const e=Uo.useWorkflowExecuted(),[t,n]=v.useState(!1),{t:r}=Ze(),i=qa.useField(),{receivers:l}=i.form.values,o=v.useCallback(()=>{l.push(""),n(!1)},[l]),s=v.useCallback(()=>{l.push({filter:{}}),n(!1)},[l]),u=S.jsx($.Button,{icon:S.jsx(Fi.PlusOutlined,{}),type:"dashed",block:!0,disabled:e,className:"ant-formily-array-base-addition",children:r("Add user")});return e?u:S.jsx($.Popover,{open:t,onOpenChange:n,content:S.jsxs($.Space,{direction:"vertical",size:"small",children:[S.jsx($.Button,{type:"text",onClick:o,children:r("Select users")}),S.jsx($.Button,{type:"text",onClick:s,children:r("Query users")})]}),children:u})}const ym=({variableOptions:e})=>{const{t}=Ze();return S.jsx(j.SchemaComponent,{scope:{t},components:{UsersSelect:hm,UsersAddition:gm},schema:{type:"void",properties:{receivers:{type:"array",title:'{{t("Receivers")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"void","x-component":"Space","x-component-props":{className:j.css`
|
|
18
18
|
width: 100%;
|
|
19
19
|
&.ant-space.ant-space-horizontal {
|
|
20
20
|
flex-wrap: nowrap;
|
package/dist/externalVersion.js
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
|
-
"@nocobase/client": "1.4.0-beta.
|
|
13
|
-
"@nocobase/plugin-notification-manager": "1.4.0-beta.
|
|
14
|
-
"@nocobase/plugin-mobile": "1.4.0-beta.
|
|
15
|
-
"@nocobase/utils": "1.4.0-beta.
|
|
12
|
+
"@nocobase/client": "1.4.0-beta.8",
|
|
13
|
+
"@nocobase/plugin-notification-manager": "1.4.0-beta.8",
|
|
14
|
+
"@nocobase/plugin-mobile": "1.4.0-beta.8",
|
|
15
|
+
"@nocobase/utils": "1.4.0-beta.8",
|
|
16
16
|
"react-i18next": "11.18.6",
|
|
17
|
-
"@nocobase/server": "1.4.0-beta.
|
|
17
|
+
"@nocobase/server": "1.4.0-beta.8",
|
|
18
18
|
"sequelize": "6.35.2",
|
|
19
|
-
"@nocobase/database": "1.4.0-beta.
|
|
19
|
+
"@nocobase/database": "1.4.0-beta.8",
|
|
20
20
|
"antd": "5.12.8",
|
|
21
21
|
"@formily/reactive-react": "2.3.0",
|
|
22
22
|
"@formily/reactive": "2.3.0",
|
|
@@ -26,6 +26,6 @@ module.exports = {
|
|
|
26
26
|
"react-router-dom": "6.21.0",
|
|
27
27
|
"@formily/react": "2.3.0",
|
|
28
28
|
"@formily/core": "2.3.0",
|
|
29
|
-
"@nocobase/plugin-workflow": "1.4.0-beta.
|
|
29
|
+
"@nocobase/plugin-workflow": "1.4.0-beta.8",
|
|
30
30
|
"@formily/shared": "2.3.2"
|
|
31
31
|
};
|
|
@@ -81,7 +81,6 @@ class InAppNotificationChannel extends import_plugin_notification_manager.BaseNo
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
sendDataToUser(userId, message) {
|
|
84
|
-
var _a, _b;
|
|
85
84
|
const clients = this.userClientsMap[userId];
|
|
86
85
|
if (clients) {
|
|
87
86
|
for (const clientId in clients) {
|
|
@@ -91,8 +90,8 @@ class InAppNotificationChannel extends import_plugin_notification_manager.BaseNo
|
|
|
91
90
|
type: message.type,
|
|
92
91
|
data: {
|
|
93
92
|
...message.data,
|
|
94
|
-
title:
|
|
95
|
-
content:
|
|
93
|
+
title: message.data.title || "",
|
|
94
|
+
content: message.data.content || ""
|
|
96
95
|
}
|
|
97
96
|
})}
|
|
98
97
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-notification-in-app-message",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.8",
|
|
4
4
|
"displayName": "Notification: In-app message",
|
|
5
5
|
"displayName.zh-CN": "通知:站内信",
|
|
6
6
|
"description": "It supports users in receiving real-time message notifications within the NocoBase application.",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@nocobase/test": "1.x",
|
|
25
25
|
"react-router-dom": "^6.x"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "d6ca78c29506d611937583d79fab5dffbd17a6fc"
|
|
28
28
|
}
|