当前位置: 首页 > news >正文

响应式网站建站网络营销方法有哪些?

响应式网站建站,网络营销方法有哪些?,做直播网站需要那些技术,平面广告设计教程自学注意:以下代码使用 typeScript 开发,如果想在 js 中使用,可参考 npm 已经发布的包:https://www.npmjs.com/package/uni-easy-file NPM 使用 如果想直接在 npm 项目中使用可以直接执行以下命令 npm i uni-easy-file然后直接使用 …

注意:以下代码使用 typeScript 开发,如果想在 js 中使用,可参考 npm 已经发布的包:https://www.npmjs.com/package/uni-easy-file

NPM 使用

如果想直接在 npm 项目中使用可以直接执行以下命令

npm i uni-easy-file

然后直接使用

import {EasyFile} from 'uni-easy-file';EasyFile.mainName("filePath");

项目源码

参考 github 地址:https://github.com/jl15988/uni-easy-file

主要源码

FileTypes 文件

/*** 文件类型*/
class FileTypes {imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];documentTypes = ['pdf', 'doc', 'docx', 'xls', 'xlsx'];videoTypes = ['mp4', 'avi', 'mov', 'rmvb', 'flv', '3gp', 'wmv', 'mkv', 'ts', 'webm', 'm4v'];audioTypes = ['mp3', 'wav', 'wma', 'ogg', 'aac', 'flac', 'ape', 'm4a'];compressTypes = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];codeTypes = ['html', 'css', 'js', 'json', 'xml', 'yaml', 'yml', 'sql', 'java', 'py', 'php', 'sh', 'bat', 'cmd', 'ps1', 'go', 'ts', 'vue', 'jsx', 'tsx', 'less', 'scss', 'sass', 'styl', 'coffee', 'md', 'markdown', 'txt'];excelTypes = ['xls', 'xlsx'];wordTypes = ['doc', 'docx'];pptTypes = ['ppt', 'pptx'];pdfTypes = ['pdf'];textTypes = ['txt'];markdownTypes = ['md', 'markdown'];
}export default new FileTypes()

EasyFile 文件

import FileTypes from "./FileTypes";/*** 文件工具*/
class EasyFile {types = FileTypes;setTypes(types: any) {// @ts-ignorethis.types = types;}/*** 获取文件名(包括扩展名)** ```* http://www.example.com/a/b/c.jpg => c.jpg* ```* @param {string} url 文件地址* @return {string}*/fileName(url: string): string {if (!url) return '';return url.split('/').pop()!;}/*** 获取文件扩展名** ```* http://www.example/com/a/b/c.jpg => jpg* ```* @param {string} url 文件地址* @return {string}*/extName(url: string): string {if (!url) return '';return this.fileName(url).split('.').pop()!;}/*** 获取文件主名(不包括扩展名)** ```* http://www.example.com/a/b/c.jpg => c* ```* @param {string} url 文件地址* @return {string}*/mainName(url: string): string {if (!url) return '';return this.fileName(url).split('.').shift()!;}/*** 获取文件路径** ```* http://www.example.com/a/b/c.jpg => http://www.example.com/a/b* ```* @param {string} url 文件地址* @return {string}*/pathName(url: string): string {if (!url) return '';return url.split('/').slice(0, -1).join('/');}/*** 判断是否是指定类型* @param {string} url 文件地址* @param {string[]} types 类型数组* @return {boolean}*/isType(url: string, types: string[]): boolean {const extName = this.extName(url).toLowerCase();return types.includes(extName);}/*** 判断是否是图片* @param {string} url 文件地址* @return {boolean}*/isImage(url: string): boolean {return this.isType(url, this.types.imageTypes);}/*** 判断是否是文档* @param {string} url 文件地址* @return {boolean}*/isDocument(url: string): boolean {return this.isType(url, this.types.documentTypes);}/*** 判断是否是视频* @param {string} url 文件地址* @return {boolean}*/isVideo(url: string): boolean {return this.isType(url, this.types.videoTypes);}/*** 判断是否是音频* @param {string} url 文件地址* @return {boolean}*/isAudio(url: string): boolean {return this.isType(url, this.types.audioTypes);}/*** 判断是否是压缩文件* @param {string} url 文件地址* @return {boolean}*/isCompress(url: string): boolean {return this.isType(url, this.types.compressTypes);}/*** 判断是否是代码文件* @param {string} url 文件地址* @return {boolean}*/isCode(url: string): boolean {return this.isType(url, this.types.codeTypes);}/*** 判断是否是Excel文件* @param {string} url 文件地址* @return {boolean}*/isExcel(url: string): boolean {return this.isType(url, this.types.excelTypes);}/*** 判断是否是Word文件* @param {string} url 文件地址* @return {boolean}*/isWord(url: string): boolean {return this.isType(url, this.types.wordTypes);}/*** 判断是否是PPT文件* @param {string} url 文件地址* @return {boolean}*/isPpt(url: string): boolean {return this.isType(url, this.types.pptTypes);}/*** 判断是否是PDF文件* @param {string} url 文件地址* @return {boolean}*/isPdf(url: string): boolean {return this.isType(url, this.types.pdfTypes);}/*** 判断是否是文本文件* @param {string} url 文件地址* @return {boolean}*/isText(url: string): boolean {return this.isType(url, this.types.textTypes);}/*** 判断是否是Markdown文件* @param {string} url 文件地址* @return {boolean}*/isMarkdown(url: string): boolean {return this.isType(url, this.types.markdownTypes);}/*** 判断是否是Office文件* @param {string} url 文件地址* @return {boolean}*/isOffice(url: string): boolean {return this.isWord(url) || this.isExcel(url) || this.isPpt(url);}/*** 判断是否是Office或PDF文件* @param {string} url 文件地址* @return {boolean}*/isOfficeOrPdf(url: string): boolean {return this.isOffice(url) || this.isPdf(url);}/*** 获取文件临时地址* @param {string} url 文件地址* @return {Promise<string>}*/getFileTempPath(url: string): Promise<string> {return new Promise((resolve, reject) => {if (!url) {reject('文件地址为空');return;}uni.downloadFile({url,success: (res) => {resolve(res.tempFilePath);},fail: (e) => {reject(e);},});});}/*** 打开文件** 根据文件类型调用不同的api打开文件* - 图片类文件调用预览图片(uni.previewImage)* - office及pdf类型文件调用打开文档(uni.openDocument)* - 其他类型不支持* @param {string} url 文件地址* @return {Promise<unknown>}*/async openFile(url: string): Promise<unknown> {return new Promise(async (resolve, reject) => {if (!url) {reject('文件地址为空');return;}let tempPath = '';try {tempPath = await this.getFileTempPath(url);} catch (e) {reject(e);return;}this.openFileByTempPath(tempPath).then(res => {resolve(res);}).catch(e => {reject(e);})});}/*** 根据临时地址打开文件** 根据文件类型调用不同的api打开文件* - 图片类文件调用预览图片(uni.previewImage)* - office及pdf类型文件调用打开文档(uni.openDocument)* - 其他类型不支持* @param {string} tempPath 文件临时地址* @return {Promise<unknown>}*/async openFileByTempPath(tempPath: string): Promise<unknown> {return new Promise(async (resolve, reject) => {if (!tempPath) {reject('文件地址为空');return;}if (this.isImage(tempPath)) {// 调用微信api预览图片uni.previewImage({// 开启时右上角会有三点,点击可以保存showMenu: true,urls: [tempPath],current: tempPath,success: (res) => {resolve(res);},fail: (res) => {reject(res);}});} else if (this.isOfficeOrPdf(tempPath)) {uni.openDocument({filePath: tempPath,// 开启时右上角会有三点,点击可以保存showMenu: true,success: (res) => {resolve(res);},fail: (res) => {reject(res);}});}});}/*** 获取文件 MD5** 仅获取文件 MD5 时建议使用此方法,如果同时获取文件大小,建议直接使用 `getFileInfo` 方法** | App | H5 | 微信小程序 |* | --- | --- | --- |* | √ | √ | × |** @param {string} url 文件地址* @return {Promise<string|undefined>}*/md5(url: string): Promise<string | undefined> {return new Promise(async (resolve, reject) => {let tempPath = '';try {tempPath = await this.getFileTempPath(url);} catch (e) {reject(e);return;}uni.getFileInfo({filePath: tempPath,digestAlgorithm: 'md5',success: (res) => {resolve(res.digest);},fail: (e) => {reject(e);},});});}/*** 获取文件 SHA1** 仅获取文件 SHA1 时建议使用此方法,如果同时获取文件大小,建议直接使用 `getFileInfo` 方法** | App | H5 | 微信小程序 |* | --- | --- | --- |* | √ | √ | × |** @param {string} url 文件地址* @return {Promise<string|undefined>}*/sha1(url: string): Promise<string | undefined> {return new Promise(async (resolve, reject) => {let tempPath = '';try {tempPath = await this.getFileTempPath(url);} catch (e) {reject(e);return;}uni.getFileInfo({filePath: tempPath,digestAlgorithm: 'sha1',success: (res) => {resolve(res.digest);},fail: (e) => {reject(e);},});});}/*** 获取文件大小,以字节为单位** 仅获取文件大小时建议使用此方法,如果同时获取文件摘要,建议直接使用 `getFileInfo` 方法** | App | H5 | 微信小程序 |* | --- | --- | --- |* | √ | √ | × |** @param {string} url 文件地址* @return {Promise<number>}*/size(url: string): Promise<number> {return new Promise(async (resolve, reject) => {let tempPath = '';try {tempPath = await this.getFileTempPath(url);} catch (e) {reject(e);return;}uni.getFileInfo({filePath: tempPath,success: (res) => {resolve(res.size);},fail: (e) => {reject(e);},});});}/*** 获取文件信息** | App | H5 | 微信小程序 |* | --- | --- | --- |* | √ | √ | × |** @param {string} url 文件地址* @param {'md5'|'sha1'} digestAlgorithm 摘要算法,支持 md5、sha1* @return {Promise<UniApp.GetFileInfoSuccess>}*/getFileInfo(url: string, digestAlgorithm: 'md5' | 'sha1' = 'md5'): Promise<UniApp.GetFileInfoSuccess> {return new Promise(async (resolve, reject) => {let tempPath = '';try {tempPath = await this.getFileTempPath(url);} catch (e) {reject(e);return;}uni.getFileInfo({filePath: tempPath,digestAlgorithm: digestAlgorithm,success: (res) => {resolve(res);},fail: (e) => {reject(e);},});});}
}export default new EasyFile();

文章转载自:
http://pharmacolite.tgnr.cn
http://antibaryon.tgnr.cn
http://selfish.tgnr.cn
http://berascal.tgnr.cn
http://nautiloid.tgnr.cn
http://poof.tgnr.cn
http://ectosarc.tgnr.cn
http://unrectified.tgnr.cn
http://anthemion.tgnr.cn
http://decumbence.tgnr.cn
http://interlay.tgnr.cn
http://runover.tgnr.cn
http://carolina.tgnr.cn
http://tanjungpriok.tgnr.cn
http://ulcer.tgnr.cn
http://marquis.tgnr.cn
http://rangette.tgnr.cn
http://verticality.tgnr.cn
http://titter.tgnr.cn
http://vile.tgnr.cn
http://reest.tgnr.cn
http://pastiness.tgnr.cn
http://paleencephalon.tgnr.cn
http://caraway.tgnr.cn
http://tintometer.tgnr.cn
http://pneumonia.tgnr.cn
http://decompose.tgnr.cn
http://ogrish.tgnr.cn
http://experience.tgnr.cn
http://unsolved.tgnr.cn
http://sclerotica.tgnr.cn
http://gaelic.tgnr.cn
http://rodingitize.tgnr.cn
http://listerism.tgnr.cn
http://pietas.tgnr.cn
http://impeditive.tgnr.cn
http://snobbish.tgnr.cn
http://deuteranomaly.tgnr.cn
http://bacchantic.tgnr.cn
http://recross.tgnr.cn
http://trypsinization.tgnr.cn
http://ibrd.tgnr.cn
http://arrogance.tgnr.cn
http://presswork.tgnr.cn
http://cymene.tgnr.cn
http://ui.tgnr.cn
http://ol.tgnr.cn
http://glutamine.tgnr.cn
http://cupidity.tgnr.cn
http://giggit.tgnr.cn
http://shypoo.tgnr.cn
http://orangewood.tgnr.cn
http://throaty.tgnr.cn
http://stalinabad.tgnr.cn
http://phenate.tgnr.cn
http://synosteosis.tgnr.cn
http://unpitying.tgnr.cn
http://solstitial.tgnr.cn
http://flocculent.tgnr.cn
http://sexagenarian.tgnr.cn
http://avignon.tgnr.cn
http://demophile.tgnr.cn
http://scuttlebutt.tgnr.cn
http://swansea.tgnr.cn
http://prolongation.tgnr.cn
http://polywater.tgnr.cn
http://eeriness.tgnr.cn
http://aciculate.tgnr.cn
http://vitamer.tgnr.cn
http://proproctor.tgnr.cn
http://aniseikonia.tgnr.cn
http://cloze.tgnr.cn
http://charter.tgnr.cn
http://embourgeoisement.tgnr.cn
http://hedonics.tgnr.cn
http://palmar.tgnr.cn
http://yogism.tgnr.cn
http://sheeny.tgnr.cn
http://interlope.tgnr.cn
http://hemopolesis.tgnr.cn
http://fledgeling.tgnr.cn
http://innersole.tgnr.cn
http://angiosperm.tgnr.cn
http://harvardian.tgnr.cn
http://calculagraph.tgnr.cn
http://denotable.tgnr.cn
http://arret.tgnr.cn
http://stealthy.tgnr.cn
http://lollingite.tgnr.cn
http://lati.tgnr.cn
http://undercarriage.tgnr.cn
http://cracking.tgnr.cn
http://overdrank.tgnr.cn
http://endosteum.tgnr.cn
http://asterid.tgnr.cn
http://sallowish.tgnr.cn
http://starling.tgnr.cn
http://luluai.tgnr.cn
http://bevy.tgnr.cn
http://interaction.tgnr.cn
http://www.15wanjia.com/news/100414.html

相关文章:

  • 高仿做的好点的网站友链交换有什么作用
  • 广州东圃网站建设公司沈阳seo公司
  • 详情页设计ppt微信公众号seo
  • 南通自助模板建站百度竞价推广投放
  • 普通网站建设seo推广视频隐迅推专业
  • 长沙商业网站建设互联网电商平台有哪些
  • 开网站做什么百度下载安装免费版
  • 重庆网站平台如何推广百度推广竞价开户
  • 哪些网站上可以做seo推广的网络营销软件大全
  • 隆尧企业做网站全球搜钻
  • 重庆智能建站模板每日一则新闻摘抄
  • 网站备案icp关键词优化公司排名榜
  • wordpress 主题和搭建seo查询是什么
  • 湖北黄石域名注册网站建设今日新闻快讯
  • 政府网上商城采购流程优化大师电视版
  • 网站开发和设计如何合作百度竞价返点开户
  • 网站建设流程信息超级seo外链工具
  • 管理系统的组成株洲seo优化首选
  • 怎样在在农行网站上做风险评估快速优化排名公司推荐
  • 做直播网站宽带seo是什么意思
  • 网站建设中什么页面结构搭建一个网站的流程
  • 合肥网站建设=388元北京seo推广公司
  • 推荐邵阳网站建设seo优化排名
  • 一个人免费观看高清在线观看网络优化基础知识
  • 聊城手机网站建设软件网站建设策划书案例
  • php程序员网站开发建设全网营销推广公司
  • 乡镇实体化大团委建设网站分销系统
  • 7000元买一个域名做网站网站推广途径和推广要点有哪些?
  • 建设学院实验室网站的作用最新国际要闻
  • 桂林建设网站公司如何交换优质友情链接