Commit c13d8494 authored by wildfirecode13's avatar wildfirecode13

1

parent 8f4efc6d
node_modules
docs
\ No newline at end of file
# teddi-tb
# 安装
```bash
npm i git+ssh://git@gitlab2.dui88.com:wanghongyuan/teddi.git --save
```
# 使用
```js
import { Countdown } from "teddi";
class Pageindex extends Component {
componentDidMount() {
const countdwon = new Countdown("剩余时间:{0}", 3600, "hhmmss");
countdwon.on("update", this.onTimer, this);
countdwon.start();
}
onTimer(data) {
console.log(data);
this.setState({ text: data });
}
}
export default Pageindex;
```
# 功能
- 防连点
- svga
- 时间相关
- net
# 防连点
js
```js
import {debounce } from "teddi";
```
html
```html
<button onClick={debounce(clickHandler)}></button>
or
<button onClick={debounce(clickHandler,3000)}></button>
```
[了解更多,请点击查看API](./globals.html#debounce)
# svga
## 快速装载一个svga动画
加载一个循环播放的动画,比如角色待机动画。
html
```html
<div className="svga-placeholder" ></div>
```
js
```js
import {getSVGA } from "teddi";
const url = '';
getSVGA(url, 'svga-placeholder');
```
加载一个动画,它只播放一次,监听播放完成事件。一般用于角色动作切换。
html
```html
<div className="svga-placeholder" ></div>
```
js
```js
import {getSVGA} from "teddi";
const url = '';
const svga = await getSVGA(url, 'svga-placeholder',1);//加载动画
svga.startAnimation();
svga.onFinished(() => {
//单次动作播放完成,此时可以切回待机状态
});
```
[了解更多,请点击查看API](./globals.html#getsvga)
## 快速加载svga资源,但不装载
js
```js
import {loadSVGA } from "teddi";
const url = '';
const videoItem = await loadSVGA(url);
```
[了解更多,请点击查看API](./globals.html#loadsvga)
# net
## 获取星速台token
星速台相关工具,需要先引入。注意:如果是本地化项目需要定制px-token.min.js。
```html
<script src="getTokenKey"></script>
<script src="//yun.duiba.com.cn/js-libs/px-token/0.0.4/px-token.min.js"></script>
```
用法
```js
import {getPxToken } from "teddi";
const token = await getPxToken();
const result = await API.doSign({token});
```
export declare const getLocalCacheTb: (key: string) => boolean;
export declare const setLocalCacheTb: (key: string) => any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setLocalCacheTb = exports.getLocalCacheTb = void 0;
var teddi_1 = require("teddi");
exports.getLocalCacheTb = function (key) {
if (my) {
return my.getStorageSync({ key: key }).data == "1";
}
return teddi_1.getLocalCache(key);
};
exports.setLocalCacheTb = function (key) {
if (my) {
return my.setStorageSync({
key: key,
data: "1"
});
;
}
return teddi_1.setLocalCache(key);
};
export * from "./cache";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./cache"), exports);
const gulp = require('gulp')
const typedoc = require('gulp-typedoc')
const browserSync = require('browser-sync').create()
const runTypeDoc = () => gulp
.src(['src'])
.pipe(typedoc({
out: './docs',
mode:'file',
exclude: '**/*/index.ts',
tsconfig: 'tsconfig.json',
}))
const reload = (done) => {
browserSync.reload()
done()
}
const runBrowserSync = (done) => {
browserSync.init({
server: {
baseDir: './docs',
},
})
done()
}
const watch = () => gulp.watch(
['README.md', 'src/*.ts'],
gulp.series(runTypeDoc, reload)
)
gulp.task('watch', gulp.series(runTypeDoc, runBrowserSync, watch))
gulp.task('build', gulp.series(runTypeDoc))
\ No newline at end of file
{
"name": "teddi-tb",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"svgaplayerweb": {
"version": "2.3.1",
"resolved": "http://npm.dui88.com:80/svgaplayerweb/-/svgaplayerweb-2.3.1.tgz",
"integrity": "sha1-Au3BavFiCvn1dKU254E/wlE55Hs="
},
"teddi": {
"version": "git+ssh://git@gitlab2.dui88.com:wanghongyuan/teddi.git#004b955bbe5aa504770141fcaf28f2211afcd5c7",
"from": "git+ssh://git@gitlab2.dui88.com:wanghongyuan/teddi.git",
"requires": {
"svgaplayerweb": "^2.3.1"
}
}
}
}
{
"name": "teddi-tb",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"doc": "gulp build",
"watch": "gulp watch",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gitlab2.dui88.com:wildfirecode13/teddi-tb.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"teddi": "git+ssh://git@gitlab2.dui88.com:wanghongyuan/teddi.git"
},
"devDependencies": {
"browser-sync": "^2.26.13",
"gulp": "^4.0.2",
"gulp-typedoc": "^2.2.5",
"typedoc": "^0.19.2",
"typescript": "^4.0.5"
}
}
import { getLocalCache, setLocalCache } from "teddi";
export const getLocalCacheTb = (key:string) => {
if(my) {
return my.getStorageSync({ key: key }).data == "1";
}
return getLocalCache(key)
}
export const setLocalCacheTb = (key:string) => {
if(my) {
return my.setStorageSync({
key: key,
data: "1"
});;
}
return setLocalCache(key)
}
\ No newline at end of file
declare var my:any;
\ No newline at end of file
export * from "./cache";
{
"compilerOptions": {
"noImplicitAny": true,
"target": "es5",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"declarationDir": "./dist",
"strict": true,
"lib": [
"DOM",
"ES2015",
]
},
"exclude": [
"node_modules",
"dist",
"types"
]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment