@mgcloud/lib-base
v1.1.0
Published
提供了一些基础功能和工具的封装。
Downloads
5
Readme
🚀 @mgcloud/lib-base
提供了一些基础功能和工具的封装。
- request: 简化的网络请求功能
- security: 前端安全 (防止 XSS 攻击)
使用示例
import { ref } from 'vue'
import { request, xssFilter } from '@mgcloud/lib-base'
interface LoginByCodesTypes {
code: string
mobile: string
}
interface LoginByCodesResultTypes {
token: string
}
export function loginByCodesApi(data: LoginByCodesTypes) {
return request<LoginByCodesResultTypes>({
baseURL: '/api',
url: `/user/loginByCodes`,
method: 'post',
data,
})
}
const xssHtml = ref(
`
<h1 id="title">XSS Demo</h1>
<p class="text-center">
Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist.
</p>
<form>
<input type="text" name="q" value="test">
<button id="submit">Submit</button>
</form>
<pre>hello</pre>
<p>
<a href="http://jsxss.com">http</a>
<a href="https://jsxss.com">https</a>
<a href="ftp://jsxss.com">ftp</a>
<a href="other1">other1</a>
<a href="/other2">other2</a>
<a href="#">other3</a>
</p>
<h3 style="color: #fff;">Features:</h3>
<ul>
<li>Specifies HTML tags and their attributes allowed with whitelist</li>
<li>Handle any tags or attributes using custom function</li>
</ul>
<script type="text/javascript">
alert(/xss/);
<\/script>
`,
)
console.log(xssFilter(xssHtml.value))