雲開發(小程式端,web端 部落格搭建部署)

2022-05-15 05:08:51 字數 2677 閱讀 2794

雲函式

const cloud = require("wx-server-sdk");

cloud.init();

const db = cloud.database();

const todo = db.collection("test");

// 雲函式入口函式

exports.main = async (event, context) => ,

}).then((res) => );

};

小程式端呼叫雲函式

data: ,

primary:function()

}).then(res => )

console.log(res)

})},

//獲取臨時檔案路徑

choosemessagefile())

console.log('選擇檔案之後的files', tempfilepaths)}})

},// 將臨時檔案上傳到雲儲存指定雲檔案裡

uploadfiles(e) -$` + filepath.match(/\.[^.]+?$/)

wx.cloud.uploadfile().then(res => ).catch(error => )

},

小程式端檢視層

primary

環境準備

雲函式

安裝 cli 工具npm i -g @cloudbase/cli

cloudbase 命令可以簡寫成 tcb

檢視版本tcb -v

嘗試登陸tcb login

檢視函式列表tcb functions:list

functions:code:update命令和functions:deploy命令的主要區別是:functions:code:update命令只會更新函式的**以及執行入口,不會修改函式的其他配置,而functions:deploy命令則會修改函式的**、配置

雲儲存

上傳檔案cloudbase storage:upload localpath cloudpath,當 cli 檢測到 localpath 為資料夾時,會自動上傳檔案內的所有檔案。

刪除檔案cloudbase storage:delete cloudpath,刪除資料夾cloudbase storage:delete cloudpath --dir

檔案列表cloudbase storage:list cloudpath

獲取檔案訪問鏈結cloudbase storage:url cloudpath

獲取檔案詳細資訊cloudbase storage:detail cloudpath

檢視許可權cloudbase storage:get-acl,設定許可權cloudbase storage:set-acl

呼叫雲函式

需要起乙個服務在根目錄下npx serverhttp-server

env: "web-d68cb1",

});.auth()

.signinanonymously()

.then(() => );

.callfunction()

.then((res) => );

async function login() )

.signin();}}

資料庫操作

const collection = db.collection("file");

collection

.add()

.then((res) => );

檔案操作

filelist: [

"cloud:",

],}).then((res) => else

});});

部署 hugo

生成乙個部落格站點hugo new site myblog

在 config.toml 檔案中新增以下行:

baseurl = ""

languagecode = "en-us"

title = "my new hugo site"

theme = "m10c"

本地啟動hugo server -d

新建一篇文章hugo new post/blog.md

部署到雲端

cloudbase hosting:deploy ./public -e web-d68cb1

移動端web開發的小筆記

移動端的開發跟pc端的開發還是稍有區別的,以下內容是個人移動開發的經驗,後期會不定時更新錯誤以及新的內容 一 從meta標籤說起 首先,在移動端,我們希望將頁面視窗自動調整到裝置寬度,需要的meta標籤是這樣 name viewport content width device width,init...

移動端web開發

viewport content width device width,user scalable no,initial scale 1.0,maximum scale 1.0,minimum scale 1.0 width 設定視口寬度 initial scale 初始化縮放比,大於0的數字 ma...

移動端Web開發

移動端web開發與pc端的web開發有尺寸上的不同,手機螢幕大小有很多種,因此尺寸方面有些要注意的。1.字型 採用js動態設定字型大小的方法 思路如下 螢幕寬度 640px,則font size 100px 螢幕寬度 640px,則font size 100 寬度 640px 字型單位為rem 在b...