nocobase-plugin-ding-talk
Version:
Integrated DingTalk, including login and robot functions
11 lines (9 loc) • 3.05 kB
JavaScript
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("@nocobase/plugin-auth/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-auth/client","react/jsx-runtime","react","antd","@ant-design/icons"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["nocobase-plugin-ding-talk"]={},e["@nocobase/client"],e["@nocobase/plugin-auth"],e.jsxRuntime,e.react,e.antd,e["@ant-design/icons"]))})(this,function(e,t,o,r,u,l,d){"use strict";var s=(e,t,o)=>new Promise((r,u)=>{var l=n=>{try{c(o.next(n))}catch(i){u(i)}},d=n=>{try{c(o.throw(n))}catch(i){u(i)}},c=n=>n.done?r(n.value):Promise.resolve(n.value).then(l,d);c((o=o.apply(e,t)).next())});const c=a=>{const[p,g]=u.useState(!1),h=t.useResource("community-ding-talk"),y=()=>s(this,null,function*(){g(!0);try{const m=yield h.getAuthUrl({values:{authenticator:a.authenticator.name,redirect:new URLSearchParams(location.search?location.search.substring(1):"").get("redirect")||""}});console.log("uu",m,m.data),location.href=m.data.data}finally{setTimeout(()=>{g(!1)},1e3)}});return r.jsx(l.Button,{loading:p,disabled:p,icon:r.jsx(d.DingtalkOutlined,{}),style:{width:"100%"},onClick:y,children:a.authenticator.title||a.authenticator.name})},n=a=>(console.log("aaa",a),r.jsx(t.SchemaComponent,{schema:{type:"object",properties:{communityDingTalkAuth:{type:"void",properties:{public:{type:"object",properties:{autoSignup:{"x-decorator":"FormItem",type:"boolean",title:"用户不存在时自动注册",required:!1,"x-component":"Checkbox"}}},internal:{type:"object",properties:{userCheckType:{"x-decorator":"FormItem",type:"string",title:"用户验证方式",required:!0,"x-component":"Select","x-component-props":{options:[{value:"orgEmail",label:"企业邮箱"},{value:"personalEmail",label:"个人邮箱"},{value:"mobile",label:"手机号"}]}},emailDomain:{"x-decorator":"FormItem",type:"string",title:"邮箱域名,多个使用英文逗号分隔",required:!0,"x-component":"Input"},appKey:{"x-decorator":"FormItem",type:"string",title:"应用ID",required:!0,"x-component":"Input"},appSecret:{"x-decorator":"FormItem",type:"string",title:"应用秘钥",required:!0,"x-component":"Password"}}}}}}}}));class i extends t.Plugin{afterAdd(){return s(this,null,function*(){})}beforeLoad(){return s(this,null,function*(){})}load(){return s(this,null,function*(){this.app.pm.get(o).registerType("community-ding-talk-auth",{components:{SignInButton:c,AdminSettingsForm:n}})})}}e.NocobasePluginDingTalkClient=i,e.default=i,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});