mirror of
				https://github.com/linux-do/new-api.git
				synced 2025-11-04 13:23:42 +08:00 
			
		
		
		
	增加了一个超链聊天跳转
在“运营设置里面”增加了“聊天页面2链接”,方便将项目(https://github.com/Dooy/chatgpt-web-midjourney-proxy) 替换掉原来的AMA问天。 Changes to be committed: modified: common/constants.go modified: controller/misc.go modified: model/option.go modified: web/src/App.js modified: web/src/components/OperationSetting.js modified: web/src/components/TokensTable.js
This commit is contained in:
		@@ -21,6 +21,7 @@ var Footer = ""
 | 
				
			|||||||
var Logo = ""
 | 
					var Logo = ""
 | 
				
			||||||
var TopUpLink = ""
 | 
					var TopUpLink = ""
 | 
				
			||||||
var ChatLink = ""
 | 
					var ChatLink = ""
 | 
				
			||||||
 | 
					var ChatLink2 = ""
 | 
				
			||||||
var QuotaPerUnit = 500 * 1000.0 // $0.002 / 1K tokens
 | 
					var QuotaPerUnit = 500 * 1000.0 // $0.002 / 1K tokens
 | 
				
			||||||
var DisplayInCurrencyEnabled = true
 | 
					var DisplayInCurrencyEnabled = true
 | 
				
			||||||
var DisplayTokenStatEnabled = true
 | 
					var DisplayTokenStatEnabled = true
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,7 @@ func GetStatus(c *gin.Context) {
 | 
				
			|||||||
			"turnstile_site_key":       common.TurnstileSiteKey,
 | 
								"turnstile_site_key":       common.TurnstileSiteKey,
 | 
				
			||||||
			"top_up_link":              common.TopUpLink,
 | 
								"top_up_link":              common.TopUpLink,
 | 
				
			||||||
			"chat_link":                common.ChatLink,
 | 
								"chat_link":                common.ChatLink,
 | 
				
			||||||
 | 
								"chat_link2":               common.ChatLink2,
 | 
				
			||||||
			"quota_per_unit":           common.QuotaPerUnit,
 | 
								"quota_per_unit":           common.QuotaPerUnit,
 | 
				
			||||||
			"display_in_currency":      common.DisplayInCurrencyEnabled,
 | 
								"display_in_currency":      common.DisplayInCurrencyEnabled,
 | 
				
			||||||
			"enable_batch_update":      common.BatchUpdateEnabled,
 | 
								"enable_batch_update":      common.BatchUpdateEnabled,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,6 +76,7 @@ func InitOptionMap() {
 | 
				
			|||||||
	common.OptionMap["GroupRatio"] = common.GroupRatio2JSONString()
 | 
						common.OptionMap["GroupRatio"] = common.GroupRatio2JSONString()
 | 
				
			||||||
	common.OptionMap["TopUpLink"] = common.TopUpLink
 | 
						common.OptionMap["TopUpLink"] = common.TopUpLink
 | 
				
			||||||
	common.OptionMap["ChatLink"] = common.ChatLink
 | 
						common.OptionMap["ChatLink"] = common.ChatLink
 | 
				
			||||||
 | 
						common.OptionMap["ChatLink2"] = common.ChatLink2
 | 
				
			||||||
	common.OptionMap["QuotaPerUnit"] = strconv.FormatFloat(common.QuotaPerUnit, 'f', -1, 64)
 | 
						common.OptionMap["QuotaPerUnit"] = strconv.FormatFloat(common.QuotaPerUnit, 'f', -1, 64)
 | 
				
			||||||
	common.OptionMap["RetryTimes"] = strconv.Itoa(common.RetryTimes)
 | 
						common.OptionMap["RetryTimes"] = strconv.Itoa(common.RetryTimes)
 | 
				
			||||||
	common.OptionMap["DataExportInterval"] = strconv.Itoa(common.DataExportInterval)
 | 
						common.OptionMap["DataExportInterval"] = strconv.Itoa(common.DataExportInterval)
 | 
				
			||||||
@@ -241,6 +242,8 @@ func updateOptionMap(key string, value string) (err error) {
 | 
				
			|||||||
		common.TopUpLink = value
 | 
							common.TopUpLink = value
 | 
				
			||||||
	case "ChatLink":
 | 
						case "ChatLink":
 | 
				
			||||||
		common.ChatLink = value
 | 
							common.ChatLink = value
 | 
				
			||||||
 | 
						case "ChatLink2":
 | 
				
			||||||
 | 
							common.ChatLink2 = value
 | 
				
			||||||
	case "ChannelDisableThreshold":
 | 
						case "ChannelDisableThreshold":
 | 
				
			||||||
		common.ChannelDisableThreshold, _ = strconv.ParseFloat(value, 64)
 | 
							common.ChannelDisableThreshold, _ = strconv.ParseFloat(value, 64)
 | 
				
			||||||
	case "QuotaPerUnit":
 | 
						case "QuotaPerUnit":
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,11 @@ function App() {
 | 
				
			|||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        localStorage.removeItem('chat_link');
 | 
					        localStorage.removeItem('chat_link');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      if (data.chat_link2) {
 | 
				
			||||||
 | 
					        localStorage.setItem('chat_link2', data.chat_link2);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        localStorage.removeItem('chat_link2');
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      // if (
 | 
					      // if (
 | 
				
			||||||
      //   data.version !== process.env.REACT_APP_VERSION &&
 | 
					      //   data.version !== process.env.REACT_APP_VERSION &&
 | 
				
			||||||
      //   data.version !== 'v0.0.0' &&
 | 
					      //   data.version !== 'v0.0.0' &&
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@ const OperationSetting = () => {
 | 
				
			|||||||
        GroupRatio: '',
 | 
					        GroupRatio: '',
 | 
				
			||||||
        TopUpLink: '',
 | 
					        TopUpLink: '',
 | 
				
			||||||
        ChatLink: '',
 | 
					        ChatLink: '',
 | 
				
			||||||
 | 
					        ChatLink2: '', // 添加的新状态变量
 | 
				
			||||||
        QuotaPerUnit: 0,
 | 
					        QuotaPerUnit: 0,
 | 
				
			||||||
        AutomaticDisableChannelEnabled: '',
 | 
					        AutomaticDisableChannelEnabled: '',
 | 
				
			||||||
        ChannelDisableThreshold: 0,
 | 
					        ChannelDisableThreshold: 0,
 | 
				
			||||||
@@ -141,6 +142,9 @@ const OperationSetting = () => {
 | 
				
			|||||||
                if (originInputs['ChatLink'] !== inputs.ChatLink) {
 | 
					                if (originInputs['ChatLink'] !== inputs.ChatLink) {
 | 
				
			||||||
                    await updateOption('ChatLink', inputs.ChatLink);
 | 
					                    await updateOption('ChatLink', inputs.ChatLink);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if (originInputs['ChatLink2'] !== inputs.ChatLink2) {
 | 
				
			||||||
 | 
					                    await updateOption('ChatLink2', inputs.ChatLink2);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                if (originInputs['QuotaPerUnit'] !== inputs.QuotaPerUnit) {
 | 
					                if (originInputs['QuotaPerUnit'] !== inputs.QuotaPerUnit) {
 | 
				
			||||||
                    await updateOption('QuotaPerUnit', inputs.QuotaPerUnit);
 | 
					                    await updateOption('QuotaPerUnit', inputs.QuotaPerUnit);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -187,6 +191,15 @@ const OperationSetting = () => {
 | 
				
			|||||||
                            type='link'
 | 
					                            type='link'
 | 
				
			||||||
                            placeholder='例如 ChatGPT Next Web 的部署地址'
 | 
					                            placeholder='例如 ChatGPT Next Web 的部署地址'
 | 
				
			||||||
                        />
 | 
					                        />
 | 
				
			||||||
 | 
					                        <Form.Input
 | 
				
			||||||
 | 
					                            label='聊天页面2链接'
 | 
				
			||||||
 | 
					                            name='ChatLink2'
 | 
				
			||||||
 | 
					                            onChange={handleInputChange}
 | 
				
			||||||
 | 
					                            autoComplete='new-password'
 | 
				
			||||||
 | 
					                            value={inputs.ChatLink2}
 | 
				
			||||||
 | 
					                            type='link'
 | 
				
			||||||
 | 
					                            placeholder='例如 ChatGPT Next Web 的部署地址'
 | 
				
			||||||
 | 
					                        />
 | 
				
			||||||
                        <Form.Input
 | 
					                        <Form.Input
 | 
				
			||||||
                            label='单位美元额度'
 | 
					                            label='单位美元额度'
 | 
				
			||||||
                            name='QuotaPerUnit'
 | 
					                            name='QuotaPerUnit'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,12 +26,12 @@ const {Column} = Table;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const COPY_OPTIONS = [
 | 
					const COPY_OPTIONS = [
 | 
				
			||||||
    {key: 'next', text: 'ChatGPT Next Web', value: 'next'},
 | 
					    {key: 'next', text: 'ChatGPT Next Web', value: 'next'},
 | 
				
			||||||
    {key: 'ama', text: 'AMA 问天', value: 'ama'},
 | 
					    {key: 'ama', text: 'ChatGPT Web & Midjourney', value: 'ama'},
 | 
				
			||||||
    {key: 'opencat', text: 'OpenCat', value: 'opencat'},
 | 
					    {key: 'opencat', text: 'OpenCat', value: 'opencat'},
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const OPEN_LINK_OPTIONS = [
 | 
					const OPEN_LINK_OPTIONS = [
 | 
				
			||||||
    {key: 'ama', text: 'AMA 问天', value: 'ama'},
 | 
					    {key: 'ama', text: 'ChatGPT Web & Midjourney', value: 'ama'},
 | 
				
			||||||
    {key: 'opencat', text: 'OpenCat', value: 'opencat'},
 | 
					    {key: 'opencat', text: 'OpenCat', value: 'opencat'},
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -66,7 +66,7 @@ const TokensTable = () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    const link_menu = [
 | 
					    const link_menu = [
 | 
				
			||||||
        {node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next')}},
 | 
					        {node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next')}},
 | 
				
			||||||
        {node: 'item', key: 'ama', name: 'AMA 问天', value: 'ama'},
 | 
					        {node: 'item', key: 'ama', name: 'ChatGPT Web & Midjourney', value: 'ama'},
 | 
				
			||||||
        {node: 'item', key: 'opencat', name: 'OpenCat', value: 'opencat'},
 | 
					        {node: 'item', key: 'opencat', name: 'OpenCat', value: 'opencat'},
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -155,7 +155,7 @@ const TokensTable = () => {
 | 
				
			|||||||
                        <Dropdown trigger="click" position="bottomRight" menu={
 | 
					                        <Dropdown trigger="click" position="bottomRight" menu={
 | 
				
			||||||
                            [
 | 
					                            [
 | 
				
			||||||
                                {node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next', record.key)}},
 | 
					                                {node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next', record.key)}},
 | 
				
			||||||
                                {node: 'item', key: 'ama', name: 'AMA 问天(BotGrem)', onClick: () => {onOpenLink('ama', record.key)}},
 | 
					                                {node: 'item', key: 'ama', name: 'ChatGPT Web & Midjourney', onClick: () => {onOpenLink('ama', record.key)}},
 | 
				
			||||||
                                {node: 'item', key: 'opencat', name: 'OpenCat', onClick: () => {onOpenLink('opencat', record.key)}},
 | 
					                                {node: 'item', key: 'opencat', name: 'OpenCat', onClick: () => {onOpenLink('opencat', record.key)}},
 | 
				
			||||||
                            ]
 | 
					                            ]
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
@@ -289,6 +289,7 @@ const TokensTable = () => {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        let encodedServerAddress = encodeURIComponent(serverAddress);
 | 
					        let encodedServerAddress = encodeURIComponent(serverAddress);
 | 
				
			||||||
        const nextLink = localStorage.getItem('chat_link');
 | 
					        const nextLink = localStorage.getItem('chat_link');
 | 
				
			||||||
 | 
					        const mjLink = localStorage.getItem('chat_link2');
 | 
				
			||||||
        let nextUrl;
 | 
					        let nextUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (nextLink) {
 | 
					        if (nextLink) {
 | 
				
			||||||
@@ -300,7 +301,7 @@ const TokensTable = () => {
 | 
				
			|||||||
        let url;
 | 
					        let url;
 | 
				
			||||||
        switch (type) {
 | 
					        switch (type) {
 | 
				
			||||||
            case 'ama':
 | 
					            case 'ama':
 | 
				
			||||||
                url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
 | 
					                url = mjLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 'opencat':
 | 
					            case 'opencat':
 | 
				
			||||||
                url = `opencat://team/join?domain=${encodedServerAddress}&token=sk-${key}`;
 | 
					                url = `opencat://team/join?domain=${encodedServerAddress}&token=sk-${key}`;
 | 
				
			||||||
@@ -351,7 +352,7 @@ const TokensTable = () => {
 | 
				
			|||||||
        let url;
 | 
					        let url;
 | 
				
			||||||
        switch (type) {
 | 
					        switch (type) {
 | 
				
			||||||
            case 'ama':
 | 
					            case 'ama':
 | 
				
			||||||
                url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
 | 
					                url = `https://mjgpt.grqnas.cn/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            case 'opencat':
 | 
					            case 'opencat':
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user