提交 8c1f89dd 编写于 作者: B baiy 提交者: ninecents

移除短连接生成代码

上级 0bb31b84
......@@ -6,32 +6,22 @@
"offline_enabled": true,
"homepage_url": "https://github.com/baiy/Ctool",
"manifest_version": 2,
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://www.baiy.org; object-src 'self'",
"browser_action": {
"default_icon": "img/icon_chrome.png",
"default_icon": "img/icon128.png",
"default_title": "常用开发工具",
"default_popup": "index.html"
},
"default_locale": "zh_CN",
"background": {
"scripts": ["background.js"]
},
"options_page": "setting.html",
"icons": {
"16": "img/icon_chrome.png",
"48": "img/icon_chrome.png",
"128": "img/icon_chrome.png"
"16": "img/icon128.png",
"48": "img/icon128.png",
"128": "img/icon128.png"
},
"permissions": [
"clipboardWrite",
"clipboardRead",
"*://get.geojs.io/*",
"*://*.baiy.org/*"
"storage"
],
"commands": {
"panel": {
"description": "打开独立工具窗口",
"global": true
}
},
"update_url": "http://clients2.google.com/service/update2/crx"
}
}
\ No newline at end of file
......@@ -21,18 +21,10 @@
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Checkbox v-model="current.generateIsShort">生成短连接</Checkbox>
</FormItem>
<FormItem v-if="current.generateIsShort">
<Alert>短链接API由 t.cn 提供</Alert>
</FormItem>
</option-block>
</Col>
<Col span="10">
<div style="text-align: center" v-html="current.generateOutput"></div>
<p style="text-align: center" v-if="current.generateIsShort && current.generateShortUrl">
短连接:{{current.generateShortUrl}}</p>
</Col>
</Row>
</TabPane>
......@@ -135,36 +127,14 @@
}
let history = this.generateHistory.getValue(index)
this.current.generateInput = history.input
this.current.generateIsShort = history.isShort
this.generate(false)
},
generate (insertHistory = true) {
if (!this.current.generateInput) return
if (this.current.generateIsShort) {
if (!isUrl(this.current.generateInput)) {
return this.$Message.error('生成短连接的内容是url')
}
request({
url: 'http://api.t.sina.com.cn/short_url/shorten.json',
data: { 'source': '2815391962', 'url_long': this.current.generateInput },
}, (err, res, result) => {
if (err) return this.$Message.error('二维码短连接生成错误:' + err)
result = JSON.parse(result)
if (!result[0]['url_short']) {
return this.$Message.error('短连接生成错误')
} else {
this.current.generateShortUrl = result[0]['url_short']
this.generateHandle(this.current.generateShortUrl)
}
})
} else {
this.current.generateShortUrl = ''
this.generateHandle(this.current.generateInput)
}
this.generateHandle(this.current.generateInput)
if (insertHistory) {
this.generateHistory.push({
input: this.current.generateInput,
isShort: this.current.generateIsShort,
input: this.current.generateInput
})
}
this.$saveToolData(this.current)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册