mirror of
https://gitee.com/bitdance-team/chrome-extension
synced 2025-10-07 16:35:15 +08:00
style
This commit is contained in:
4
packages/shell-chrome/assets/js/lib/axios.min.js
vendored
Normal file
4
packages/shell-chrome/assets/js/lib/axios.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
packages/shell-chrome/assets/js/lib/uuid.min.js
vendored
Normal file
1
packages/shell-chrome/assets/js/lib/uuid.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
43
packages/shell-chrome/assets/js/login.js
Normal file
43
packages/shell-chrome/assets/js/login.js
Normal file
@@ -0,0 +1,43 @@
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
username: "",
|
||||
password: ""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
if (!this.username || !this.password) {
|
||||
alert('账号和密码不能为空!')
|
||||
return
|
||||
}
|
||||
axios.post("https://qcmma8.app.cloudendpoint.cn/api/auth/login", {
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}).then(res => {
|
||||
window.close()
|
||||
}).catch(err => {
|
||||
if (err.response && err.response.data)
|
||||
alert(err.response.data.msg)
|
||||
else alert("请求失败!")
|
||||
})
|
||||
},
|
||||
register() {
|
||||
if (!this.username || !this.password) {
|
||||
alert('账号和密码不能为空!')
|
||||
return
|
||||
}
|
||||
axios.post("https://qcmma8.app.cloudendpoint.cn/api/auth/register", {
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}).then(res => {
|
||||
window.close()
|
||||
}).catch(err => {
|
||||
if (err.response && err.response.data)
|
||||
alert(err.response.data.msg)
|
||||
else alert("请求失败!")
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
17
packages/shell-chrome/assets/js/session.js
Normal file
17
packages/shell-chrome/assets/js/session.js
Normal file
@@ -0,0 +1,17 @@
|
||||
chrome.storage.sync.get('sessionid', function ({ sessionid }) {
|
||||
|
||||
if (!sessionid) {
|
||||
sessionid = uuid.v4()
|
||||
console.log(sessionid)
|
||||
chrome.storage.sync.set({
|
||||
'sessionid': sessionid
|
||||
});
|
||||
}
|
||||
|
||||
axios.defaults.headers.common['x-tt-session-v2'] = sessionid
|
||||
|
||||
if (typeof sessionCb === 'function') {
|
||||
sessionCb()
|
||||
}
|
||||
})
|
||||
|
42
packages/shell-chrome/assets/js/todos.js
Normal file
42
packages/shell-chrome/assets/js/todos.js
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
let app = new Vue({
|
||||
data() {
|
||||
return {
|
||||
todos: [],
|
||||
todoForm: "",
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadTodos () {
|
||||
axios.get("https://qcmma8.app.cloudendpoint.cn/api/memos?pageSize=100").then(res => {
|
||||
this.todos = res.data.content
|
||||
})
|
||||
},
|
||||
createTodo () {
|
||||
if (!this.toDoForm.trim()) {
|
||||
alert('内容不能为空')
|
||||
return
|
||||
}
|
||||
axios.post("https://qcmma8.app.cloudendpoint.cn/api/memos", { content: this.toDoForm }).then(() => {
|
||||
alert('添加成功!')
|
||||
this.loadTodos()
|
||||
this.toDoForm = ""
|
||||
})
|
||||
},
|
||||
removeTodo(id) {
|
||||
axios.delete(`https://qcmma8.app.cloudendpoint.cn/api/memos/${id}`, {
|
||||
content: this.toDoForm
|
||||
}).then(() => {
|
||||
alert('删除成功!')
|
||||
this.loadTodos()
|
||||
})
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
this.loadTodos()
|
||||
}
|
||||
})
|
||||
|
||||
function sessionCb() {
|
||||
app.$mount('#app')
|
||||
}
|
Reference in New Issue
Block a user