中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

響應(yīng)式網(wǎng)站建站seo初學(xué)教程

響應(yīng)式網(wǎng)站建站,seo初學(xué)教程,長(zhǎng)沙做網(wǎng)站建設(shè)的,什么樣的網(wǎng)站可以做站內(nèi)站注意:以下代碼使用 typeScript 開(kāi)發(fā),如果想在 js 中使用,可參考 npm 已經(jīng)發(fā)布的包:https://www.npmjs.com/package/uni-easy-file NPM 使用 如果想直接在 npm 項(xiàng)目中使用可以直接執(zhí)行以下命令 npm i uni-easy-file然后直接使用 …

注意:以下代碼使用 typeScript 開(kāi)發(fā),如果想在 js 中使用,可參考 npm 已經(jīng)發(fā)布的包:https://www.npmjs.com/package/uni-easy-file

NPM 使用

如果想直接在 npm 項(xiàng)目中使用可以直接執(zhí)行以下命令

npm i uni-easy-file

然后直接使用

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

項(xiàng)目源碼

參考 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;}/*** 獲取文件名(包括擴(kuò)展名)** ```* 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()!;}/*** 獲取文件擴(kuò)展名** ```* 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()!;}/*** 獲取文件主名(不包括擴(kuò)展名)** ```* 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 類型數(shù)組* @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);}/*** 獲取文件臨時(shí)地址* @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);},});});}/*** 打開(kāi)文件** 根據(jù)文件類型調(diào)用不同的api打開(kāi)文件* - 圖片類文件調(diào)用預(yù)覽圖片(uni.previewImage)* - office及pdf類型文件調(diào)用打開(kāi)文檔(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);})});}/*** 根據(jù)臨時(shí)地址打開(kāi)文件** 根據(jù)文件類型調(diào)用不同的api打開(kāi)文件* - 圖片類文件調(diào)用預(yù)覽圖片(uni.previewImage)* - office及pdf類型文件調(diào)用打開(kāi)文檔(uni.openDocument)* - 其他類型不支持* @param {string} tempPath 文件臨時(shí)地址* @return {Promise<unknown>}*/async openFileByTempPath(tempPath: string): Promise<unknown> {return new Promise(async (resolve, reject) => {if (!tempPath) {reject('文件地址為空');return;}if (this.isImage(tempPath)) {// 調(diào)用微信api預(yù)覽圖片uni.previewImage({// 開(kāi)啟時(shí)右上角會(huì)有三點(diǎn),點(diǎn)擊可以保存showMenu: true,urls: [tempPath],current: tempPath,success: (res) => {resolve(res);},fail: (res) => {reject(res);}});} else if (this.isOfficeOrPdf(tempPath)) {uni.openDocument({filePath: tempPath,// 開(kāi)啟時(shí)右上角會(huì)有三點(diǎn),點(diǎn)擊可以保存showMenu: true,success: (res) => {resolve(res);},fail: (res) => {reject(res);}});}});}/*** 獲取文件 MD5** 僅獲取文件 MD5 時(shí)建議使用此方法,如果同時(shí)獲取文件大小,建議直接使用 `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 時(shí)建議使用此方法,如果同時(shí)獲取文件大小,建議直接使用 `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);},});});}/*** 獲取文件大小,以字節(jié)為單位** 僅獲取文件大小時(shí)建議使用此方法,如果同時(shí)獲取文件摘要,建議直接使用 `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://www.risenshineclean.com/news/40847.html

相關(guān)文章:

  • 煙臺(tái)微信網(wǎng)站建設(shè)網(wǎng)站搜索優(yōu)化
  • 懷化市建設(shè)局門戶網(wǎng)站網(wǎng)絡(luò)營(yíng)銷推廣平臺(tái)
  • 定制型網(wǎng)站開(kāi)發(fā)2345網(wǎng)址導(dǎo)航智能主板
  • 商丘哪里做網(wǎng)站百度收錄提交入口網(wǎng)址
  • dede網(wǎng)站打開(kāi)速度慢如何優(yōu)化seo關(guān)鍵詞
  • 百度如何搜索到自己的網(wǎng)站網(wǎng)站綜合查詢工具
  • 鄭州電商網(wǎng)站開(kāi)發(fā)港港網(wǎng)app下載最新版
  • angular2是做網(wǎng)站的還是手機(jī)的seo排名的公司
  • app運(yùn)營(yíng)流程上海外貿(mào)seo公司
  • 樂(lè)清網(wǎng)站建設(shè)網(wǎng)站建設(shè)網(wǎng)站的宣傳與推廣
  • 旅游景區(qū)網(wǎng)站源碼個(gè)人網(wǎng)站設(shè)計(jì)成品
  • 建c2c網(wǎng)站費(fèi)用拉新推廣賺錢的app
  • 浙江網(wǎng)站建設(shè)企業(yè)軟文類型
  • 免費(fèi)做的網(wǎng)站怎么設(shè)置域名京津冀協(xié)同發(fā)展
  • 營(yíng)銷加盟網(wǎng)站建設(shè)網(wǎng)站維護(hù)是什么意思
  • erp定制開(kāi)發(fā)價(jià)格澳門seo關(guān)鍵詞排名
  • 做網(wǎng)站阿里云買哪個(gè)服務(wù)器好點(diǎn)汽車推廣軟文
  • 長(zhǎng)沙制作網(wǎng)頁(yè)網(wǎng)站杭州網(wǎng)絡(luò)
  • 一品威客網(wǎng)怎么樣seo免費(fèi)優(yōu)化網(wǎng)站
  • win7iis配置網(wǎng)站百度搜索引擎網(wǎng)址
  • 整站優(yōu)化網(wǎng)站報(bào)價(jià)公司網(wǎng)站建設(shè)全包
  • 網(wǎng)站開(kāi)發(fā)團(tuán)隊(duì)取什么名字好怎么引流怎么推廣自己的產(chǎn)品
  • 長(zhǎng)春怎么做網(wǎng)站建站流程新手搭建網(wǎng)站第一步
  • 商城網(wǎng)站開(kāi)發(fā)教程視頻北京網(wǎng)絡(luò)營(yíng)銷推廣
  • 歐美設(shè)計(jì)網(wǎng)站推薦app拉新平臺(tái)哪個(gè)好傭金高
  • 密云做網(wǎng)站的產(chǎn)品關(guān)鍵詞大全
  • 建站行業(yè)的利潤(rùn)百度指數(shù)里的資訊指數(shù)是什么
  • 不銹鋼公司網(wǎng)站源碼 網(wǎng)站建設(shè) 產(chǎn)品3級(jí)分類asp源碼域名查詢注冊(cè)商
  • 360度全景街景地圖陽(yáng)江seo
  • 北京營(yíng)銷型網(wǎng)站建設(shè)培訓(xùn)百度怎么優(yōu)化網(wǎng)站關(guān)鍵詞