{"_id":"@blueking/platform-config","_rev":"7-4ff23b8e342931a540820263a368e4d6","name":"@blueking/platform-config","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@blueking/platform-config","version":"1.0.0","_id":"@blueking/platform-config@1.0.0","maintainers":[{"name":"blueking","email":"contactus_bk@tencent.com"}],"dist":{"shasum":"942ce30c7f310b26896e4c0cb3e571dd3c82d65f","tarball":"https://registry.npmjs.org/@blueking/platform-config/-/platform-config-1.0.0.tgz","fileCount":4,"integrity":"sha512-5W29oXljgtpE50ag1360Xvs2NyXRvO26pjwjVmtPDvw7RbnPwezCVjLJRWT/9+3lRsEQExqyxhDvWqQWEik3tQ==","signatures":[{"sig":"MEYCIQDD+KK8ImTfNMGXx/lpbciLm/ZdDfHYVLH3pyQQi7VWLAIhANCgB8GH4Njd/r/5xePiqE4Mw4na05ZRElKausR5bmxn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":53210},"main":"./dist/platform-config.js","type":"module","module":"./dist/platform-config.js","exports":{".":{"import":"./dist/platform-config.js","require":"./dist/platform-config.umd.cjs"}},"gitHead":"b961ea447c92847edc330ddb5906792c2c310011","scripts":{"dev":"vite --host example.com","build":"vite build"},"_npmUser":{"name":"blueking","email":"contactus_bk@tencent.com"},"_npmVersion":"9.8.1","description":"获取及使用平台配置公共方法","directories":{},"_nodeVersion":"18.18.0","dependencies":{"xss":"^1.0.15"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/platform-config_1.0.0_1716372620443_0.8117953627933239","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@blueking/platform-config","version":"1.0.1","author":{"name":"bkfe"},"license":"MIT","_id":"@blueking/platform-config@1.0.1","maintainers":[{"name":"blueking","email":"contactus_bk@tencent.com"}],"dist":{"shasum":"2817fc834c7c3dbcfd5b98c504c7558bad77a60b","tarball":"https://registry.npmjs.org/@blueking/platform-config/-/platform-config-1.0.1.tgz","fileCount":4,"integrity":"sha512-40u7F8ZhNxLxbEoRfGt81WpzPgyNfCkFEtMM3/ysV9rSaOaxi3QKiaSmJ6jyfh4Vtvkn/itSs84zf/MCJGl8lA==","signatures":[{"sig":"MEUCIBvXdbEfDRrZeHU1T6FZt5160BjdPcUZjYyQRDd8KxAJAiEAsldNYUgbP3lRYkGOXiE4sZAYHdqaHZf8irwN5o1G9SA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":53807},"main":"./dist/platform-config.js","type":"module","module":"./dist/platform-config.js","exports":{".":{"import":"./dist/platform-config.js","require":"./dist/platform-config.umd.cjs"}},"gitHead":"b961ea447c92847edc330ddb5906792c2c310011","scripts":{"dev":"vite --host example.com","build":"vite build"},"_npmUser":{"name":"blueking","email":"contactus_bk@tencent.com"},"_npmVersion":"9.8.1","description":"获取及使用平台配置的方法","directories":{},"_nodeVersion":"18.18.0","dependencies":{"xss":"^1.0.15"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/platform-config_1.0.1_1716867245134_0.7374743155853363","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@blueking/platform-config","version":"1.0.2","author":{"name":"bkfe"},"license":"MIT","_id":"@blueking/platform-config@1.0.2","maintainers":[{"name":"blueking","email":"contactus_bk@tencent.com"}],"dist":{"shasum":"be668d4df65e4abc2c19d0a3dd8f86b48cbf222d","tarball":"https://registry.npmjs.org/@blueking/platform-config/-/platform-config-1.0.2.tgz","fileCount":4,"integrity":"sha512-ai4x5Ru0gcucSuxpE9gha7S/lIsU0RsGchrHRPUrbbR8OujzC1X6KmUcRoJDZ4m3gghAUvWQFArkheL+o41v0Q==","signatures":[{"sig":"MEYCIQCBbHi18WumAuSl6g7PWmNKSYqyZyQd/lPzTiQRCzolygIhAM2a/455BaJk2peTQNSEjNpKbPqlJXKERI6HNtm8QYpN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":55540},"main":"./dist/platform-config.js","type":"module","module":"./dist/platform-config.js","exports":{".":{"import":"./dist/platform-config.js","require":"./dist/platform-config.umd.cjs"}},"gitHead":"0f0d6b4376862b78d8e718a7dbae4e8664b128b5","scripts":{"dev":"vite --host example.com","build":"vite build"},"_npmUser":{"name":"blueking","email":"contactus_bk@tencent.com"},"_npmVersion":"9.8.1","description":"获取及使用平台配置的方法","directories":{},"_nodeVersion":"18.18.0","dependencies":{"xss":"^1.0.15"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/platform-config_1.0.2_1718617244961_0.7023258103360559","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@blueking/platform-config","version":"1.0.3","author":{"name":"bkfe"},"license":"MIT","_id":"@blueking/platform-config@1.0.3","dist":{"shasum":"e9968f5283153b58ffa40a732e9a89e7396b5336","tarball":"https://registry.npmjs.org/@blueking/platform-config/-/platform-config-1.0.3.tgz","fileCount":4,"integrity":"sha512-eNTX+Uy8wzjAEfCJJ8OZAWwiyhFr9KseGt9OIg7AR448Qgpgd0qNDgEJeSKEsuUIonZOt9oIw2nXvcZyY8dGLg==","signatures":[{"sig":"MEUCIQDhvS02TaraA9jhSfdqrIiXWyqkrShEEmkpU/ZF9gjjWgIgcaV/cHImRO01cvPJoGGW1L0Q/EA6tBw8KLlUPYGCtME=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":55592},"main":"./dist/platform-config.js","type":"module","module":"./dist/platform-config.js","exports":{".":{"import":"./dist/platform-config.js","require":"./dist/platform-config.umd.cjs"}},"gitHead":"7292924eae01002723ebb93724e7602c11d899a1","scripts":{"dev":"vite --host example.com","build":"vite build"},"_npmUser":{"name":"blueking","email":"contactus_bk@tencent.com"},"_npmVersion":"9.8.1","description":"获取及使用平台配置的方法","directories":{},"_nodeVersion":"18.18.0","dependencies":{"xss":"^1.0.15"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/platform-config_1.0.3_1719218725868_0.027380420377146164","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"@blueking/platform-config","version":"1.0.4","author":{"name":"bkfe"},"license":"MIT","_id":"@blueking/platform-config@1.0.4","maintainers":[{"name":"blueking","email":"contactus_bk@tencent.com"}],"dist":{"shasum":"459f579beb188e834d9a726d8815216d12a6cf4c","tarball":"https://registry.npmjs.org/@blueking/platform-config/-/platform-config-1.0.4.tgz","fileCount":4,"integrity":"sha512-qYdNtOGHAd0h6o1QF6DR0BG+Xx7bkljJEt3iC0hD1hDAxhDOOTwjsb/VRKNDTcNm8WJWDLkV/afK1CauRP6d0A==","signatures":[{"sig":"MEYCIQDc95MEUFokfVferihp0s5ynaDXqrlsJ6mgD7exbztdLwIhANmaG5l2pn2i7TA3WZbiUyArBjgUgcXHmkHtdNvXXo1o","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":55546},"main":"./dist/platform-config.js","type":"module","module":"./dist/platform-config.js","exports":{".":{"import":"./dist/platform-config.js","require":"./dist/platform-config.umd.cjs"}},"gitHead":"44ace43bddec8f989291c2033444b06b2d4996a5","scripts":{"dev":"vite --host example.com","build":"vite build"},"_npmUser":{"name":"blueking","email":"contactus_bk@tencent.com"},"_npmVersion":"9.8.1","description":"获取及使用平台配置的方法","directories":{},"_nodeVersion":"18.18.0","dependencies":{"xss":"^1.0.15"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/platform-config_1.0.4_1720934665206_0.8431768664228732","host":"s3://npm-registry-packages"}},"1.0.5":{"name":"@blueking/platform-config","version":"1.0.5","author":{"name":"bkfe"},"license":"MIT","_id":"@blueking/platform-config@1.0.5","maintainers":[{"name":"blueking","email":"contactus_bk@tencent.com"}],"dist":{"shasum":"938800d36497af33beffe517fe689042c798450b","tarball":"https://registry.npmjs.org/@blueking/platform-config/-/platform-config-1.0.5.tgz","fileCount":4,"integrity":"sha512-z88WCgnPJ1V5XzFMcftEEwDVz3Cvfn7VWv+mRlfh+LfBBDJyUrwX4uhkMYr06kP+35NPIky8ZdETFb2VWDoMyg==","signatures":[{"sig":"MEUCIBylQV8GVrRCehsztBwjNwi/CMQ84AT1PIkkmIdzN8OtAiEAmdietfvAm03DIVahqbzO4jcPzWCAfKdzKc8TEKlnGSw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":56054},"main":"./dist/platform-config.js","type":"module","module":"./dist/platform-config.js","exports":{".":{"import":"./dist/platform-config.js","require":"./dist/platform-config.umd.cjs"}},"gitHead":"d377923e0bdb412ceba1adb3bb6061ad8ab2ca74","scripts":{"dev":"vite --host example.com","build":"vite build"},"_npmUser":{"name":"blueking","email":"contactus_bk@tencent.com"},"_npmVersion":"9.8.1","description":"获取及使用平台配置的方法","directories":{},"_nodeVersion":"18.18.0","dependencies":{"xss":"^1.0.15"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/platform-config_1.0.5_1723018370247_0.5844073359953093","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-05-22T10:10:20.311Z","modified":"2026-01-15T04:04:00.908Z","1.0.0":"2024-05-22T10:10:20.627Z","1.0.1":"2024-05-28T03:34:05.294Z","1.0.2":"2024-06-17T09:40:45.107Z","1.0.3":"2024-06-24T08:45:26.061Z","1.0.4":"2024-07-14T05:24:25.362Z","1.0.5":"2024-08-07T08:12:50.414Z"},"author":{"name":"bkfe"},"license":"MIT","description":"获取及使用平台配置的方法","maintainers":[{"email":"contactus_bk@tencent.com","name":"blueking-magicbox"}],"readme":"# platform-config\n\n获取及使用平台配置的方法\n\n# 安装\n\n```bash\nnpm install @blueking/platform-config\n```\n\n# 使用\n\n## 获取远程配置\n\n建议在所有数据请求之前，先请求远程配置（并且只请求一次），获取到配置之后写入到系统的store中，以便全局使用\n\n```js\nimport { getPlatformConfig } from '@blueking/platform-config'\n\nconst url = 'abc.example.com/base.js'\nconst defaults = { name: \"某某平台\", ..., version: 'v3.13.8' }\n\n// url，远程配置文件地址\n// defaults，默认配置及额外附加数据，如 version，当请求url配置失败时，会使用传入的默认配置\n// 返回值，参考配置字段说明\nconst config = await getPlatformConfig(url, defaults)\n\n// 获取到config之后，可以将config写入到store当中，方便之后在其它地方使用\n// commit('setConfig', config)\n```\n\n## 设置 favicon\n\n```js\nimport { setShortcutIcon } from '@blueking/platform-config';\n\n// 如果在其它页面中使用，可能需要从store取出config\n\n// 传入favicon地址即可，建议在获取远程配置之后就调用\nsetShortcutIcon(config.favicon);\n```\n\n## 设置 document.title\n\n```js\nimport { setDocumentTitle } from '@blueking/platform-config';\n\n// 1. 如果网页标题是不变的，同样在获取远程配置之后就调用\nsetDocumentTitle(config.i18n);\n\n// 2. 如果网页标题要动态加上当前页面的名称，将需要附加的内容作为第二个参数\nconst matchedNames = ['页面名称'];\nsetDocumentTitle(config.i18n, matchedNames);\n```\n\n## 使用 logo & name\n\n```html\n<!-- img 标签 -->\n<img :src=\"appLogo\" />{{ appName }}\n\n<!-- 样式背景 -->\n<div class=\"logo\">{{ appName }}</div>\n\n<style>\n  .logo {\n    ...\n    background: v-bind(appLogo) no-repeat 0 center;\n  }\n</style>\n```\n\n```js\n// 如果获取时未设置logo默认值，可以在这里处理\nimport logoSvg from 'xxx/logo.svg'\n\n...\ncomputed: {\n  ...mapGetters('globalConfig', ['config']),\n  appName() {\n    // 1.0.5 版本开始使用 productName\n    return this.config.i18n.productName\n  },\n  appLogo() {\n    // 如果未获取到配置，使用默认logo\n    const src = this.config.appLogo ?? logoSvg\n\n    // 如果是img标签，直接返回src\n    return src\n\n    // 如果是样式背景图\n    // return `url(${src})`\n  }\n}\n...\n```\n\n## 使用 footer\n\n```html\n<template>\n  <div class=\"footer\">\n    <p\n      class=\"contact\"\n      v-html=\"contact\"\n    ></p>\n    <p class=\"copyright\">{{copyright}}</p>\n  </div>\n</template>\n```\n\n```js\n...\ncomputed: {\n  ...mapGetters('globalConfig', ['config']),\n  contact() {\n    // 已处理 xss\n    return this.config.i18n.footerInfoHTML\n  },\n  copyright() {\n    return this.config.footerCopyrightContent\n  }\n}\n...\n```\n\n# 配置字段说明\n\n```json\n{\n  \"bkAppCode\": \"abc\", // appcode\n  \"name\": \"某某平台\", // 站点的名称，用于网页title中\n  \"nameEn\": \"AAA\", // 站点的名称-英文\n  \"appLogo\": \"http://abc.example.com.com/logo.svg\", // 站点logo\n  \"favicon\": \"http://abc.example.com/favicon.ico\", // 站点favicon\n  \"productName\": \"某某产品名称\", // 产品名称，展示在logo区域 1.0.5版本新增\n  \"productNameEn\": \"AAA\", // 产品名称-英文 1.0.5版本新增\n  \"helperText\": \"联系xxx\",\n  \"helperTextEn\": \"Contact xxx\",\n  \"helperLink\": \"超链接或IM协议地址\",\n  \"brandImg\": \"http://abc.example.com/brand.png\",\n  \"brandImgEn\": \"http://abc.example.com/brand.png\",\n  \"brandName\": \"某某公司\", // 品牌名，会用于拼接在站点名称后面显示在网页title中\n  \"brandNameEn\": \"CCC\", // 品牌名-英文\n  \"footerInfo\": \"[技术支持](https://xxx) | [社区论坛](https://bbb) | [产品官网](https://ccc/)\", // 页脚的内容，仅支持 a 的 markdown 内容格式\n  \"footerInfoEn\": \"[Support](https://xxx) | [Forum](https://ccc) | [Official](https:ddd)\", // 页脚的内容-英文\n  \"footerCopyright\": \"Copyright © 2012 xxx All Rights Reserved. {{version}}\", // 版本信息，包含 version 变量，展示在页脚内容下方\n\n  // 以下所有字段不存在于配置文件中，是通过调用getPlatformConfig方法后对源字段处理后附加的，用于在页面中使用\n  \"footerInfoHTML\": \"转换为HTML的页脚内容，已处理 xss，可以直接用于在页面中展示\",\n  \"footerInfoHTMLEn\": \"转换为HTML的页脚内容-英文\",\n  \"footerCopyrightContent\": \"替换完变量之后的版本信息，可以直接用于在页面中展示\",\n  // 需要国际化的字段，根据当前语言cookie自动匹配，页面中应该优先使用这里的字段\n  \"i18n\": {\n    \"name\": \"国际化对应的内容：某某平台或或其英文\",\n    \"productName\": \"国际化对应的内容：某某产品名称或其英文\", // 1.0.5版本新增\n    \"helperText\": \"...\",\n    \"brandImg\": \"...\",\n    \"brandName\": \"...\",\n    \"footerInfoHTML\": \"...\"\n  }\n}\n```\n","readmeFilename":"README.md"}